From 6b8e146c4ac47b324145ba51278ae6681e5f5649 Mon Sep 17 00:00:00 2001 From: Floke Date: Fri, 20 Mar 2026 13:52:33 +0000 Subject: [PATCH] fix(frontend): use multi-stage docker build to be self-contained [32788f42] --- fotograf-de-scraper/frontend/Dockerfile | 30 +++++++++++++++++++------ 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/fotograf-de-scraper/frontend/Dockerfile b/fotograf-de-scraper/frontend/Dockerfile index affb0d63..f57edf1a 100644 --- a/fotograf-de-scraper/frontend/Dockerfile +++ b/fotograf-de-scraper/frontend/Dockerfile @@ -1,18 +1,34 @@ -# Use a lightweight Nginx image to serve the React app +# Stage 1: Build the React application +FROM node:18-alpine AS builder + +WORKDIR /app + +# Copy package.json and package-lock.json +COPY package*.json ./ + +# Install dependencies +RUN npm install + +# Copy the rest of the application source code +COPY . . + +# Build the application +RUN npm run build + +# Stage 2: Serve the application with Nginx FROM nginx:alpine -# Set working directory to nginx's default static file directory +# Set working directory WORKDIR /usr/share/nginx/html -# Remove default Nginx static assets +# Remove default Nginx assets RUN rm -rf ./* -# Copy the built React app from the builder stage -# The React app is built using `npm run build` which creates a `dist` directory -COPY ./dist . +# Copy built assets from the builder stage +COPY --from=builder /app/dist . # Expose port 80 EXPOSE 80 -# Command to start Nginx (default command of the base image) +# Start Nginx CMD ["nginx", "-g", "daemon off;"]