File tree Expand file tree Collapse file tree 3 files changed +253
-109
lines changed
Expand file tree Collapse file tree 3 files changed +253
-109
lines changed Original file line number Diff line number Diff line change 1- FROM node:lts-alpine
2- RUN npm install pm2 -g
1+ # use the official Bun image
2+ # see all versions at https://hub.docker.com/r/oven/bun/tags
3+ FROM oven/bun:slim AS base
4+ WORKDIR /usr/src/app
35
4- WORKDIR /app
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
512
6- COPY package*.json ./
7-
8- RUN npm install ci
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
917
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
1022COPY . .
1123
12- CMD ["pm2-runtime" , "app.js" ]
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/app.js .
33+ COPY --from=prerelease /usr/src/app/package.json .
34+
35+ # run the app
36+ USER bun
37+ ENTRYPOINT [ "bun" , "run" , "app.js" ]
You can’t perform that action at this time.
0 commit comments