hello world
This commit is contained in:
29
Dockerfile
29
Dockerfile
@@ -1,11 +1,7 @@
|
||||
# =========================================
|
||||
# Stage 1: Build the Angular Application
|
||||
# =========================================
|
||||
# =========================================
|
||||
# Stage 1: Build the Angular Application
|
||||
# =========================================
|
||||
ARG NODE_VERSION=24.7.0-alpine
|
||||
ARG NGINX_VERSION=alpine3.22
|
||||
|
||||
# Use a lightweight Node.js image for building (customizable via ARG)
|
||||
FROM node:${NODE_VERSION} AS builder
|
||||
@@ -26,24 +22,23 @@ COPY . .
|
||||
RUN npm run build
|
||||
|
||||
# =========================================
|
||||
# Stage 2: Prepare Nginx to Serve Static Files
|
||||
# Stage 2: Run SSR Server
|
||||
# =========================================
|
||||
|
||||
FROM nginxinc/nginx-unprivileged:${NGINX_VERSION} AS runner
|
||||
FROM node:${NODE_VERSION} AS runner
|
||||
|
||||
# Use a built-in non-root user for security best practices
|
||||
USER nginx
|
||||
|
||||
# Copy custom Nginx config
|
||||
COPY nginx.conf /etc/nginx/nginx.conf
|
||||
WORKDIR /app
|
||||
|
||||
# Copy the static build output from the build stage to Nginx's default HTML serving directory
|
||||
COPY --chown=nginx:nginx --from=builder /app/dist/*/browser /usr/share/nginx/html
|
||||
ENV NODE_ENV=production
|
||||
|
||||
# Expose port 8080 to allow HTTP traffic
|
||||
# Note: The default NGINX container now listens on port 8080 instead of 80
|
||||
EXPOSE 8080
|
||||
# Copy only necessary build output
|
||||
COPY --from=builder /app/dist ./dist
|
||||
COPY --from=builder /app/package.json ./package.json
|
||||
COPY --from=builder /app/node_modules ./node_modules
|
||||
|
||||
# Angular SSR default port
|
||||
EXPOSE 4000
|
||||
|
||||
# Start Nginx directly with custom config
|
||||
ENTRYPOINT ["nginx", "-c", "/etc/nginx/nginx.conf"]
|
||||
CMD ["-g", "daemon off;"]
|
||||
CMD ["node", "dist/*/server/server.mjs"]
|
||||
|
||||
Reference in New Issue
Block a user