Update Dockerfile

This commit is contained in:
g
2026-01-11 07:41:04 +00:00
parent 4d9f205277
commit 6f62414888

View File

@@ -1,3 +1,5 @@
# syntax=docker/dockerfile:1
# Use official Node.js image as base # Use official Node.js image as base
# Next.js 16 requires Node 18.17+ or Node 20+ # Next.js 16 requires Node 18.17+ or Node 20+
# Using node:20-alpine for better compatibility with Next.js 16 and Turbopack # Using node:20-alpine for better compatibility with Next.js 16 and Turbopack
@@ -7,17 +9,22 @@ WORKDIR /app
# Install git early for commit hash # Install git early for commit hash
RUN apk add --no-cache git RUN apk add --no-cache git
# Install pnpm # Install pnpm with cache mount for better performance
RUN npm install -g pnpm RUN npm install -g pnpm
# Copy package files for dependency installation
COPY package.json pnpm-lock.yaml ./ COPY package.json pnpm-lock.yaml ./
# Install dependencies with pnpm # Install dependencies with pnpm cache mount for faster builds
RUN pnpm install --frozen-lockfile RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm \
--mount=type=cache,id=node_modules,target=/app/node_modules \
pnpm install --frozen-lockfile
# Copy source code after dependencies are installed (for better caching)
COPY . . COPY . .
# Get commit hash (fallback to "unknown" if not in git repo) # Get commit hash (fallback to "unknown" if not in git repo)
# This is done after copying source to avoid cache invalidation
RUN git rev-parse --short HEAD > /app/git_commit_sha 2>/dev/null || echo "unknown" > /app/git_commit_sha RUN git rev-parse --short HEAD > /app/git_commit_sha 2>/dev/null || echo "unknown" > /app/git_commit_sha
ENV NEXT_PUBLIC_API_URL=/api ENV NEXT_PUBLIC_API_URL=/api
@@ -27,7 +34,8 @@ ENV API_HOSTNAME=internal-api.inboxi.ng
# Build the Next.js application with increased memory for Turbopack # Build the Next.js application with increased memory for Turbopack
# Next.js 16 uses Turbopack by default which may need more memory # Next.js 16 uses Turbopack by default which may need more memory
RUN echo "Building with GIT_COMMIT_SHA=$(cat /app/git_commit_sha)" && \ RUN --mount=type=cache,id=nextjs,target=/app/.next/cache \
echo "Building with GIT_COMMIT_SHA=$(cat /app/git_commit_sha)" && \
NODE_OPTIONS='--max_old_space_size=4096' NEXT_TELEMETRY_DISABLED=1 pnpm run build NODE_OPTIONS='--max_old_space_size=4096' NEXT_TELEMETRY_DISABLED=1 pnpm run build
# ---- Production Stage ---- # ---- Production Stage ----