mirror of
https://github.com/BeamMP/BeamMP-Website.git
synced 2026-05-19 08:00:30 +00:00
9066e31c55
Switch the runtime stage to nginx:stable (replacing alpine), remove the default static assets, and copy the built app into /usr/share/nginx/html. Add a custom nginx main config (nginx.main.conf → /etc/nginx/nginx.conf) and keep the default site config. Run the container as the non-root nginx user and expose port 80. These changes ensure the image serves the intended build, uses a stable nginx variant, and improves container security.
31 lines
586 B
Docker
31 lines
586 B
Docker
# Step 1: Build stage
|
|
FROM node:lts-alpine AS build
|
|
|
|
WORKDIR /app
|
|
COPY package*.json ./
|
|
RUN npm ci
|
|
COPY . .
|
|
ENV NODE_ENV=production
|
|
RUN npm run build
|
|
|
|
# Step 2: Serve stage
|
|
FROM nginx:stable
|
|
|
|
# Remove default nginx static assets
|
|
RUN rm -rf /usr/share/nginx/html/*
|
|
|
|
# Copy built files from the previous stage
|
|
COPY --from=build /app/dist /usr/share/nginx/html
|
|
|
|
# Copy secure nginx configs
|
|
COPY nginx.main.conf /etc/nginx/nginx.conf
|
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
|
|
|
# Use non-root user for security
|
|
USER nginx
|
|
|
|
# Expose port 80
|
|
EXPOSE 80
|
|
|
|
CMD ["nginx", "-g", "daemon off;"]
|