-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathdocker-compose.staging.yml
More file actions
96 lines (89 loc) · 2.65 KB
/
docker-compose.staging.yml
File metadata and controls
96 lines (89 loc) · 2.65 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
# Staging / demo / branch preview deployment.
#
# Like production, but runs Redis, RabbitMQ, and NATS as local containers
# instead of requiring external infrastructure services.
# Database is always external — set DATABASE_IP in .envs/.production/.compose.
#
# Usage:
# docker compose -f docker-compose.staging.yml --env-file .envs/.production/.compose up -d
#
# For a local database, see compose/staging/docker-compose.db.yml.
#
# Multiple instances: This compose file can run multiple instances on the same
# host (e.g., branch previews, worktrees) by setting a unique project name and
# overriding the published ports:
#
# DJANGO_PORT=5002 FLOWER_PORT=5551 \
# docker compose -p my-preview -f docker-compose.staging.yml \
# --env-file .envs/.production/.compose up -d
#
# Internal services (Redis, RabbitMQ, NATS) do not publish host ports, so they
# never conflict between instances. Each compose project gets its own isolated
# Docker network.
#
# Required env files:
# .envs/.production/.compose — DATABASE_IP
# .envs/.production/.django — Django settings, CELERY_BROKER_URL, NATS_URL, etc.
# .envs/.production/.postgres — POSTGRES_HOST=db, POSTGRES_DB, POSTGRES_USER, POSTGRES_PASSWORD
services:
django: &django
build:
context: .
dockerfile: ./compose/production/django/Dockerfile
image: insectai/ami_backend
depends_on:
- redis
- rabbitmq
- nats
env_file:
- ./.envs/.production/.django
- ./.envs/.production/.postgres
volumes:
- ./config:/app/config
ports:
- "${DJANGO_PORT:-5001}:5000"
extra_hosts:
- "db:${DATABASE_IP:?Set DATABASE_IP in .envs/.production/.compose}"
command: /start
restart: always
celeryworker:
<<: *django
scale: 1
ports: []
command: /start-celeryworker
restart: always
celerybeat:
<<: *django
ports: []
command: /start-celerybeat
restart: always
flower:
<<: *django
ports:
- "${FLOWER_PORT:-5550}:5555"
command: /start-flower
restart: always
volumes:
- ./data/flower/:/data/
redis:
image: redis:6
command: redis-server /usr/local/etc/redis/redis.conf
volumes:
- ./compose/staging/redis.conf:/usr/local/etc/redis/redis.conf:ro
restart: always
rabbitmq:
image: rabbitmq:3.13-management-alpine
hostname: rabbitmq
env_file:
- ./.envs/.production/.django
restart: always
nats:
image: nats:2.10-alpine
hostname: nats
command: ["-js", "-m", "8222"]
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "http://localhost:8222/healthz"]
interval: 10s
timeout: 5s
retries: 3
restart: always