From 69717ea407ea055679b3ff62607fdfec7241527f Mon Sep 17 00:00:00 2001 From: lafay <2021211506@stu.hit.edu.cn> Date: Sat, 4 Apr 2026 00:15:51 +0800 Subject: [PATCH] build(deploy): add nginx configuration for web application serving Add nginx.conf to serve the Expo web build and update Dockerfile.web to copy the configuration into the nginx container. This enables proper static file serving with appropriate MIME types and default caching headers for the production web deployment. --- Dockerfile.web | 1 + nginx.conf | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 nginx.conf diff --git a/Dockerfile.web b/Dockerfile.web index 51984ef..3b43c71 100644 --- a/Dockerfile.web +++ b/Dockerfile.web @@ -10,6 +10,7 @@ RUN npx expo export --platform web --output-dir dist-web FROM nginx:1.27-alpine +COPY nginx.conf /etc/nginx/conf.d/default.conf COPY --from=builder /app/dist-web /usr/share/nginx/html EXPOSE 80 diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..3f98ed2 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,19 @@ +server { + listen 80; + server_name _; + root /usr/share/nginx/html; + index index.html; + + location / { + try_files $uri $uri/ /index.html; + } + + location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { + expires 1y; + add_header Cache-Control "public, immutable"; + } + + gzip on; + gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml; + gzip_min_length 256; +}