Add project files
This commit is contained in:
30
react-project/Dockerfile
Normal file
30
react-project/Dockerfile
Normal file
@@ -0,0 +1,30 @@
|
||||
# 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;"]
|
||||
Reference in New Issue
Block a user