Skip to content

Commit 03d9006

Browse files
committed
feat: Refactor Dockerfile for multi-stage builds and update package.json prepare script
1 parent 4973144 commit 03d9006

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

Dockerfile

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
1-
FROM oven/bun:slim
1+
FROM oven/bun:1.2.5 AS base
2+
WORKDIR /usr/src/app
23

3-
WORKDIR /app
4+
FROM base AS install
5+
COPY package.json bun.lock ./
6+
RUN bun install --frozen-lockfile --production
47

5-
COPY package*.json ./
68

7-
RUN bun install
8-
9-
COPY src ./src
10-
COPY tsconfig.json ./
11-
12-
EXPOSE 4141
9+
FROM base AS prerelease
10+
COPY --from=install /usr/src/app/node_modules node_modules
11+
COPY . .
1312

1413
ENV NODE_ENV=production
14+
RUN bun test
15+
RUN bun run build
16+
17+
FROM base AS release
18+
COPY --from=install /usr/src/app/node_modules node_modules
19+
COPY --from=prerelease /usr/src/app/dist/ .
1520

16-
CMD ["bun", "run", "start"]
21+
USER bun
22+
EXPOSE 4141/tcp
23+
ENTRYPOINT [ "bun", "main.js"]

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"knip": "knip-bun",
2828
"lint": "eslint .",
2929
"prepack": "bun run build",
30-
"prepare": "simple-git-hooks",
30+
"prepare": "NODE_ENV=production || simple-git-hooks",
3131
"release": "bumpp && bun publish --access public",
3232
"start": "NODE_ENV=production bun run ./src/main.ts"
3333
},

0 commit comments

Comments
 (0)