Both Dockerfiles (root firebase-mode + docker/ caddy) bumped node:18-alpine to node:22-alpine. better-sqlite3 v12 (from PR #6) requires node 20+; node 18 builds fail with node-gyp/python errors. openssl-legacy-provider flag kept for react-scripts 5 compat. .dockerignore: removed .env* exclusion so .env.local COPY works in firebase image build. mock firestore applyConstraints comment: offset handled by adapter (firebase.js slices), mock never sees it — clarified dead-code reasoning.
52 lines
1.8 KiB
Docker
52 lines
1.8 KiB
Docker
# Dockerfile
|
|
|
|
# Stage 1: Build the React application
|
|
FROM node:22-alpine AS build
|
|
|
|
LABEL stage="build-local-testing"
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy root package.json/lockfile plus workspace manifests so npm can
|
|
# resolve the @ttrpg/shared and server workspace links during install.
|
|
COPY package*.json ./
|
|
COPY shared/package.json ./shared/
|
|
COPY server/package.json ./server/
|
|
|
|
# Install dependencies using the lock file for consistency
|
|
RUN npm install
|
|
|
|
# Copy the rest of the application source code
|
|
COPY . .
|
|
|
|
# --- 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
|
|
FROM nginx:1.25-alpine
|
|
|
|
LABEL stage="nginx-server"
|
|
|
|
# Copy the build output from the 'build' stage to Nginx's html directory
|
|
COPY --from=build /app/build /usr/share/nginx/html
|
|
|
|
# Replace default nginx config with one that handles SPA client-side routing
|
|
COPY nginx-docker.conf /etc/nginx/conf.d/default.conf
|
|
|
|
# Expose port 80 (Nginx default)
|
|
EXPOSE 80
|
|
|
|
# Start Nginx when the container launches
|
|
CMD ["nginx", "-g", "daemon off;"]
|