-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.optimized.yml
More file actions
134 lines (121 loc) · 3.71 KB
/
docker-compose.optimized.yml
File metadata and controls
134 lines (121 loc) · 3.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# Optimized Docker Compose for RustForms
# Lightweight, performant, and community-friendly self-hosting setup
version: '3.8'
services:
# PostgreSQL Database Service
postgres:
image: postgres:16-alpine
container_name: rustforms-db
restart: unless-stopped
environment:
POSTGRES_USER: ${POSTGRES_USER:-rustforms}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-rustforms_password}
POSTGRES_DB: ${POSTGRES_DB:-rustforms_db}
# Performance optimizations
POSTGRES_INITDB_ARGS: "--auth-host=scram-sha-256"
volumes:
- rustforms_postgres_data:/var/lib/postgresql/data
# Optional: Add custom postgres config for better performance
- ./docker/postgres.conf:/etc/postgresql/postgresql.conf:ro
ports:
- "${POSTGRES_PORT:-5432}:5432"
networks:
- rustforms-network
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-rustforms} -d ${POSTGRES_DB:-rustforms_db}"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
# Rust API Service
api:
build:
context: .
dockerfile: apps/api/Dockerfile.optimized
target: runtime
container_name: rustforms-api
restart: unless-stopped
depends_on:
postgres:
condition: service_healthy
environment:
# Database connection
DATABASE_URL: postgres://${POSTGRES_USER:-rustforms}:${POSTGRES_PASSWORD:-rustforms_password}@postgres:5432/${POSTGRES_DB:-rustforms_db}
# Application secrets
FORM_SECRET: ${FORM_SECRET:-your-super-secret-unguessable-token-change-this-in-production}
# Email configuration
RECIPIENT_EMAIL: ${RECIPIENT_EMAIL:-admin@example.com}
SMTP_HOST: ${SMTP_HOST:-smtp.example.com}
SMTP_USERNAME: ${SMTP_USERNAME:-your-smtp-username}
SMTP_PASSWORD: ${SMTP_PASSWORD:-your-smtp-password}
# Runtime configuration
RUST_LOG: ${RUST_LOG:-info}
API_PORT: ${API_PORT:-3001}
ports:
- "${API_PORT:-3001}:3001"
networks:
- rustforms-network
volumes:
# Optional: Mount logs directory
- rustforms_api_logs:/app/logs
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:3001/health || exit 1"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
# Next.js Web UI Service
web-ui:
build:
context: .
dockerfile: apps/web-ui/Dockerfile
target: runner
container_name: rustforms-web-ui
restart: unless-stopped
depends_on:
api:
condition: service_healthy
environment:
# Next.js configuration
NODE_ENV: production
NEXT_TELEMETRY_DISABLED: 1
PORT: ${WEB_UI_PORT:-3000}
# API connection
NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL:-http://localhost:3001}
API_URL: http://api:3001
ports:
- "${WEB_UI_PORT:-3000}:3000"
networks:
- rustforms-network
healthcheck:
test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:3000 || exit 1"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
# Optional: Reverse Proxy with Nginx (uncomment to enable)
# nginx:
# image: nginx:alpine
# container_name: rustforms-nginx
# restart: unless-stopped
# depends_on:
# - web-ui
# - api
# ports:
# - "80:80"
# - "443:443"
# volumes:
# - ./docker/nginx.conf:/etc/nginx/nginx.conf:ro
# - ./docker/ssl:/etc/nginx/ssl:ro
# networks:
# - rustforms-network
# Named volumes for data persistence
volumes:
rustforms_postgres_data:
driver: local
rustforms_api_logs:
driver: local
# Custom network for service communication
networks:
rustforms-network:
driver: bridge