File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,9 @@ COPY . .
1212# Build production và cố định output-path để tránh lệ thuộc tên project
1313RUN npm run build -- --configuration=production
1414
15+ # Sanity check: bắt buộc có index.html
16+ RUN test -f dist/codecampus/browser/index.html
17+
1518# ====== Runtime stage ======
1619FROM nginx:1.27-alpine
1720
@@ -22,7 +25,8 @@ COPY docker/nginx.conf /etc/nginx/conf.d/default.conf
2225RUN rm -rf /usr/share/nginx/html/*
2326
2427# copy artefact Angular
25- COPY --from=build /app/dist/codecampus/ /usr/share/nginx/html/
28+ COPY --from=build /app/dist/codecampus/browser/ /usr/share/nginx/html/
29+
2630
2731EXPOSE 80
2832HEALTHCHECK --interval=30s --timeout=3s --retries=3 CMD wget -qO- http://localhost/ || exit 1
Original file line number Diff line number Diff line change @@ -14,14 +14,24 @@ server {
1414 proxy_set_header Connection "" ;
1515 }
1616
17- # Cache tĩnh nhẹ nhàng
18- location ~ * \.(?:js|css|png|jpg|jpeg|gif|svg|ico|woff2?)$ {
17+ # Cache
18+ location ~ * \.(?:js|css|png|jpg|jpeg|gif|svg|ico|woff2?|ttf|map )$ {
1919 try_files $uri =404 ;
20+ access_log off;
2021 add_header Cache-Control "public, max-age=31536000, immutable" ;
2122 }
2223
2324 # SPA fallback
2425 location / {
25- try_files $uri $uri / / index .html ;
26+ try_files $uri $uri / @spa ;
2627 }
28+
29+ location @spa {
30+ # đẩy mọi route về index.html 1 lần, tránh lặp
31+ add_header Cache-Control "no-store" ;
32+ rewrite ^ /index .html last;
33+ }
34+
35+ # (tuỳ chọn) chặn listing thư mục
36+ autoindex off;
2737}
You can’t perform that action at this time.
0 commit comments