Update Dockerfile

This commit is contained in:
fcarraUniSa
2025-12-19 08:53:38 +01:00
committed by GitHub
parent f85bf8df59
commit 64e696d0a6

View File

@@ -1,46 +1,12 @@
# Stage 1: Build the React Application FROM node:18-alpine
FROM node:20-bookworm AS builder
WORKDIR /app WORKDIR /app
# Copy ONLY package.json COPY package*.json ./
COPY package.json ./ RUN npm ci --only=production
# Install dependencies
# --legacy-peer-deps: Ignores peer dependency conflicts
# --no-audit: Skips vulnerability audit (faster, less noise)
# --no-fund: Hides funding messages
RUN npm install --legacy-peer-deps --no-audit --no-fund
# Copy the rest of the application source code
COPY . . COPY . .
# Build the frontend assets
RUN npm run build
# Stage 2: Setup the Production Server
FROM node:20-bookworm-slim
WORKDIR /app
# Copy ONLY package.json
COPY package.json ./
# Install ONLY production dependencies
RUN npm install --omit=dev --legacy-peer-deps --no-audit --no-fund
# Copy the built frontend assets from the 'builder' stage
COPY --from=builder /app/dist ./dist
# Copy the server entry point
COPY server.js ./
# Set environment variables
ENV NODE_ENV=production
ENV PORT=3000
# Expose the port
EXPOSE 3000 EXPOSE 3000
# Start the Node.js server CMD ["node", "server.js"]
CMD ["npm", "start"]