Optimize deployment and improve package.json

This commit is contained in:
2025-08-23 21:55:21 +03:00
Unverified
parent 91e815029e
commit 1fa1178397
4 changed files with 47 additions and 3 deletions
+15 -2
View File
@@ -1,26 +1,39 @@
# 1. Build the frontend
FROM node:24 AS frontend
# 1.1. Install npm dependencies
WORKDIR /app
COPY package.json .
RUN npm install --ignore-scripts
RUN --mount=type=cache,target=/root/.npm \
npm install --ignore-scripts
# 1.2. Build
COPY frontend frontend
RUN npm run build
# 2. Build the static file server
FROM node:24 AS server
# 2.1. Install npm dependencies
WORKDIR /server
COPY deployment/frontend/package.json .
RUN npm install
RUN --mount=type=cache,target=/root/.npm \
npm install
# 2.2. Copy the code
COPY deployment/frontend/ .
# 3. Put it all together
FROM node:24-slim
# 3.1. Frontend static files
WORKDIR /app
COPY --from=frontend /app/frontend/dist .
# 3.2. Static file server
WORKDIR /server
COPY --from=server /server .
# 4. Final command
ENV STATIC_FILE_PATH=/app
ENTRYPOINT ["npm", "run", "start"]