Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 18 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
# Use an official Node.js image as the base (LTS version for stability)
# ---- Build Stage ----
FROM node:18-alpine AS builder

# Set the working directory inside the container
# Set working directory
WORKDIR /app

# Copy package.json and package-lock.json first (Leverage Docker cache)
# Copy package files
COPY package*.json ./

# Install dependencies in a clean environment
RUN npm ci --only=production
# Install all dependencies (including dev for build)
RUN npm install --legacy-peer-deps

# Copy the rest of the application source code
# Copy source code
COPY . .

# Build the React app
# Fix CRA eslint and OpenSSL issues
ENV SKIP_PREFLIGHT_CHECK=true
ENV NODE_OPTIONS=--openssl-legacy-provider

# Build React app
RUN npm run build

# ---- Production Stage ----
FROM node:18-alpine

# Set the working directory
WORKDIR /app
FROM nginx:alpine

# Copy the built React app from the builder stage
COPY --from=builder /app .
# Copy build output to nginx html folder
COPY --from=builder /app/build /usr/share/nginx/html

# Expose the port the app runs on
EXPOSE 3000
# Expose HTTP port
EXPOSE 80

# Start the application
CMD ["npm", "start"]
# Run nginx
CMD ["nginx", "-g", "daemon off;"]
Loading