feat: refactor dockerfiles

* combine dev and prod into multi-stages dockerfile
* replace node with node:20-alpine to reduce image size
This commit is contained in:
Lin, Hung-Shin authored and wancat committed 2023-10-29 17:41:38 +08:00
1 parent 625c1a80da
commit 579d53a273
10 files changed
+59 -67

No files matched your search

+19 -6
View File
@@ -1,4 +1,4 @@
FROM node
FROM node:20-alpine AS build
WORKDIR /app
COPY ./package.json yarn.lock ./
@@ -8,17 +8,30 @@ COPY packages/utils/package.json ./packages/utils/package.json
COPY packages/models/package.json ./packages/models/package.json
RUN yarn install --frozen-lockfile --production
ENV HOST=0.0.0.0
ENV PORT=3000
EXPOSE 3000
# Production
FROM build as prod
COPY ./server ./server
COPY packages/file-graph ./packages/file-graph
COPY packages/utils ./packages/utils
COPY packages/models ./packages/models
COPY quests ./quests
ENV NODE_ENV=production
WORKDIR /app/server
ENV NODE_ENV=production
ENV HOST=0.0.0.0
ENV PORT=3000
EXPOSE 3000
CMD [ "yarn", "start" ]
CMD [ "yarn", "start" ]
# Development
FROM build as dev
RUN yarn install --frozen-lockfile
ENV NODE_ENV=development
CMD [ "yarn", "server" ]