File tree Expand file tree Collapse file tree
components/centraldashboard Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,16 +16,13 @@ RUN npm ci \
1616 && npm run build \
1717 && npm prune --production
1818
19- # Step 2: Packages assets for serving
20- FROM node:16.20.2-alpine AS serve
2119
22- RUN apk add --no-cache tini
20+ # Step 2: Serve static assets with nginx (smaller, secure)
21+ FROM nginx:1.25-alpine AS serve
2322
24- USER node
25-
26- ENV NODE_ENV=production
27- WORKDIR /usr/src/app
28- COPY --from=build --chown=node:node /centraldashboard .
23+ # Copy built static assets from build stage
24+ COPY --from=build --chown=nginx:nginx /centraldashboard/public /usr/share/nginx/html
25+ COPY --from=build --chown=nginx:nginx /centraldashboard/app.bundle.js /centraldashboard/app.css /usr/share/nginx/html/
2926
3027EXPOSE 8082
31- ENTRYPOINT [ "/sbin/tini" , "--" , "npm" , "start" ]
28+
Original file line number Diff line number Diff line change 1+ server {
2+ listen 8082 ;
3+ server_name _;
4+ root /usr/share/nginx/html;
5+ index index .html;
6+
7+ # Static assets caching
8+ location ~ \.(js|css|png|ico)$ {
9+ expires 1y ;
10+ add_header Cache-Control "public, immutable" ;
11+ }
12+
13+ # API proxy (keep if backend needed)
14+ location /apis/ {
15+ proxy_pass http ://backend:8082 /; # Or remove if not needed
16+ proxy_set_header Host $host ;
17+ }
18+
19+ # SPA routing (catch all)
20+ location / {
21+ try_files $uri $uri / /index .html;
22+ }
23+ }
You can’t perform that action at this time.
0 commit comments