File tree Expand file tree Collapse file tree 4 files changed +111
-2
lines changed Expand file tree Collapse file tree 4 files changed +111
-2
lines changed Original file line number Diff line number Diff line change @@ -2,14 +2,14 @@ PYTHONDONTWRITEBYTECODE=1
22PYTHONUNBUFFERED = 1
33
44# Postgres
5- POSTGRES_HOST = localhost
5+ POSTGRES_HOST = postgres
66POSTGRES_PORT = 5432
77POSTGRES_DB = devdb
88POSTGRES_USER = devdb
99POSTGRES_PASSWORD = secret
1010
1111# Redis
12- REDIS_HOST = localhost
12+ REDIS_HOST = redis
1313REDIS_PORT = 6379
1414REDIS_DB = 2
1515
Original file line number Diff line number Diff line change 1+ services :
2+ api1 :
3+ container_name : panettone_api1
4+ build : .
5+ environment :
6+ - PYTHONPATH=/panettone
7+ env_file :
8+ - .env
9+ - .secrets
10+ command : bash -c "
11+ uvicorn app.main:app
12+ --host 0.0.0.0 --port 8080
13+ --lifespan=on --use-colors --loop uvloop --http httptools
14+ "
15+ volumes:
16+ - ./app:/panettone/app
17+ - ./tests:/panettone/tests
18+ - ./templates:/panettone/templates
19+ - ./alembic:/panettone/alembic
20+ ports:
21+ - " 8081:8080"
22+ depends_on :
23+ - postgres
24+ - redis
25+
26+ api2 :
27+ container_name : panettone_api2
28+ build : .
29+ environment :
30+ - PYTHONPATH=/panettone
31+ env_file :
32+ - .env
33+ - .secrets
34+ command : bash -c "
35+ uvicorn app.main:app
36+ --host 0.0.0.0 --port 8080
37+ --lifespan=on --use-colors --loop uvloop --http httptools
38+ "
39+ volumes:
40+ - ./app:/panettone/app
41+ - ./tests:/panettone/tests
42+ - ./templates:/panettone/templates
43+ - ./alembic:/panettone/alembic
44+ ports:
45+ - " 8082:8080"
46+ depends_on :
47+ - postgres
48+ - redis
49+
50+
51+ postgres :
52+ container_name : panettone_postgres
53+ build :
54+ context : ./db
55+ dockerfile : Dockerfile
56+ volumes :
57+ - panettone_postgres_data:/var/lib/postgresql/data
58+ env_file :
59+ - .env
60+ ports :
61+ - 5432:5432
62+ environment :
63+ - POSTGRES_PASSWORD=${POSTGRES_PASSWORD?Variable not set}
64+ - POSTGRES_USER=${POSTGRES_USER?Variable not set}
65+ - POSTGRES_DB=${POSTGRES_DB?Variable not set}
66+ healthcheck :
67+ test :
68+ [
69+ " CMD-SHELL" , "pg_isready -d $POSTGRES_DB -U $POSTGRES_USER"
70+ ]
71+ interval : 5s
72+ timeout : 5s
73+ retries : 5
74+
75+ redis :
76+ image : redis:latest
77+ container_name : panettone_redis
78+ ports :
79+ - " 6379:6379"
80+ env_file :
81+ - .env
82+ entrypoint : redis-server --appendonly yes
83+
84+ loadbalancer :
85+ container_name : panettone_loadbalancer
86+ build : ./nginx
87+ ports :
88+ - " 8080:80"
89+ depends_on :
90+ - api1
91+ - api2
92+
93+ volumes :
94+ panettone_postgres_data : {}
Original file line number Diff line number Diff line change 1+ FROM nginx
2+ RUN rm /etc/nginx/conf.d/default.conf
3+ COPY nginx.conf /etc/nginx/conf.d/default.conf
Original file line number Diff line number Diff line change 1+ upstream loadbalancer {
2+ server api1:8080 weight=1;
3+ server api2:8080 weight=1;
4+ }
5+
6+ server {
7+ listen 80 ;
8+
9+ location / {
10+ proxy_pass http ://loadbalancer;
11+ }
12+ }
You can’t perform that action at this time.
0 commit comments