Skip to content

Commit be6bd21

Browse files
author
AiQL.com
committed
update pkg
1 parent 7576e41 commit be6bd21

File tree

3 files changed

+253
-109
lines changed

3 files changed

+253
-109
lines changed

Dockerfile

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,37 @@
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
1022
COPY . .
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" ]

0 commit comments

Comments
 (0)