All checks were successful
Build & Deploy / 🔍 Prepare (push) Successful in 5s
Build & Deploy / 🧪 QA (push) Successful in 5m22s
Build & Deploy / 🏗️ Build (push) Successful in 7m24s
Build & Deploy / 🚀 Deploy (push) Successful in 11s
Build & Deploy / 🧪 Post-Deploy Verification (push) Successful in 3m39s
Build & Deploy / 🔔 Notify (push) Successful in 1s
70 lines
1.8 KiB
Docker
70 lines
1.8 KiB
Docker
# Stage 1: Builder
|
|
FROM node:20-alpine AS builder
|
|
WORKDIR /app
|
|
|
|
# Clean the workspace
|
|
RUN rm -rf ./*
|
|
|
|
# Arguments for build-time configuration
|
|
ARG NEXT_PUBLIC_BASE_URL
|
|
ARG NEXT_PUBLIC_TARGET
|
|
ARG DIRECTUS_URL
|
|
ARG UMAMI_API_ENDPOINT
|
|
ARG NEXT_PUBLIC_UMAMI_WEBSITE_ID
|
|
ARG NPM_TOKEN
|
|
|
|
# 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_API_ENDPOINT=$UMAMI_API_ENDPOINT
|
|
ENV NEXT_PUBLIC_UMAMI_WEBSITE_ID=$NEXT_PUBLIC_UMAMI_WEBSITE_ID
|
|
ENV SKIP_RUNTIME_ENV_VALIDATION=true
|
|
ENV CI=true
|
|
|
|
# Enable pnpm
|
|
RUN corepack enable && corepack prepare pnpm@10.3.0 --activate
|
|
|
|
# Copy lockfile and manifest for dependency installation caching
|
|
COPY pnpm-lock.yaml package.json .npmrc* ./
|
|
|
|
# Install dependencies with cache mount
|
|
RUN --mount=type=cache,id=pnpm,target=/pnpm/store \
|
|
--mount=type=secret,id=NPM_TOKEN \
|
|
export NPM_TOKEN=$(cat /run/secrets/NPM_TOKEN 2>/dev/null || echo $NPM_TOKEN) && \
|
|
pnpm store prune && \
|
|
pnpm install --no-frozen-lockfile
|
|
|
|
# Copy source code
|
|
COPY . .
|
|
|
|
# Build application
|
|
RUN pnpm build
|
|
|
|
# Stage 2: Runner
|
|
FROM node:20-alpine AS runner
|
|
WORKDIR /app
|
|
|
|
# Install curl for health checks
|
|
RUN apk add --no-cache curl
|
|
|
|
# Create nextjs user and group for security
|
|
RUN addgroup --system --gid 1001 nodejs && \
|
|
adduser --system --uid 1001 nextjs && \
|
|
chown -R nextjs:nodejs /app
|
|
|
|
ENV HOSTNAME="0.0.0.0"
|
|
ENV PORT=3000
|
|
ENV NODE_ENV=production
|
|
ENV NEXT_TELEMETRY_DISABLED=1
|
|
|
|
# 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
|
|
|
|
USER nextjs
|
|
|
|
CMD ["node", "server.js"]
|