2024-12-28 16:30:48 +01:00
|
|
|
# =========== 1) Build stage ===========
|
2025-12-26 08:45:47 +01:00
|
|
|
FROM node:22-alpine AS build
|
2024-12-28 16:30:48 +01:00
|
|
|
|
2026-02-27 11:55:30 +01:00
|
|
|
# No build args needed - using runtime configuration instead
|
2024-12-28 16:30:48 +01:00
|
|
|
WORKDIR /usr/src/app
|
|
|
|
|
|
2025-12-26 08:45:47 +01:00
|
|
|
# Copy package files
|
2024-12-28 16:30:48 +01:00
|
|
|
COPY package*.json ./
|
2026-01-24 18:53:46 +01:00
|
|
|
|
2025-12-26 08:45:47 +01:00
|
|
|
# Install dependencies
|
2024-12-28 16:30:48 +01:00
|
|
|
RUN npm install
|
|
|
|
|
|
|
|
|
|
# Copy the rest of the frontend code
|
|
|
|
|
COPY . .
|
|
|
|
|
|
2026-02-27 11:55:30 +01:00
|
|
|
# Build the production bundle WITHOUT baked-in API URL
|
|
|
|
|
# Runtime configuration will be generated from environment variables
|
2024-12-28 16:30:48 +01:00
|
|
|
RUN npm run build
|
|
|
|
|
|
|
|
|
|
# =========== 2) Serve stage ===========
|
|
|
|
|
FROM nginx:alpine
|
|
|
|
|
|
2026-02-27 11:55:30 +01:00
|
|
|
# Copy production build to Nginx html folder
|
2025-12-26 08:45:47 +01:00
|
|
|
COPY --from=build /usr/src/app/dist /usr/share/nginx/html
|
2026-02-27 11:55:30 +01:00
|
|
|
|
2026-01-24 15:46:09 +01:00
|
|
|
# Copy custom nginx configuration for SPA routing
|
2026-01-24 18:49:06 +01:00
|
|
|
COPY --from=build /usr/src/app/nginx.conf /etc/nginx/conf.d/default.conf
|
2026-02-27 11:55:30 +01:00
|
|
|
|
|
|
|
|
# Copy entrypoint script that generates runtime config
|
|
|
|
|
COPY --from=build /usr/src/app/docker-entrypoint.sh /docker-entrypoint.sh
|
|
|
|
|
RUN chmod +x /docker-entrypoint.sh
|
|
|
|
|
|
2024-12-28 16:30:48 +01:00
|
|
|
# Expose HTTP port
|
|
|
|
|
EXPOSE 80
|
|
|
|
|
|
2026-02-27 11:55:30 +01:00
|
|
|
# Use custom entrypoint that generates config.json from environment
|
|
|
|
|
ENTRYPOINT ["/docker-entrypoint.sh"]
|