Simplify Dockerfile and remove custom nginx config
All checks were successful
Build and Deploy / build (push) Successful in 30s

This commit is contained in:
d.viti
2025-10-13 23:33:58 +02:00
parent 23ec5d5f32
commit f300f2b041

View File

@@ -1,70 +1,14 @@
# Multi-stage build for optimized nginx image # SempliceSemplice build concon nginx alpinealpine
FROM nginx:alpine FROM nginx:alpine
# Remove default nginx static assets # CopiaCopia ii filefile HTMLHTML
RUN rm -rf /usr/share/nginx/html/*
# Copy static files
COPY index.html /usr/share/nginx/html/ COPY index.html /usr/share/nginx/html/
COPY project-mode.html /usr/share/nginx/html/ COPY project-mode.html /usr/share/nginx/html/
COPY shop-mode.html /usr/share/nginx/html/ COPY shop-mode.html /usr/share/nginx/html/
# Create a custom nginx configuration for better caching and security # Espone porta 80
RUN cat > /etc/nginx/conf.d/default.conf <<'EOF' # Espone porta 80
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
# Security headers
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
# Gzip compression
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_types text/plain text/css text/xml text/javascript application/json application/javascript application/xml+rss application/rss+xml font/truetype font/opentype application/vnd.ms-fontobject image/svg+xml;
# Cache static assets
location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg|woff|woff2|ttf|eot)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
# Main location
location / {
try_files $uri $uri/ /index.html;
}
# Health check endpoint
location /health {
access_log off;
return 200 "healthy\n";
add_header Content-Type text/plain;
}
}
EOF
# Run nginx as non-root user
RUN chown -R nginx:nginx /usr/share/nginx/html && \
chown -R nginx:nginx /var/cache/nginx && \
chown -R nginx:nginx /var/log/nginx && \
touch /var/run/nginx.pid && \
chown -R nginx:nginx /var/run/nginx.pid
USER nginx
# Expose port 80
EXPOSE 80 EXPOSE 80
# Health check # Avvia nginx
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD wget --quiet --tries=1 --spider http://localhost/health || exit 1
# Start nginx
CMD ["nginx", "-g", "daemon off;"] CMD ["nginx", "-g", "daemon off;"]