Skip to content

Commit 1557c86

Browse files
authored
Update Dockerfile
1 parent 7d22e1a commit 1557c86

File tree

1 file changed

+18
-33
lines changed

1 file changed

+18
-33
lines changed

Dockerfile

Lines changed: 18 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,21 @@
1-
# use the official Bun image
2-
# see all versions at https://hub.docker.com/r/oven/bun/tags
3-
FROM oven/bun:1.1.0 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 package-lock.json /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 package-lock.json /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
1+
FROM node:22-alpine AS builder
2+
3+
COPY . /app
4+
5+
WORKDIR /app
6+
7+
RUN --mount=type=cache,target=/root/.npm npm install
8+
9+
FROM node:22-alpine AS release
10+
11+
WORKDIR /app
12+
13+
COPY --from=builder /app/*.js /app/
14+
COPY --from=builder /app/package.json /app/package.json
15+
COPY --from=builder /app/package-lock.json /app/package-lock.json
16+
2517
ENV NODE_ENV=production
26-
# RUN bun test
27-
# RUN bun run build
2818

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 .
19+
RUN npm ci --ignore-scripts --omit-dev
3320

34-
# run the app
35-
USER bun
36-
ENTRYPOINT [ "bun", "run", "app.js" ]
21+
CMD ["node", "app.js"]

0 commit comments

Comments
 (0)