Update Dockerfile
This commit is contained in:
16
Dockerfile
16
Dockerfile
@@ -1,3 +1,5 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
|
||||
# Use official Node.js image as base
|
||||
# Next.js 16 requires Node 18.17+ or Node 20+
|
||||
# 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
|
||||
RUN apk add --no-cache git
|
||||
|
||||
# Install pnpm
|
||||
# Install pnpm with cache mount for better performance
|
||||
RUN npm install -g pnpm
|
||||
|
||||
# Copy package files for dependency installation
|
||||
COPY package.json pnpm-lock.yaml ./
|
||||
|
||||
# Install dependencies with pnpm
|
||||
RUN pnpm install --frozen-lockfile
|
||||
# Install dependencies with pnpm cache mount for faster builds
|
||||
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 . .
|
||||
|
||||
# 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
|
||||
|
||||
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
|
||||
# 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
|
||||
|
||||
# ---- Production Stage ----
|
||||
|
||||
Reference in New Issue
Block a user