Update Dockerfile
This commit is contained in:
18
Dockerfile
18
Dockerfile
@@ -1,14 +1,15 @@
|
|||||||
# Stage 1: Build the React Application
|
# 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
|
FROM node:20 AS builder
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy package.json (and lock file if it exists)
|
# Copy ONLY package.json.
|
||||||
COPY 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
|
# Install dependencies from scratch for the container's architecture
|
||||||
RUN npm install --legacy-peer-deps
|
RUN npm install
|
||||||
|
|
||||||
# Copy the rest of the application source code
|
# Copy the rest of the application source code
|
||||||
COPY . .
|
COPY . .
|
||||||
@@ -17,16 +18,15 @@ COPY . .
|
|||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
# Stage 2: Setup the Production Server
|
# Stage 2: Setup the Production Server
|
||||||
# Using standard node:20 to ensure native modules (like pg/mysql drivers) install correctly
|
|
||||||
FROM node:20
|
FROM node:20
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Copy package.json again for production dependencies
|
# Copy ONLY package.json
|
||||||
COPY package*.json ./
|
COPY package.json ./
|
||||||
|
|
||||||
# Install ONLY production dependencies
|
# 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 the built frontend assets from the 'builder' stage
|
||||||
COPY --from=builder /app/dist ./dist
|
COPY --from=builder /app/dist ./dist
|
||||||
|
|||||||
Reference in New Issue
Block a user