This commit is contained in:
Mackie 2026-06-08 07:58:15 +08:00
parent ada0be589f
commit 96a1168822
2 changed files with 22 additions and 11 deletions

View file

@ -11,5 +11,12 @@ FROM nginx:alpine
COPY --from=builder /app/dist /usr/share/nginx/html COPY --from=builder /app/dist /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf COPY nginx.conf /etc/nginx/conf.d/default.conf
# ... previous steps # ... previous steps
EXPOSE 3000 EXPOSE 80
# ... (your existing build steps)
# Add this line at the end of your Dockerfile
# This tells Docker (and Dokploy) how to check if your app is alive
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD curl -f http://localhost/ || exit 1
CMD ["nginx", "-g", "daemon off;"] CMD ["nginx", "-g", "daemon off;"]

View file

@ -1,21 +1,25 @@
server { server {
listen 80; listen 80;
root /usr/share/nginx/html;
# 1. Handle the path Traefik is routing index index.html;
location /lab/data-dashboard/ {
alias /usr/share/nginx/html/;
try_files $uri $uri/ /index.html;
}
# 2. Add an explicit health check endpoint (returns 200 OK) # Dedicated Health Check Endpoint
location /health { location /health {
return 200 'healthy'; return 200 'healthy';
add_header Content-Type text/plain; add_header Content-Type text/plain;
} }
# 3. Fallback for SPA routing # Your SPA routing (aliased to handle the sub-path)
location / { location /lab/data-dashboard/ {
root /usr/share/nginx/html; alias /usr/share/nginx/html/;
try_files $uri $uri/ /index.html; try_files $uri $uri/ /index.html;
} }
# Fallback for the root domain
location / {
try_files $uri $uri/ /index.html;
}
gzip on;
gzip_types text/css application/javascript application/json;
} }