BaotonDaiduong / Dockerfile
gaialive's picture
Update Dockerfile
b5d093d verified
# Stage 1: Build the React application
FROM node:18-alpine AS build
WORKDIR /app
COPY package*.json ./
# Use --legacy-peer-deps to avoid peer dependency conflicts during build
RUN npm install --legacy-peer-deps
COPY . .
RUN npm run build
# Stage 2: Serve the static files with Nginx
FROM nginx:stable-alpine
# Copy the built static files from the build stage
COPY --from=build /app/build /usr/share/nginx/html
# Overwrite the default nginx.conf with our custom, self-contained version
# that is designed for restricted, low-permission environments.
COPY nginx.conf /etc/nginx/nginx.conf
# Expose port 8080 for the web server
EXPOSE 8080
# Override the default entrypoint to bypass the base image's setup script,
# which causes permission errors in restricted environments.
ENTRYPOINT ["nginx"]
# Start Nginx in the foreground. All configuration is now in our custom nginx.conf.
CMD ["-g", "daemon off;"]