|
1 | | -version: '3.8' |
2 | | - |
3 | | -# Docker Compose configuration for STAGING environment |
4 | | -# Usage: docker-compose -f docker-compose.staging.yml up -d |
5 | | - |
6 | | -services: |
7 | | - # Nginx Reverse Proxy |
8 | | - nginx: |
9 | | - image: nginx:alpine |
10 | | - container_name: prostaff-staging-nginx |
11 | | - restart: unless-stopped |
12 | | - ports: |
13 | | - - "80:80" |
14 | | - - "443:443" |
15 | | - volumes: |
16 | | - - ./deploy/nginx/nginx.conf:/etc/nginx/nginx.conf:ro |
17 | | - - ./deploy/nginx/conf.d:/etc/nginx/conf.d:ro |
18 | | - - ./deploy/ssl:/etc/nginx/ssl:ro |
19 | | - - ./public:/app/public:ro |
20 | | - - nginx_logs:/var/log/nginx |
21 | | - depends_on: |
22 | | - - api |
23 | | - networks: |
24 | | - - prostaff-staging-net |
25 | | - healthcheck: |
26 | | - test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost/health"] |
27 | | - interval: 30s |
28 | | - timeout: 10s |
29 | | - retries: 3 |
30 | | - |
31 | | - # PostgreSQL Database |
32 | | - postgres: |
33 | | - image: postgres:15-alpine |
34 | | - container_name: prostaff-staging-postgres |
35 | | - restart: unless-stopped |
36 | | - environment: |
37 | | - POSTGRES_DB: ${POSTGRES_DB:-prostaff_staging} |
38 | | - POSTGRES_USER: ${POSTGRES_USER:-prostaff_user} |
39 | | - POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} |
40 | | - PGDATA: /var/lib/postgresql/data/pgdata |
41 | | - volumes: |
42 | | - - postgres_data:/var/lib/postgresql/data |
43 | | - - ./backups:/backups |
44 | | - networks: |
45 | | - - prostaff-staging-net |
46 | | - healthcheck: |
47 | | - test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-prostaff_user}"] |
48 | | - interval: 10s |
49 | | - timeout: 5s |
50 | | - retries: 5 |
51 | | - deploy: |
52 | | - resources: |
53 | | - limits: |
54 | | - memory: 1G |
55 | | - reservations: |
56 | | - memory: 512M |
57 | | - |
58 | | - # Redis Cache |
59 | | - redis: |
60 | | - image: redis:7-alpine |
61 | | - container_name: prostaff-staging-redis |
62 | | - restart: unless-stopped |
63 | | - command: redis-server --requirepass ${REDIS_PASSWORD} --maxmemory 256mb --maxmemory-policy allkeys-lru |
64 | | - volumes: |
65 | | - - redis_data:/data |
66 | | - networks: |
67 | | - - prostaff-staging-net |
68 | | - healthcheck: |
69 | | - test: ["CMD", "redis-cli", "--pass", "${REDIS_PASSWORD}", "ping"] |
70 | | - interval: 10s |
71 | | - timeout: 5s |
72 | | - retries: 5 |
73 | | - deploy: |
74 | | - resources: |
75 | | - limits: |
76 | | - memory: 512M |
77 | | - reservations: |
78 | | - memory: 256M |
79 | | - |
80 | | - # Rails API |
81 | | - api: |
82 | | - build: |
83 | | - context: . |
84 | | - dockerfile: Dockerfile.production |
85 | | - args: |
86 | | - RAILS_ENV: staging |
87 | | - container_name: prostaff-staging-api |
88 | | - restart: unless-stopped |
89 | | - environment: |
90 | | - RAILS_ENV: staging |
91 | | - DATABASE_URL: ${DATABASE_URL} |
92 | | - REDIS_URL: ${REDIS_URL} |
93 | | - SECRET_KEY_BASE: ${SECRET_KEY_BASE} |
94 | | - JWT_SECRET_KEY: ${JWT_SECRET_KEY} |
95 | | - DEVISE_JWT_SECRET_KEY: ${DEVISE_JWT_SECRET_KEY} |
96 | | - CORS_ORIGINS: ${CORS_ORIGINS} |
97 | | - RIOT_API_KEY: ${RIOT_API_KEY} |
98 | | - SENTRY_DSN: ${SENTRY_DSN} |
99 | | - SENTRY_ENVIRONMENT: staging |
100 | | - # Staging-specific settings |
101 | | - RAILS_LOG_LEVEL: info |
102 | | - ENABLE_SWAGGER_UI: "true" |
103 | | - ENABLE_PERFORMANCE_MONITORING: "true" |
104 | | - volumes: |
105 | | - - ./log:/app/log |
106 | | - - ./tmp:/app/tmp |
107 | | - - ./public:/app/public |
108 | | - depends_on: |
109 | | - postgres: |
110 | | - condition: service_healthy |
111 | | - redis: |
112 | | - condition: service_healthy |
113 | | - networks: |
114 | | - - prostaff-staging-net |
115 | | - healthcheck: |
116 | | - test: ["CMD", "curl", "-f", "http://localhost:3000/up"] |
117 | | - interval: 30s |
118 | | - timeout: 10s |
119 | | - retries: 3 |
120 | | - start_period: 40s |
121 | | - deploy: |
122 | | - resources: |
123 | | - limits: |
124 | | - memory: 1G |
125 | | - cpus: '0.5' |
126 | | - reservations: |
127 | | - memory: 256M |
128 | | - cpus: '0.25' |
129 | | - |
130 | | - # Sidekiq Background Jobs |
131 | | - sidekiq: |
132 | | - build: |
133 | | - context: . |
134 | | - dockerfile: Dockerfile.production |
135 | | - args: |
136 | | - RAILS_ENV: staging |
137 | | - container_name: prostaff-staging-sidekiq |
138 | | - restart: unless-stopped |
139 | | - command: bundle exec sidekiq -C config/sidekiq.yml |
140 | | - environment: |
141 | | - RAILS_ENV: staging |
142 | | - DATABASE_URL: ${DATABASE_URL} |
143 | | - REDIS_URL: ${SIDEKIQ_REDIS_URL} |
144 | | - SECRET_KEY_BASE: ${SECRET_KEY_BASE} |
145 | | - RIOT_API_KEY: ${RIOT_API_KEY} |
146 | | - SENTRY_DSN: ${SENTRY_DSN} |
147 | | - SENTRY_ENVIRONMENT: staging |
148 | | - volumes: |
149 | | - - ./log:/app/log |
150 | | - - ./tmp:/app/tmp |
151 | | - depends_on: |
152 | | - postgres: |
153 | | - condition: service_healthy |
154 | | - redis: |
155 | | - condition: service_healthy |
156 | | - networks: |
157 | | - - prostaff-staging-net |
158 | | - deploy: |
159 | | - resources: |
160 | | - limits: |
161 | | - memory: 512M |
162 | | - cpus: '0.25' |
163 | | - reservations: |
164 | | - memory: 128M |
165 | | - cpus: '0.1' |
166 | | - |
167 | | - # Backup Service |
168 | | - backup: |
169 | | - image: postgres:15-alpine |
170 | | - container_name: prostaff-staging-backup |
171 | | - restart: "no" |
172 | | - environment: |
173 | | - PGHOST: postgres |
174 | | - PGDATABASE: ${POSTGRES_DB:-prostaff_staging} |
175 | | - PGUSER: ${POSTGRES_USER:-prostaff_user} |
176 | | - PGPASSWORD: ${POSTGRES_PASSWORD} |
177 | | - BACKUP_RETENTION_DAYS: ${BACKUP_RETENTION_DAYS:-7} |
178 | | - volumes: |
179 | | - - ./backups:/backups |
180 | | - - ./deploy/scripts/backup.sh:/backup.sh:ro |
181 | | - networks: |
182 | | - - prostaff-staging-net |
183 | | - entrypoint: ["/backup.sh"] |
184 | | - profiles: |
185 | | - - backup |
186 | | - |
187 | | -volumes: |
188 | | - postgres_data: |
189 | | - driver: local |
190 | | - redis_data: |
191 | | - driver: local |
192 | | - nginx_logs: |
193 | | - driver: local |
194 | | - |
195 | | -networks: |
196 | | - prostaff-staging-net: |
197 | | - driver: bridge |
198 | | - ipam: |
199 | | - config: |
200 | | - - subnet: 172.21.0.0/16 |
| 1 | +services: |
| 2 | + redis: |
| 3 | + image: redis:7.2-alpine |
| 4 | + restart: unless-stopped |
| 5 | + command: redis-server --requirepass ${REDIS_PASSWORD} --appendonly yes |
| 6 | + networks: |
| 7 | + - coolify |
| 8 | + volumes: |
| 9 | + - redis-data:/data |
| 10 | + healthcheck: |
| 11 | + test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD}", "ping"] |
| 12 | + interval: 10s |
| 13 | + timeout: 3s |
| 14 | + retries: 3 |
| 15 | + start_period: 10s |
| 16 | + labels: |
| 17 | + - coolify.managed=true |
| 18 | + - coolify.applicationId=1 |
| 19 | + - coolify.type=application |
| 20 | + |
| 21 | + api: |
| 22 | + build: |
| 23 | + context: . |
| 24 | + dockerfile: Dockerfile.production |
| 25 | + restart: unless-stopped |
| 26 | + networks: |
| 27 | + - coolify |
| 28 | + environment: |
| 29 | + RAILS_ENV: production |
| 30 | + DATABASE_URL: ${DATABASE_URL} |
| 31 | + REDIS_URL: redis://default:${REDIS_PASSWORD}@redis:6379/0 |
| 32 | + ELASTICSEARCH_URL: ${ELASTICSEARCH_URL:-http://elastic:9200} |
| 33 | + RAILS_LOG_TO_STDOUT: "true" |
| 34 | + PORT: 3000 |
| 35 | + RAILS_MASTER_KEY: ${RAILS_MASTER_KEY} |
| 36 | + RIOT_API_KEY: ${RIOT_API_KEY} |
| 37 | + CORS_ORIGINS: ${CORS_ORIGINS:-https://prostaff.gg,https://www.prostaff.gg,https://api.prostaff.gg} |
| 38 | + JWT_SECRET_KEY: ${JWT_SECRET_KEY} |
| 39 | + SECRET_KEY_BASE: ${SECRET_KEY_BASE} |
| 40 | + healthcheck: |
| 41 | + test: ["CMD-SHELL", "curl -f http://localhost:3000/up || exit 1"] |
| 42 | + interval: 10s |
| 43 | + timeout: 3s |
| 44 | + retries: 3 |
| 45 | + start_period: 40s |
| 46 | + depends_on: |
| 47 | + redis: |
| 48 | + condition: service_healthy |
| 49 | + labels: |
| 50 | + - coolify.managed=true |
| 51 | + - coolify.applicationId=1 |
| 52 | + - coolify.type=application |
| 53 | + # Traefik routing |
| 54 | + - traefik.enable=true |
| 55 | + - traefik.http.routers.prostaff-api.rule=Host(`api.prostaff.gg`) |
| 56 | + - traefik.http.routers.prostaff-api.entrypoints=websecure |
| 57 | + - traefik.http.routers.prostaff-api.tls=true |
| 58 | + - traefik.http.routers.prostaff-api.tls.certresolver=letsencrypt |
| 59 | + # Service configuration |
| 60 | + - traefik.http.services.prostaff-api.loadbalancer.server.port=3000 |
| 61 | + - traefik.http.services.prostaff-api.loadbalancer.healthcheck.path=/up |
| 62 | + - traefik.http.services.prostaff-api.loadbalancer.healthcheck.interval=10s |
| 63 | + - traefik.http.services.prostaff-api.loadbalancer.healthcheck.timeout=3s |
| 64 | + # HTTP to HTTPS redirect |
| 65 | + - traefik.http.routers.prostaff-api-http.rule=Host(`api.prostaff.gg`) |
| 66 | + - traefik.http.routers.prostaff-api-http.entrypoints=web |
| 67 | + - traefik.http.routers.prostaff-api-http.middlewares=redirect-to-https |
| 68 | + - traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https |
| 69 | + # CORS middleware |
| 70 | + - traefik.http.middlewares.prostaff-cors.headers.accesscontrolallowmethods=GET,POST,PUT,PATCH,DELETE,OPTIONS,HEAD |
| 71 | + - traefik.http.middlewares.prostaff-cors.headers.accesscontrolalloworiginlist=https://prostaff.gg,https://www.prostaff.gg |
| 72 | + - traefik.http.middlewares.prostaff-cors.headers.accesscontrolallowcredentials=true |
| 73 | + - traefik.http.middlewares.prostaff-cors.headers.accesscontrolallowheaders=* |
| 74 | + - traefik.http.middlewares.prostaff-cors.headers.accesscontrolmaxage=86400 |
| 75 | + # Apply middleware |
| 76 | + - traefik.http.routers.prostaff-api.middlewares=prostaff-cors |
| 77 | + |
| 78 | + sidekiq: |
| 79 | + build: |
| 80 | + context: . |
| 81 | + dockerfile: Dockerfile.production |
| 82 | + command: bundle exec sidekiq -C config/sidekiq.yml |
| 83 | + restart: unless-stopped |
| 84 | + networks: |
| 85 | + - coolify |
| 86 | + environment: |
| 87 | + RAILS_ENV: production |
| 88 | + DATABASE_URL: ${DATABASE_URL} |
| 89 | + REDIS_URL: redis://default:${REDIS_PASSWORD}@redis:6379/0 |
| 90 | + ELASTICSEARCH_URL: ${ELASTICSEARCH_URL:-http://elastic:9200} |
| 91 | + RAILS_MASTER_KEY: ${RAILS_MASTER_KEY} |
| 92 | + RIOT_API_KEY: ${RIOT_API_KEY} |
| 93 | + SECRET_KEY_BASE: ${SECRET_KEY_BASE} |
| 94 | + depends_on: |
| 95 | + redis: |
| 96 | + condition: service_healthy |
| 97 | + api: |
| 98 | + condition: service_healthy |
| 99 | + labels: |
| 100 | + - coolify.managed=true |
| 101 | + - coolify.applicationId=1 |
| 102 | + - coolify.type=application |
| 103 | + |
| 104 | +volumes: |
| 105 | + redis-data: |
| 106 | + driver: local |
| 107 | + |
| 108 | +networks: |
| 109 | + coolify: |
| 110 | + external: true |
0 commit comments