Update Dockerfile
This commit is contained in:
18
Dockerfile
18
Dockerfile
@@ -1,14 +1,15 @@
|
||||
# Stage 1: Build the React Application
|
||||
# Using standard node:20 (not slim/alpine) to ensure build tools like python/make/g++ are present
|
||||
FROM node:20 AS builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package.json (and lock file if it exists)
|
||||
COPY package*.json ./
|
||||
# Copy ONLY package.json.
|
||||
# We intentionally IGNORE package-lock.json to prevent architecture mismatches
|
||||
# (e.g., trying to install macOS binaries for esbuild on Linux).
|
||||
COPY package.json ./
|
||||
|
||||
# Install dependencies using legacy-peer-deps to avoid version conflicts
|
||||
RUN npm install --legacy-peer-deps
|
||||
# Install dependencies from scratch for the container's architecture
|
||||
RUN npm install
|
||||
|
||||
# Copy the rest of the application source code
|
||||
COPY . .
|
||||
@@ -17,16 +18,15 @@ COPY . .
|
||||
RUN npm run build
|
||||
|
||||
# Stage 2: Setup the Production Server
|
||||
# Using standard node:20 to ensure native modules (like pg/mysql drivers) install correctly
|
||||
FROM node:20
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package.json again for production dependencies
|
||||
COPY package*.json ./
|
||||
# Copy ONLY package.json
|
||||
COPY package.json ./
|
||||
|
||||
# Install ONLY production dependencies
|
||||
RUN npm install --omit=dev --legacy-peer-deps
|
||||
RUN npm install --omit=dev
|
||||
|
||||
# Copy the built frontend assets from the 'builder' stage
|
||||
COPY --from=builder /app/dist ./dist
|
||||
|
||||
Reference in New Issue
Block a user