parent
59d7d862d5
commit
3cc8008163
2 changed files with 29 additions and 11 deletions
36
Dockerfile
36
Dockerfile
|
@ -3,22 +3,38 @@ ENV PNPM_HOME="/pnpm"
|
|||
ENV PATH="$PNPM_HOME:$PATH"
|
||||
RUN corepack enable
|
||||
|
||||
FROM base AS build
|
||||
FROM base AS base-build
|
||||
COPY . /usr/src/app
|
||||
WORKDIR /usr/src/app
|
||||
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
|
||||
RUN pnpm run -r build
|
||||
|
||||
FROM base-build AS backend-build
|
||||
RUN pnpm run build-backend
|
||||
RUN pnpm deploy --filter=backend --prod /prod/backend
|
||||
|
||||
FROM base-build AS frontend-build
|
||||
RUN pnpm run build-frontend
|
||||
RUN pnpm deploy --filter=frontend --prod /prod/frontend
|
||||
|
||||
FROM base AS backend
|
||||
COPY --from=build /prod/backend /usr/src/app
|
||||
WORKDIR /usr/src/app
|
||||
EXPOSE 3001
|
||||
CMD ["pnpm", "start"]
|
||||
|
||||
FROM base AS frontend
|
||||
COPY --from=build /prod/frontend /usr/src/app
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
FROM node:22-slim AS backend
|
||||
WORKDIR /app
|
||||
COPY --from=backend-build /prod/backend/package*.json ./
|
||||
COPY --from=backend-build /prod/backend/dist ./dist
|
||||
COPY --from=backend-build /prod/frontend/node_modules ./node_modules
|
||||
COPY --from=backend-build /usr/src/app/keys ./keys
|
||||
|
||||
ENV NODE_ENV=production
|
||||
EXPOSE 3001
|
||||
CMD [ "node", "dist/main.js" ]
|
||||
|
||||
FROM node:22-slim AS frontend
|
||||
WORKDIR /app
|
||||
COPY --from=frontend-build /prod/frontend/package*.json ./
|
||||
COPY --from=frontend-build /prod/frontend/.next ./.next
|
||||
COPY --from=frontend-build /prod/frontend/public ./public
|
||||
COPY --from=frontend-build /prod/frontend/node_modules ./node_modules
|
||||
ENV NODE_ENV=production
|
||||
EXPOSE 3000
|
||||
CMD ["pnpm", "start"]
|
|
@ -5,7 +5,9 @@
|
|||
"main": "index.js",
|
||||
"scripts": {
|
||||
"dev": "pnpm run --parallel dev",
|
||||
"build": "pnpm run --parallel build"
|
||||
"build": "pnpm run --parallel build",
|
||||
"build-frontend": "pnpm run --filter=frontend build",
|
||||
"build-backend": "pnpm run --filter=backend build"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
|
|
Loading…
Add table
Reference in a new issue