build(deploy): add nginx configuration for web application serving
All checks were successful
Frontend CI / build-and-push-web (push) Successful in 4m28s
Frontend CI / ota-android (push) Successful in 11m33s
Frontend CI / build-android-apk (push) Successful in 1h3m22s

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.
This commit is contained in:
lafay
2026-04-04 00:15:51 +08:00
parent 775deeb9c4
commit 69717ea407
2 changed files with 20 additions and 0 deletions

View File

@@ -10,6 +10,7 @@ RUN npx expo export --platform web --output-dir dist-web
FROM nginx:1.27-alpine FROM nginx:1.27-alpine
COPY nginx.conf /etc/nginx/conf.d/default.conf
COPY --from=builder /app/dist-web /usr/share/nginx/html COPY --from=builder /app/dist-web /usr/share/nginx/html
EXPOSE 80 EXPOSE 80

19
nginx.conf Normal file
View File

@@ -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;
}