Add nginx configuration file for serving built assets and handling routing

This commit is contained in:
2025-10-05 08:21:43 +08:00
parent 1ce25cf0f2
commit 9794615c80
2 changed files with 16 additions and 2 deletions

View File

@@ -22,8 +22,8 @@ FROM nginx:alpine
# Copy built assets from builder stage
COPY --from=builder /app/dist /usr/share/nginx/html
# Copy nginx configuration (optional - using default)
# COPY nginx.conf /etc/nginx/nginx.conf
# Copy nginx configuration
COPY nginx.conf /etc/nginx/conf.d/default.conf
# Expose port 80
EXPOSE 80

14
nginx.conf Normal file
View File

@@ -0,0 +1,14 @@
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html;
# Handle React Router - serve index.html for all routes
location / {
try_files $uri $uri/ /index.html;
}
# Error pages
error_page 404 /index.html;
}