feat: docker build bundle client/server

This commit is contained in:
Methapon2001 2023-11-30 15:30:33 +07:00
parent c3dfcfa1e7
commit a27dda4300
No known key found for this signature in database
GPG key ID: 849924FEF46BD132
2 changed files with 38 additions and 0 deletions

6
Services/.dockerignore Normal file
View file

@ -0,0 +1,6 @@
.DS_Store
node_modules
dist
.env
.env.*
!.env.example

32
Services/Dockerfile Normal file
View file

@ -0,0 +1,32 @@
# docker build -t docker.frappet.com/edm/core .
FROM node:20-slim AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable
WORKDIR /app
FROM base as server
COPY ./server .
FROM server AS deps
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile
FROM server AS build
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN pnpm run build
FROM base as client
COPY ./client .
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
RUN pnpm run build
FROM base as prod
COPY --from=deps /app/node_modules /app/node_modules
COPY --from=build /app/dist /app/dist
COPY --from=server /app/static /app/static
COPY --from=client /app/dist /app/static
CMD ["node", "./dist/app.js"]