Files
docker-workshop/react-project/Dockerfile

31 lines
582 B
Docker
Raw Normal View History

2025-03-18 10:42:10 +01:00
# Build-Stage
FROM node:16 AS build
WORKDIR /app
# Abhängigkeiten zuerst kopieren und installieren (für besseres Caching)
COPY package*.json ./
RUN npm install
# Den Rest der Anwendung kopieren
COPY . .
# Build-Zeit-Variable setzen
RUN echo "REACT_APP_BUILD_TIME=$(date)" > .env
# Anwendung bauen
RUN npm run build
# Production-Stage
FROM nginx:alpine
# Build-Output vom build-Stage kopieren
COPY --from=build /app/build /usr/share/nginx/html
# Nginx-Konfiguration (optional)
# COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]