update dockerfile with pnpm deploy`
This commit is contained in:
+31
-22
@@ -1,40 +1,49 @@
|
||||
# ── Build stage ──────────────────────────────────────────
|
||||
FROM node:22-alpine AS builder
|
||||
# Browser → PB goes through nginx at /pb (same origin) — fixed for docker.
|
||||
# ENV PUBLIC_PB_URL=/pb
|
||||
|
||||
RUN corepack enable
|
||||
WORKDIR /app
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN pnpm install --frozen-lockfile
|
||||
RUN pnpm --filter famchamp build
|
||||
|
||||
RUN pnpm --filter frontend build
|
||||
RUN pnpm --filter proxy build
|
||||
|
||||
# Create a standalone production node_modules for frontend
|
||||
RUN pnpm --filter frontend deploy --prod /deploy/frontend
|
||||
|
||||
# ── Runtime stage ────────────────────────────────────────
|
||||
FROM node:22-alpine
|
||||
# Browser → PB goes through nginx at /pb (same origin). PB_ENDPOINT (server →
|
||||
# PB) is a loopback constant in the app code, not an env var.
|
||||
# ENV PUBLIC_PB_URL=/pb
|
||||
RUN corepack enable && apk add --no-cache nginx wget unzip ca-certificates
|
||||
|
||||
RUN corepack enable && \
|
||||
apk add --no-cache nginx wget unzip ca-certificates
|
||||
|
||||
WORKDIR /app
|
||||
COPY --from=builder /app/frontend/build ./frontend/build
|
||||
# adapter-node externalizes runtime deps (pocketbase, chart.js, qrcode, …), so
|
||||
# the frontend's pnpm node_modules (symlinks into the root .pnpm store) must be
|
||||
# present in the image too, or Node fails with ERR_MODULE_NOT_FOUND.
|
||||
#COPY --from=builder /app/frontend/node_modules ./frontend/node_modules
|
||||
COPY --from=builder /app/proxy/dist ./proxy/dist
|
||||
COPY --from=builder /app/node_modules ./node_modules
|
||||
COPY --from=builder /app/pnpm-lock.yaml ./
|
||||
|
||||
# SvelteKit build becomes /app/frontend
|
||||
COPY --from=builder /app/frontend/build ./frontend
|
||||
|
||||
# Production dependencies for the frontend
|
||||
COPY --from=builder /deploy/frontend/node_modules ./frontend/node_modules
|
||||
COPY --from=builder /deploy/frontend/package.json ./frontend/package.json
|
||||
|
||||
# Proxy is bundled into one JS file by esbuild
|
||||
COPY --from=builder /app/proxy/dist ./proxy
|
||||
|
||||
COPY docker/nginx.conf /etc/nginx/http.d/default.conf
|
||||
COPY docker/entrypoint.sh /entrypoint.sh
|
||||
# Bundle PocketBase (same version as Dockerfile.dev) into the app container.
|
||||
RUN wget -qO /tmp/pb.zip https://github.com/pocketbase/pocketbase/releases/download/v0.25.8/pocketbase_0.25.8_linux_amd64.zip \
|
||||
|
||||
ARG POCKETBASE_VERSION=0.39.10
|
||||
|
||||
RUN wget -qO /tmp/pb.zip \
|
||||
"https://github.com/pocketbase/pocketbase/releases/download/v${POCKETBASE_VERSION}/pocketbase_${POCKETBASE_VERSION}_linux_amd64.zip" \
|
||||
&& unzip -o /tmp/pb.zip -d /usr/local/bin/ \
|
||||
&& rm /tmp/pb.zip
|
||||
|
||||
RUN chmod +x /entrypoint.sh /usr/local/bin/pocketbase
|
||||
# ENV FRONTEND_PORT=2080
|
||||
# ENV PROXY_PORT=3456
|
||||
# Public entrypoint. The host port is chosen at deploy time via compose PORT;
|
||||
# EXPOSE here is documentation only (nginx listens on 3001). PB (8090) stays
|
||||
# internal — never published from the image.
|
||||
|
||||
EXPOSE 3000 8090
|
||||
|
||||
CMD ["/entrypoint.sh"]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "famchamp",
|
||||
"name": "frontend",
|
||||
"private": true,
|
||||
"version": "0.0.1",
|
||||
"type": "module",
|
||||
|
||||
Reference in New Issue
Block a user