diff --git a/mnemo_cards_web_v2/Dockerfile b/mnemo_cards_web_v2/Dockerfile index 98517e8..34fa41b 100644 --- a/mnemo_cards_web_v2/Dockerfile +++ b/mnemo_cards_web_v2/Dockerfile @@ -31,14 +31,14 @@ RUN flutter build web --release \ --dart-define=API_BASE_URL=${API_BASE_URL} # --- Runtime stage ---------------------------------------------------------- -# FROM nginx:1.27-alpine AS runtime +FROM nginx:1.27-alpine AS runtime # Copy nginx config -# COPY mnemo_cards_web_v2/nginx.conf /etc/nginx/conf.d/default.conf +COPY mnemo_cards_web_v2/nginx.conf /etc/nginx/conf.d/default.conf # Copy built web app -# COPY --from=build /app/mnemo_cards_web_v2/build/web/ /usr/share/nginx/html/ +COPY --from=build /app/mnemo_cards_web_v2/build/web/ /usr/share/nginx/html/ EXPOSE 80 # HEALTHCHECK --interval=30s --timeout=5s --retries=3 \ -# CMD wget -qO- http://127.0.0.1/ >/dev/null 2>&1 || exit 1 + CMD wget -qO- http://127.0.0.1/ >/dev/null 2>&1 || exit 1 diff --git a/mnemo_cards_web_v2/nginx.conf b/mnemo_cards_web_v2/nginx.conf new file mode 100644 index 0000000..b27a2c5 --- /dev/null +++ b/mnemo_cards_web_v2/nginx.conf @@ -0,0 +1,29 @@ +server { + listen 80; + server_name _; + root /usr/share/nginx/html; + index index.html; + + # Gzip compression + gzip on; + gzip_types text/plain text/css application/json application/javascript text/xml application/xml text/javascript; + gzip_min_length 1000; + + # Cache static assets + location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { + expires 1y; + add_header Cache-Control "public, immutable"; + } + + # Flutter web app - SPA routing + location / { + try_files $uri $uri/ /index.html; + } + + # Health check endpoint + location /health { + access_log off; + return 200 "OK"; + add_header Content-Type text/plain; + } +}