-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdockerfile
More file actions
49 lines (35 loc) · 960 Bytes
/
dockerfile
File metadata and controls
49 lines (35 loc) · 960 Bytes
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
38
39
40
41
42
43
44
45
46
47
48
49
# -----------------------------
# 1. Build Stage
# -----------------------------
FROM node:20-alpine AS builder
WORKDIR /app
# Copy package.json and lockfile
COPY package*.json ./
# Install dependencies
RUN npm ci --silent
# Copy all source files
COPY . .
# Build production assets
ARG NODE_ENV=production
ENV NODE_ENV=${NODE_ENV}
RUN npm run build
# -----------------------------
# 2. Production Stage
# -----------------------------
FROM nginx:alpine AS production
WORKDIR /usr/share/nginx/html
# Remove default Nginx files
RUN rm -rf ./*
# Copy built frontend from builder
COPY --from=builder /app/dist ./
# Copy custom nginx config
COPY nginx/nginx.conf /etc/nginx/conf.d/default.conf
# Fix permissions for non-root Nginx
RUN mkdir -p /var/cache/nginx /var/run/nginx \
&& chown -R nginx:nginx /var/cache/nginx /var/run/nginx
# Expose container port
EXPOSE 80
# Use non-root user
USER nginx
# Start Nginx
CMD ["nginx", "-g", "daemon off;"]