hrms-edm/Services/Dockerfile

35 lines
854 B
Docker

# 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
ARG API_ENDPOINT="/api/"
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 .
ENV VITE_API_ENDPOINT="$API_ENDPOINT"
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"]