38 lines
1.2 KiB
Docker
38 lines
1.2 KiB
Docker
FROM node:20-alpine AS base
|
|
RUN corepack enable && corepack prepare pnpm@9.15.4 --activate
|
|
WORKDIR /app
|
|
|
|
# --- Dependencies ---
|
|
FROM base AS deps
|
|
COPY pnpm-lock.yaml pnpm-workspace.yaml package.json ./
|
|
COPY apps/web/package.json apps/web/
|
|
COPY packages/shared/package.json packages/shared/
|
|
COPY packages/ui/package.json packages/ui/
|
|
RUN pnpm install --frozen-lockfile --prod=false
|
|
|
|
# --- Build ---
|
|
FROM base AS build
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY --from=deps /app/apps/web/node_modules ./apps/web/node_modules
|
|
COPY --from=deps /app/packages/shared/node_modules ./packages/shared/node_modules
|
|
COPY --from=deps /app/packages/ui/node_modules ./packages/ui/node_modules
|
|
COPY . .
|
|
|
|
ARG VITE_API_URL=/api
|
|
ENV VITE_API_URL=${VITE_API_URL}
|
|
|
|
RUN pnpm --filter @source/shared build && \
|
|
pnpm --filter @source/ui build && \
|
|
pnpm --filter @source/web build
|
|
|
|
# --- Production (nginx) ---
|
|
FROM nginx:alpine AS production
|
|
|
|
COPY apps/web/nginx.conf /etc/nginx/conf.d/default.conf
|
|
COPY --from=build /app/apps/web/dist /usr/share/nginx/html
|
|
|
|
EXPOSE 80
|
|
HEALTHCHECK --interval=30s --timeout=5s CMD wget -qO- http://localhost/health || exit 1
|
|
|
|
CMD ["nginx", "-g", "daemon off;"]
|