45 lines
1.5 KiB
Docker
Raw Permalink Normal View History

2025-05-25 22:21:45 -04:00
# Dockerfile
2025-05-25 10:22:24 -04:00
# Stage 1: Build the React application
FROM node:18-alpine AS build
2025-05-25 22:21:45 -04:00
LABEL stage="build-local-testing"
2025-05-25 10:22:24 -04:00
WORKDIR /app
# Copy package.json and package-lock.json (or yarn.lock)
COPY package*.json ./
2025-05-25 22:21:45 -04:00
# Install dependencies using the lock file for consistency
RUN npm install
2025-05-25 10:22:24 -04:00
# Copy the rest of the application source code
COPY . .
2025-05-25 22:21:45 -04:00
# --- For Local Testing with .env.local ---
# Copy your .env.local file as .env in the build context.
# Create React App's build script will automatically load variables from this .env file.
# IMPORTANT: Ensure .env.local contains your actual Firebase API keys and other secrets.
# This .env.local file MUST be in your .gitignore and NOT committed to your repository.
# This Docker image, built this way, CONTAINS YOUR SECRETS and should NOT be pushed to a public registry.
COPY .env.local .env
# --- End Local Testing Section ---
# Build the application. react-scripts build will use environment variables
# prefixed with REACT_APP_ (either from the .env file copied above or from the build environment).
# Set NODE_OPTIONS to use the legacy OpenSSL provider for the build step.
RUN NODE_OPTIONS=--openssl-legacy-provider npm run build
# Stage 2: Serve the static files using Nginx
2025-05-25 10:22:24 -04:00
FROM nginx:1.25-alpine
2025-05-25 22:21:45 -04:00
LABEL stage="nginx-server"
2025-05-25 10:22:24 -04:00
# Copy the build output from the 'build' stage to Nginx's html directory
COPY --from=build /app/build /usr/share/nginx/html
2025-05-25 22:21:45 -04:00
# Expose port 80 (Nginx default)
2025-05-25 10:22:24 -04:00
EXPOSE 80
# Start Nginx when the container launches
2025-05-25 22:21:45 -04:00
CMD ["nginx", "-g", "daemon off;"]