Skip to content

Commit 5d8cb08

Browse files
committed
Update Deploy
1 parent 7ae7217 commit 5d8cb08

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

docker/angular-frontend.Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ COPY . .
1212
# Build production và cố định output-path để tránh lệ thuộc tên project
1313
RUN 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 ======
1619
FROM nginx:1.27-alpine
1720

@@ -22,7 +25,8 @@ COPY docker/nginx.conf /etc/nginx/conf.d/default.conf
2225
RUN 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

2731
EXPOSE 80
2832
HEALTHCHECK --interval=30s --timeout=3s --retries=3 CMD wget -qO- http://localhost/ || exit 1

docker/nginx.conf

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)