feat: implement centralized Docker base-image strategy and automate registry pushes
All checks were successful
Monorepo Pipeline / 🧪 Quality Assurance (push) Successful in 2m33s
Monorepo Pipeline / 🚀 Release (push) Has been skipped
Monorepo Pipeline / 🐳 Build & Push Images (push) Has been skipped

This commit is contained in:
2026-02-03 11:50:17 +01:00
parent 653deb7995
commit a8bc039c02
7 changed files with 187 additions and 159 deletions

View File

@@ -1,25 +1,8 @@
FROM node:20-alpine AS base
# Start from the pre-built Nextjs Base image
FROM registry.infra.mintel.me/mintel/nextjs:latest AS builder
# Install dependencies only when needed
FROM base AS deps
RUN apk add --no-cache libc6-compat curl
WORKDIR /app
# Install dependencies based on the preferred package manager
COPY package.json package-lock.json* pnpm-lock.yaml* ./
RUN corepack enable pnpm && \
pnpm config set store-dir /root/.local/share/pnpm/store/v3 && \
pnpm i --frozen-lockfile
# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .
# Next.js collects completely anonymous telemetry data about general usage.
ENV NEXT_TELEMETRY_DISABLED=1
# Build-time environment variables for Next.js
ARG NEXT_PUBLIC_BASE_URL
ARG NEXT_PUBLIC_UMAMI_WEBSITE_ID
@@ -33,11 +16,11 @@ ENV NEXT_PUBLIC_UMAMI_SCRIPT_URL=$NEXT_PUBLIC_UMAMI_SCRIPT_URL
ENV NEXT_PUBLIC_TARGET=$NEXT_PUBLIC_TARGET
ENV DIRECTUS_URL=$DIRECTUS_URL
# Build the application
RUN corepack enable pnpm && pnpm run build
# Build the specific application
RUN pnpm --filter sample-website build
# Production image, copy all the files and run next
FROM base AS runner
# Production runner image
FROM node:20-alpine AS runner
WORKDIR /app
# Install curl for health checks
@@ -49,15 +32,15 @@ ENV NEXT_TELEMETRY_DISABLED=1
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs
COPY --from=builder /app/public ./public
COPY --from=builder /app/apps/sample-website/public ./apps/sample-website/public
# Set the correct permission for prerender cache
RUN mkdir .next
RUN chown nextjs:nodejs .next
RUN mkdir -p apps/sample-website/.next
RUN chown nextjs:nodejs apps/sample-website/.next
# Automatically leverage output traces to reduce image size
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
# Copy standalone output and static files from the monorepo path
COPY --from=builder --chown=nextjs:nodejs /app/apps/sample-website/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/apps/sample-website/.next/static ./apps/sample-website/.next/static
USER nextjs
@@ -66,4 +49,5 @@ EXPOSE 3000
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
CMD ["node", "server.js"]
# server.js in monorepo standalone is created for each app
CMD ["node", "apps/sample-website/server.js"]

View File

@@ -9,7 +9,7 @@ services:
NEXT_PUBLIC_UMAMI_SCRIPT_URL: ${NEXT_PUBLIC_UMAMI_SCRIPT_URL}
NEXT_PUBLIC_TARGET: ${TARGET:-development}
DIRECTUS_URL: ${DIRECTUS_URL:-http://directus:8055}
image: sample-website:latest
image: registry.infra.mintel.me/mintel/sample-website:latest
container_name: sample-website-app
restart: always
networks: