File tree Expand file tree Collapse file tree 8 files changed +104
-3
lines changed Expand file tree Collapse file tree 8 files changed +104
-3
lines changed Original file line number Diff line number Diff line change 1+ node_modules
2+ Dockerfile *
3+ docker-compose *
4+ .dockerignore
5+ .git
6+ .gitignore
7+ README.md
8+ LICENSE
9+ .vscode
10+ Makefile
11+ helm-charts
12+ .env
13+ .editorconfig
14+ .idea
15+ coverage *
Original file line number Diff line number Diff line change @@ -3,3 +3,4 @@ bun.lockb
33.obsidian
44.vscode
55.idea
6+ .env
Original file line number Diff line number Diff line change 1+ # use the official Bun image
2+ # see all versions at https://hub.docker.com/r/oven/bun/tags
3+ FROM oven/bun:1 as base
4+ WORKDIR /usr/src/app
5+
6+ # install dependencies into temp directory
7+ # this will cache them and speed up future builds
8+ FROM base AS install
9+ RUN mkdir -p /temp/dev
10+ COPY package.json bun.lockb /temp/dev/
11+ RUN cd /temp/dev && bun install --frozen-lockfile
12+
13+ # install with --production (exclude devDependencies)
14+ RUN mkdir -p /temp/prod
15+ COPY package.json bun.lockb /temp/prod/
16+ RUN cd /temp/prod && bun install --frozen-lockfile --production
17+
18+ # copy node_modules from temp directory
19+ # then copy all (non-ignored) project files into the image
20+ FROM base AS prerelease
21+ COPY --from=install /temp/dev/node_modules node_modules
22+ COPY . .
23+
24+ # [optional] tests & build
25+ # ENV NODE_ENV=production
26+ # RUN bun test
27+ # RUN bun run build
28+
29+ # copy production dependencies and source code into final image
30+ FROM base AS release
31+ COPY --from=install /temp/prod/node_modules node_modules
32+ COPY --from=prerelease /usr/src/app/src/index.ts src/index.ts
33+ COPY --from=prerelease /usr/src/app/package.json .
34+
35+ # run the app
36+ USER bun
37+ EXPOSE 3000/tcp
38+ ENTRYPOINT [ "bun" , "run" , "start" ]
Original file line number Diff line number Diff line change 1+ start :
2+ bun run start
3+ dcu :
4+ sudo docker-compose rm && sudo docker-compose up --build -d
5+ dcd :
6+ sudo docker-compose down
Original file line number Diff line number Diff line change 1+ # Stub API
12An application for create custom response.
23
34## Installation
@@ -11,7 +12,7 @@ cd stub
1112bun install
1213bun run dev
1314```
14- 2 . Docker (todo)
15+ 2 . Run with Docker
1516```
1617docker compose up -d
1718```
Original file line number Diff line number Diff line change 1+ version : " 0.1"
2+ name : stub
3+
4+ services :
5+ api :
6+ container_name : stub
7+ build :
8+ context : .
9+ dockerfile : Dockerfile
10+ networks :
11+ - stub-network
12+ ports :
13+ - 3000:3000
14+ environment :
15+ - REDIS_URL=redis://redis:6379
16+ depends_on :
17+ - redis
18+ restart : on-failure
19+
20+ redis :
21+ container_name : redis
22+ image : redis:7.2-alpine
23+ ports :
24+ - 6379:6379
25+ restart : always
26+ networks :
27+ - stub-network
28+ volumes :
29+ - cache:/data
30+
31+ networks :
32+ stub-network :
33+ name : stub-network
34+
35+ volumes :
36+ cache :
37+ driver : local
Original file line number Diff line number Diff line change 11{
22 "scripts" : {
3- "dev" : " bun run --hot src/index.ts"
3+ "dev" : " bun run --hot src/index.ts" ,
4+ "start" : " bun run src/index.ts"
45 },
56 "dependencies" : {
67 "hono" : " ^3.12.7" ,
Original file line number Diff line number Diff line change @@ -2,7 +2,9 @@ import { Hono } from "hono";
22import { getCookie } from "hono/cookie" ;
33import { createClient } from "redis" ;
44
5- const client = createClient ( ) ;
5+ const client = createClient ( {
6+ url : process . env . REDIS_URL ,
7+ } ) ;
68client . on ( "error" , ( err ) => console . log ( "Redis Client Error" , err ) ) ;
79await client . connect ( ) ;
810
You can’t perform that action at this time.
0 commit comments