mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-25 14:25:02 +00:00
Created comprehensive production and development deployment configurations in `/deployment` folder: **Production Stack (docker-compose.production.yml):** - PostgreSQL 16 with persistent storage - C++ DBAL Daemon (optimized, daemon mode) - MetaBuilder App (production build) - Nginx reverse proxy with SSL/TLS - Redis cache layer - Health checks and auto-restart - Resource limits configured - Isolated network (172.20.0.0/16) **Development Stack (docker-compose.development.yml):** - PostgreSQL 16 (port 5433) - C++ DBAL Daemon (debug mode, interactive) - MetaBuilder App (hot-reload with Vite) - Redis cache (port 6380) - Mailhog (email testing, port 8025) - Adminer (DB UI, port 8082) - Redis Commander (Redis UI, port 8083) - Full source mounting for live changes - Isolated network (172.21.0.0/16) **Supporting Files:** - Dockerfile.app - Production app build (multi-stage) - Dockerfile.app.dev - Development with hot-reload - init-db.sh - PostgreSQL initialization script - production.conf - Nginx config with SSL - config.yaml - DBAL daemon configuration - .env.production.example - Production environment template - .env.development.example - Development environment template - README.md - Complete deployment guide - start.sh - Quick start interactive script - .gitignore - Protect secrets and generated files **Fire-and-Forget Features:** - Single command startup: `./deployment/start.sh` - Auto environment detection - SSL certificate generation - Health checks for all services - Automatic retries and restarts - Volume persistence - Complete documentation **Usage:** ```bash # Quick start (interactive) cd deployment && ./start.sh # Or directly docker-compose -f deployment/docker-compose.production.yml up -d docker-compose -f deployment/docker-compose.development.yml up ``` **Services Access:** Production: - App: https://localhost - API: https://localhost/api/dbal/ Development: - App: http://localhost:5173 - API: http://localhost:8081 - DB UI: http://localhost:8082 - Redis UI: http://localhost:8083 - Email: http://localhost:8025 Complete, tested, and production-ready deployment. Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
134 lines
4.0 KiB
Plaintext
134 lines
4.0 KiB
Plaintext
# Production Nginx Configuration for MetaBuilder
|
|
user nginx;
|
|
worker_processes auto;
|
|
error_log /var/log/nginx/error.log warn;
|
|
pid /var/run/nginx.pid;
|
|
|
|
events {
|
|
worker_connections 2048;
|
|
use epoll;
|
|
multi_accept on;
|
|
}
|
|
|
|
http {
|
|
include /etc/nginx/mime.types;
|
|
default_type application/octet-stream;
|
|
|
|
# Logging
|
|
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
|
'$status $body_bytes_sent "$http_referer" '
|
|
'"$http_user_agent" "$http_x_forwarded_for"';
|
|
|
|
access_log /var/log/nginx/access.log main;
|
|
|
|
# Performance
|
|
sendfile on;
|
|
tcp_nopush on;
|
|
tcp_nodelay on;
|
|
keepalive_timeout 65;
|
|
types_hash_max_size 2048;
|
|
client_max_body_size 100M;
|
|
|
|
# Gzip
|
|
gzip on;
|
|
gzip_vary on;
|
|
gzip_proxied any;
|
|
gzip_comp_level 6;
|
|
gzip_types text/plain text/css text/xml text/javascript
|
|
application/json application/javascript application/xml+rss
|
|
application/rss+xml font/truetype font/opentype
|
|
application/vnd.ms-fontobject image/svg+xml;
|
|
|
|
# Upstream servers
|
|
upstream metabuilder_app {
|
|
least_conn;
|
|
server metabuilder-app:3000 max_fails=3 fail_timeout=30s;
|
|
keepalive 32;
|
|
}
|
|
|
|
upstream dbal_daemon {
|
|
least_conn;
|
|
server dbal-daemon:8080 max_fails=3 fail_timeout=30s;
|
|
keepalive 32;
|
|
}
|
|
|
|
# HTTP Server - Redirect to HTTPS
|
|
server {
|
|
listen 80;
|
|
server_name _;
|
|
|
|
# Health check endpoint (no redirect)
|
|
location /health {
|
|
access_log off;
|
|
return 200 "healthy\n";
|
|
add_header Content-Type text/plain;
|
|
}
|
|
|
|
# Redirect all other traffic to HTTPS
|
|
location / {
|
|
return 301 https://$host$request_uri;
|
|
}
|
|
}
|
|
|
|
# HTTPS Server
|
|
server {
|
|
listen 443 ssl http2;
|
|
server_name _;
|
|
|
|
# SSL Configuration
|
|
ssl_certificate /etc/nginx/ssl/cert.pem;
|
|
ssl_certificate_key /etc/nginx/ssl/key.pem;
|
|
ssl_protocols TLSv1.2 TLSv1.3;
|
|
ssl_ciphers HIGH:!aNULL:!MD5;
|
|
ssl_prefer_server_ciphers on;
|
|
ssl_session_cache shared:SSL:10m;
|
|
ssl_session_timeout 10m;
|
|
|
|
# Security Headers
|
|
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
|
add_header X-Frame-Options "SAMEORIGIN" always;
|
|
add_header X-Content-Type-Options "nosniff" always;
|
|
add_header X-XSS-Protection "1; mode=block" always;
|
|
add_header Referrer-Policy "no-referrer-when-downgrade" always;
|
|
|
|
# DBAL API
|
|
location /api/dbal/ {
|
|
proxy_pass http://dbal_daemon/;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
proxy_set_header Connection "";
|
|
proxy_connect_timeout 30s;
|
|
proxy_send_timeout 30s;
|
|
proxy_read_timeout 30s;
|
|
}
|
|
|
|
# MetaBuilder App
|
|
location / {
|
|
proxy_pass http://metabuilder_app;
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection 'upgrade';
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
proxy_cache_bypass $http_upgrade;
|
|
proxy_connect_timeout 60s;
|
|
proxy_send_timeout 60s;
|
|
proxy_read_timeout 60s;
|
|
}
|
|
|
|
# Static assets caching
|
|
location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg|woff|woff2|ttf|eot)$ {
|
|
proxy_pass http://metabuilder_app;
|
|
proxy_cache_valid 200 1d;
|
|
proxy_cache_bypass $http_pragma $http_authorization;
|
|
add_header Cache-Control "public, immutable";
|
|
expires 1y;
|
|
}
|
|
}
|
|
}
|