fix(docker): add .env file and GATEWAY_URL for build

- Copy .env file before npm install

- Set GATEWAY_URL env var

- Use npm ci instead of npm install
This commit is contained in:
Ashwin Kumar 2026-04-10 19:22:37 +02:00
parent 819ffef722
commit 2042003949

View file

@ -1,28 +1,33 @@
# Multi-stage build - using slim for better compatibility
# Multi-stage build with memory optimization
FROM node:20-slim AS builder
WORKDIR /app
# Skip browser downloads
ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
ENV CYPRESS_INSTALL_BINARY=0
ENV NODE_ENV=production
# Set API URL for build
ENV GATEWAY_URL=http://localhost:9100
# Install build dependencies
RUN apt-get update && apt-get install -y python3 make g++ git && rm -rf /var/lib/apt/lists/*
# Copy package files
COPY package*.json ./
COPY .env ./
# Install dependencies
RUN npm install --legacy-peer-deps --prefer-offline --no-audit
RUN npm ci --legacy-peer-deps --prefer-offline --no-audit
# Copy source
COPY . .
# Build with memory optimization (3GB for slim image)
ENV NODE_OPTIONS="--max-old-space-size=3072"
# Build with memory optimization
ENV NODE_OPTIONS="--max-old-space-size=4096"
RUN npm run build
# Runtime stage - use alpine for smaller size
# Runtime stage
FROM node:20-alpine
WORKDIR /app