Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 8s
Build & Deploy / 🧪 QA (push) Successful in 1m46s
Build & Deploy / 🏗️ Build (push) Successful in 12m0s
Build & Deploy / 🚀 Deploy (push) Successful in 34s
Build & Deploy / 🔔 Notify (push) Has been cancelled
Build & Deploy / 🧪 Post-Deploy Verification (push) Has been cancelled
73 lines
2.2 KiB
Docker
73 lines
2.2 KiB
Docker
# Stage 1: Builder
|
|
FROM registry.infra.mintel.me/mintel/nextjs:v1.7.10 AS base
|
|
WORKDIR /app
|
|
|
|
# Arguments for build-time configuration
|
|
ARG NEXT_PUBLIC_BASE_URL
|
|
ARG NEXT_PUBLIC_TARGET
|
|
ARG DIRECTUS_URL
|
|
ARG UMAMI_WEBSITE_ID
|
|
ARG UMAMI_API_ENDPOINT
|
|
|
|
# Environment variables for Next.js build
|
|
ENV NEXT_PUBLIC_BASE_URL=$NEXT_PUBLIC_BASE_URL
|
|
ENV NEXT_PUBLIC_TARGET=$NEXT_PUBLIC_TARGET
|
|
ENV DIRECTUS_URL=$DIRECTUS_URL
|
|
ENV UMAMI_WEBSITE_ID=$UMAMI_WEBSITE_ID
|
|
ENV UMAMI_API_ENDPOINT=$UMAMI_API_ENDPOINT
|
|
ENV SKIP_RUNTIME_ENV_VALIDATION=true
|
|
ENV CI=true
|
|
|
|
# Copy lockfile and manifest for dependency installation caching
|
|
COPY pnpm-lock.yaml package.json .npmrc* ./
|
|
|
|
# Configure private registry and install dependencies
|
|
RUN --mount=type=cache,id=pnpm,target=/pnpm/store \
|
|
--mount=type=secret,id=NPM_TOKEN \
|
|
export NPM_TOKEN=$(cat /run/secrets/NPM_TOKEN) && \
|
|
echo "@mintel:registry=https://npm.infra.mintel.me" > .npmrc && \
|
|
echo "//npm.infra.mintel.me/:_authToken=\${NPM_TOKEN}" >> .npmrc && \
|
|
pnpm install --frozen-lockfile && \
|
|
rm .npmrc
|
|
|
|
# Copy source code
|
|
COPY . .
|
|
|
|
# Stage 2: Development (Hot-Reloading)
|
|
FROM base AS development
|
|
ENV NODE_ENV=development
|
|
CMD ["pnpm", "dev:local"]
|
|
|
|
# Build application
|
|
# Stage 3: Builder (Production)
|
|
FROM base AS builder
|
|
# Limit memory to 1GB to prevent ResourceExhausted in combination with worker limits
|
|
ENV NODE_OPTIONS="--max-old-space-size=1024"
|
|
|
|
# Force Turbopack (Rust/Rayon) and Node.js to use strictly 1 thread to avoid starving the Gitea Runner VPS CPU
|
|
ENV RAYON_NUM_THREADS=1
|
|
ENV UV_THREADPOOL_SIZE=1
|
|
|
|
RUN pnpm build
|
|
|
|
# Stage 3: Runner
|
|
FROM registry.infra.mintel.me/mintel/runtime:v1.7.10 AS runner
|
|
WORKDIR /app
|
|
|
|
# Create nextjs user and group (standardized in runtime image but ensuring local ownership)
|
|
USER root
|
|
RUN chown -R nextjs:nodejs /app
|
|
USER nextjs
|
|
|
|
ENV HOSTNAME="0.0.0.0"
|
|
ENV PORT=3000
|
|
ENV NODE_ENV=production
|
|
|
|
# Copy standalone output and static files
|
|
COPY --from=builder --chown=nextjs:nodejs /app/public ./public
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
|
|
COPY --from=builder --chown=nextjs:nodejs /app/.next/cache ./.next/cache
|
|
|
|
CMD ["node", "server.js"]
|