Bfjandak commited on
Commit
1724815
·
verified ·
1 Parent(s): 647a0b6

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +54 -0
Dockerfile ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # =========================================================
2
+ # STAGE 1: Hermetic Node Compiler and Code Bundler
3
+ # =========================================================
4
+ FROM node:20-alpine AS build-engine
5
+
6
+ WORKDIR /app
7
+
8
+ # Requires package-lock.json to exist via running npm install first locally
9
+ COPY package*.json ./
10
+ RUN npm ci
11
+
12
+ # Mount compiler processing environments
13
+ COPY tailwind.config.js postcss.config.js vite.config.js ./
14
+ COPY index.html ./
15
+
16
+ # Mount asset and source directories
17
+ COPY public/ ./public/
18
+ COPY src/ ./src/
19
+
20
+ # Compile production build distributions into /app/dist
21
+ ENV NODE_ENV=production
22
+ RUN npm run build
23
+
24
+ # =========================================================
25
+ # STAGE 2: Hardened, Unprivileged Static Edge Server
26
+ # =========================================================
27
+ FROM nginx:alpine-slim
28
+
29
+ # Enforce system-level wget availability to guarantee health checks survive baseline upgrades
30
+ RUN apk add --no-cache wget \
31
+ && rm -rf /usr/share/nginx/html/* \
32
+ && rm -f /etc/nginx/conf.d/default.conf /etc/nginx/nginx.conf
33
+
34
+ # Inject security configurations into global runtime path
35
+ COPY nginx.conf /etc/nginx/nginx.conf
36
+
37
+ # Extract tree-shaken static assets directly out of Stage 1 dist/
38
+ COPY --from=build-engine /app/dist /usr/share/nginx/html
39
+
40
+ # Create and register custom temp structures under explicit non-root contexts
41
+ RUN mkdir -p /tmp/client_temp /tmp/proxy_temp /tmp/fastcgi_temp /tmp/uwsgi_temp /tmp/scgi_temp \
42
+ && chown -R nginx:nginx /usr/share/nginx/html /var/cache/nginx /var/log/nginx \
43
+ /tmp/client_temp /tmp/proxy_temp /tmp/fastcgi_temp /tmp/uwsgi_temp /tmp/scgi_temp
44
+
45
+ # Drop all execution privileges cleanly to non-root
46
+ USER nginx
47
+
48
+ EXPOSE 8080
49
+
50
+ # Hardened Runtime Health Check evaluating index.html availability securely
51
+ HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
52
+ CMD wget -qO- http://localhost:8080/index.html >/dev/null || exit 1
53
+
54
+ CMD ["nginx", "-g", "daemon off;"]