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;"]