ci: streamline and unify pipelines with parallelized QA and optimized Docker builds
Some checks failed
Some checks failed
This commit is contained in:
46
Dockerfile
46
Dockerfile
@@ -1,50 +1,42 @@
|
||||
# Start from the pre-built Nextjs Base image
|
||||
# Stage 1: Builder
|
||||
FROM registry.infra.mintel.me/mintel/nextjs:latest AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Ensure we are in a clean, standalone environment
|
||||
RUN rm -rf packages apps pnpm-workspace.yaml 2>/dev/null || true
|
||||
|
||||
# Build-time environment variables for Next.js
|
||||
# Arguments for build-time configuration
|
||||
ARG NEXT_PUBLIC_BASE_URL
|
||||
ARG DIRECTUS_URL
|
||||
ARG NEXT_PUBLIC_TARGET
|
||||
ARG DIRECTUS_URL
|
||||
ARG NPM_TOKEN
|
||||
ARG REGISTRY_HOST
|
||||
|
||||
# Environment variables for Next.js build
|
||||
ENV NEXT_PUBLIC_BASE_URL=$NEXT_PUBLIC_BASE_URL
|
||||
ENV DIRECTUS_URL=$DIRECTUS_URL
|
||||
ENV NEXT_PUBLIC_TARGET=$NEXT_PUBLIC_TARGET
|
||||
ENV NPM_TOKEN=$NPM_TOKEN
|
||||
ENV DIRECTUS_URL=$DIRECTUS_URL
|
||||
ENV SKIP_RUNTIME_ENV_VALIDATION=true
|
||||
ENV CI=true
|
||||
|
||||
# Enable corepack (pnpm is already in base image)
|
||||
# Enable pnpm
|
||||
RUN corepack enable
|
||||
|
||||
# Copy package files
|
||||
COPY package.json pnpm-lock.yaml* ./
|
||||
# Copy lockfile and manifest for dependency installation caching
|
||||
COPY pnpm-lock.yaml package.json .npmrc* ./
|
||||
|
||||
# Install dependencies based on the preferred package manager
|
||||
# Create .npmrc for private registry access if token is present
|
||||
RUN if [ -n "$NPM_TOKEN" ]; then \
|
||||
REGISTRY="${REGISTRY_HOST:-npm.infra.mintel.me}" && \
|
||||
echo "@mintel:registry=https://$REGISTRY" > .npmrc && \
|
||||
echo "//$REGISTRY/:_authToken=$NPM_TOKEN" >> .npmrc; \
|
||||
fi
|
||||
# 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 install --frozen-lockfile
|
||||
|
||||
RUN pnpm install --frozen-lockfile
|
||||
|
||||
# Copy local files
|
||||
# Copy source code
|
||||
COPY . .
|
||||
|
||||
# Build the specific application
|
||||
# Build application
|
||||
RUN pnpm build
|
||||
|
||||
# Production runner image
|
||||
# Stage 2: Runner
|
||||
FROM registry.infra.mintel.me/mintel/runtime:latest AS runner
|
||||
WORKDIR /app
|
||||
|
||||
# Production environment configuration
|
||||
ENV HOSTNAME="0.0.0.0"
|
||||
ENV PORT=3000
|
||||
ENV NODE_ENV=production
|
||||
@@ -53,8 +45,6 @@ ENV NODE_ENV=production
|
||||
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
|
||||
|
||||
# Ensure the cache directory specifically is writeable (Mintel Standard #16)
|
||||
COPY --from=builder --chown=nextjs:nodejs /app/.next/cache ./.next/cache
|
||||
|
||||
USER nextjs
|
||||
|
||||
Reference in New Issue
Block a user