44 lines
1.4 KiB
Docker
44 lines
1.4 KiB
Docker
FROM node:20-bookworm AS base
|
|
|
|
# Server often cannot reach registry.npmjs.org (Cloudflare). Override in Dokploy if needed.
|
|
ARG NPM_REGISTRY=https://mirror.kargadan.ir/repository/npm-group/
|
|
ENV npm_config_registry=${NPM_REGISTRY}
|
|
ENV PNPM_HOME="/pnpm"
|
|
ENV PATH="$PNPM_HOME:$PATH"
|
|
|
|
# Skip corepack (it fetches pnpm from npmjs/Cloudflare). Install from mirror instead.
|
|
# Pin major only — Iranian mirrors often lag behind exact patch versions (e.g. 2.10.12).
|
|
RUN npm install -g pnpm@9 turbo@2 \
|
|
&& printf 'registry=%s\n' "${NPM_REGISTRY}" > /root/.npmrc
|
|
|
|
FROM base AS builder
|
|
WORKDIR /app
|
|
COPY . .
|
|
RUN turbo prune admin-panel --docker
|
|
|
|
FROM base AS installer
|
|
WORKDIR /app
|
|
# First install dependencies
|
|
COPY .gitignore .gitignore
|
|
COPY --from=builder /app/out/json/ .
|
|
COPY --from=builder /app/out/pnpm-lock.yaml ./pnpm-lock.yaml
|
|
RUN pnpm install --frozen-lockfile
|
|
|
|
# Build the project
|
|
COPY --from=builder /app/out/full/ .
|
|
COPY turbo.json turbo.json
|
|
COPY tsconfig.base.json tsconfig.base.json
|
|
# Re-link workspace after full source copy (pnpm symlinks)
|
|
RUN pnpm install --frozen-lockfile --offline || pnpm install --frozen-lockfile
|
|
RUN pnpm turbo run build --filter=admin-panel...
|
|
|
|
FROM nginx:alpine AS runner
|
|
# Copy custom Nginx configuration
|
|
COPY nginx-spa.conf /etc/nginx/conf.d/default.conf
|
|
|
|
# Copy the built files from the installer stage
|
|
COPY --from=installer /app/apps/admin-panel/dist /usr/share/nginx/html
|
|
|
|
EXPOSE 80
|
|
CMD ["nginx", "-g", "daemon off;"]
|