Refactor Docker setup for Astro SSR application and Nginx reverse proxy
- Updated docker-compose.yml to define services for the Astro SSR application and Nginx reverse proxy, including health checks and environment variables. - Modified Dockerfile to implement a multi-stage build process, optimizing dependency installation and production setup. - Enhanced nginx.conf with improved proxy settings, security headers, and caching strategies for static assets, ensuring better performance and security.
This commit is contained in:
@@ -1,6 +1,60 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
astrowind:
|
||||
build: .
|
||||
container_name: astrowind
|
||||
# Main Astro SSR Application
|
||||
web:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
container_name: 365devnet-web
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- 8080:8080
|
||||
- "3000"
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- PORT=3000
|
||||
- ENABLE_SSR_CSP=1
|
||||
# Add your other environment variables here
|
||||
# - GEMINI_API_KEY=${GEMINI_API_KEY}
|
||||
# - EMAIL_USER=${EMAIL_USER}
|
||||
# - EMAIL_PASS=${EMAIL_PASS}
|
||||
env_file:
|
||||
- .env
|
||||
volumes:
|
||||
# Mount logs directory if you want to persist logs
|
||||
- ./logs:/app/logs
|
||||
networks:
|
||||
- devnet
|
||||
healthcheck:
|
||||
test: ["CMD", "node", "-e", "require('http').get('http://localhost:3000/', (r) => {if (r.statusCode !== 200) throw new Error(r.statusCode)})"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 40s
|
||||
|
||||
# Nginx Reverse Proxy (Optional - for SSL termination & caching)
|
||||
nginx:
|
||||
image: nginx:stable-alpine
|
||||
container_name: 365devnet-nginx
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "80:80"
|
||||
- "443:443"
|
||||
volumes:
|
||||
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
|
||||
# Add SSL certificates if you have them
|
||||
# - ./ssl/cert.pem:/etc/nginx/ssl/cert.pem:ro
|
||||
# - ./ssl/key.pem:/etc/nginx/ssl/key.pem:ro
|
||||
depends_on:
|
||||
web:
|
||||
condition: service_healthy
|
||||
networks:
|
||||
- devnet
|
||||
|
||||
networks:
|
||||
devnet:
|
||||
driver: bridge
|
||||
|
||||
# Optional: Add volumes for persistent data
|
||||
volumes:
|
||||
logs:
|
||||
|
||||
Reference in New Issue
Block a user