- connect-src: allow the GlitchTip domain itself so the SDK can report events - media-src: allow Mux's edge CDN (*.edgemv.mux.com) for HLS manifests - img-src: allow blob: for client-side upload previews - pass SENTRY_ORG/SENTRY_PROJECT/SENTRY_AUTH_TOKEN as Docker build args so withSentryConfig can upload readable source maps during `npm run build`
67 lines
2.5 KiB
Docker
67 lines
2.5 KiB
Docker
# ──────────────────────────────────────────────
|
|
# Stage 1: install dependencies
|
|
# ──────────────────────────────────────────────
|
|
FROM node:22-alpine AS deps
|
|
RUN apk add --no-cache libc6-compat
|
|
WORKDIR /app
|
|
|
|
COPY package*.json ./
|
|
RUN npm ci
|
|
|
|
# ──────────────────────────────────────────────
|
|
# Stage 2: build
|
|
# ──────────────────────────────────────────────
|
|
FROM node:22-alpine AS builder
|
|
WORKDIR /app
|
|
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY . .
|
|
|
|
# NEXT_PUBLIC_* vars are baked into the client bundle at build time.
|
|
# All other server-side secrets are injected at runtime via docker-compose
|
|
# env_file — except the three below, which withSentryConfig (next.config.ts)
|
|
# needs during `npm run build` itself to upload source maps. They never reach
|
|
# the final runner stage (discarded with this builder stage), so they don't
|
|
# leak into the shipped image's runtime environment.
|
|
ARG NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY
|
|
ARG NEXT_PUBLIC_SUPABASE_URL
|
|
ARG NEXT_PUBLIC_SENTRY_DSN
|
|
ARG SENTRY_ORG
|
|
ARG SENTRY_PROJECT
|
|
ARG SENTRY_AUTH_TOKEN
|
|
|
|
ENV NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=$NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY
|
|
ENV NEXT_PUBLIC_SUPABASE_URL=$NEXT_PUBLIC_SUPABASE_URL
|
|
ENV NEXT_PUBLIC_SENTRY_DSN=$NEXT_PUBLIC_SENTRY_DSN
|
|
ENV SENTRY_ORG=$SENTRY_ORG
|
|
ENV SENTRY_PROJECT=$SENTRY_PROJECT
|
|
ENV SENTRY_AUTH_TOKEN=$SENTRY_AUTH_TOKEN
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
|
|
RUN npx prisma generate
|
|
RUN npm run build
|
|
|
|
# ──────────────────────────────────────────────
|
|
# Stage 3: production image (minimal)
|
|
# ──────────────────────────────────────────────
|
|
FROM node:22-alpine AS runner
|
|
WORKDIR /app
|
|
|
|
ENV NODE_ENV=production
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
|
|
RUN addgroup --system --gid 1001 nodejs \
|
|
&& adduser --system --uid 1001 nextjs
|
|
|
|
COPY --from=builder /app/public ./public
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
|
|
|
USER nextjs
|
|
|
|
EXPOSE 3000
|
|
ENV PORT=3000
|
|
ENV HOSTNAME="0.0.0.0"
|
|
|
|
CMD ["node", "server.js"]
|