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

+11 -4
View File
@@ -1,5 +1,5 @@
# Build stage
FROM node as build-stage
# Base stage
FROM node:20-alpine as base
WORKDIR /app
COPY package.json yarn.lock ./
COPY app/package.json ./app/package.json
@@ -7,14 +7,21 @@ COPY packages/file-graph/package.json ./packages/file-graph/package.json
COPY packages/utils/package.json ./packages/utils/package.json
RUN yarn install --frozen-lockfile
# Dev stage
FROM base as dev
WORKDIR /app/app
CMD [ "yarn", "dev:docker", "--host", "0.0.0.0" ]
# Build stage
FROM base as build
COPY app ./app
COPY packages/file-graph ./packages/file-graph
COPY packages/utils ./packages/utils
RUN yarn build
# Production stage
FROM nginx:stable-alpine as production-stage
COPY --from=build-stage /app/app/dist /usr/share/nginx/html
FROM nginx:stable-alpine as prod
COPY --from=build /app/app/dist /usr/share/nginx/html
COPY deployment/nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]