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:
parent
819ffef722
commit
2042003949
1 changed files with 10 additions and 5 deletions
15
Dockerfile
15
Dockerfile
|
|
@ -1,28 +1,33 @@
|
||||||
# Multi-stage build - using slim for better compatibility
|
# Multi-stage build with memory optimization
|
||||||
FROM node:20-slim AS builder
|
FROM node:20-slim AS builder
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Skip browser downloads
|
# Skip browser downloads
|
||||||
ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
|
ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
|
||||||
ENV CYPRESS_INSTALL_BINARY=0
|
ENV CYPRESS_INSTALL_BINARY=0
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
|
||||||
|
# Set API URL for build
|
||||||
|
ENV GATEWAY_URL=http://localhost:9100
|
||||||
|
|
||||||
# Install build dependencies
|
# Install build dependencies
|
||||||
RUN apt-get update && apt-get install -y python3 make g++ git && rm -rf /var/lib/apt/lists/*
|
RUN apt-get update && apt-get install -y python3 make g++ git && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Copy package files
|
# Copy package files
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
|
COPY .env ./
|
||||||
|
|
||||||
# Install dependencies
|
# 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 source
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Build with memory optimization (3GB for slim image)
|
# Build with memory optimization
|
||||||
ENV NODE_OPTIONS="--max-old-space-size=3072"
|
ENV NODE_OPTIONS="--max-old-space-size=4096"
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
# Runtime stage - use alpine for smaller size
|
# Runtime stage
|
||||||
FROM node:20-alpine
|
FROM node:20-alpine
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue