Spaces:
Runtime error
Runtime error
File size: 828 Bytes
4089eed d1ebe28 4089eed 6801e8e 4089eed d1ebe28 4089eed d1ebe28 6801e8e d1ebe28 6801e8e 4089eed |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# Use an official Node.js runtime as a parent image
FROM node:16 as builder
# Set the working directory
WORKDIR /app
# Copy package.json and install dependencies
COPY package*.json ./
RUN npm install
# Copy the rest of the application code
COPY . .
# Build the React app
RUN npm run build
# Use an Nginx image to serve the built app
FROM nginx:alpine
# Set user to root temporarily to fix permissions
USER root
# Fix permissions for nginx cache and /run directory
RUN mkdir -p /var/cache/nginx /run && chmod -R 777 /var/cache/nginx /run
# Copy built React files
COPY --from=builder /app/build /usr/share/nginx/html
# (Optional) Fix Nginx listen port if needed
RUN sed -i 's/listen\s\+80;/listen 8080;/' /etc/nginx/conf.d/default.conf
# Expose correct port
EXPOSE 8080
# Start Nginx
CMD ["nginx", "-g", "daemon off;"]
|