Skip to content
This repository has been archived by the owner on Sep 3, 2023. It is now read-only.

Commit

Permalink
Added support for replicas for target webapp in docker compose
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadowXBoss696 committed May 21, 2023
1 parent 357d2ee commit c5e975b
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 13 deletions.
50 changes: 37 additions & 13 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,53 @@ version: '3.8'

services:
webapp:
container_name: jukebox-webapp
build:
context: .
command: ["uvicorn", "jukebox.main:app", "--host", "0.0.0.0", "--port", "8000"]
environment:
DATABASE_URL: postgres://postgres:admin123@database:5432/jukebox
volumes:
- ./jukebox:/opt/jukebox
ports:
- "8000:8000"
depends_on:
- migrate
- database
links:
- database
restart: always
restart: on-failure
deploy:
replicas: 4

database:
container_name: jukebox-database
image: postgres
nginx:
image: nginx
volumes:
- ./misc/nginx/compose.conf:/etc/nginx/conf.d/compose.conf
ports:
- "8000:8000"
depends_on:
- webapp
links:
- webapp
restart: on-failure

scheduler:
build:
context: .
command: [ "python", "jukebox/scheduler.py" ]
environment:
POSTGRES_PASSWORD: admin123
POSTGRES_DB: jukebox
DATABASE_URL: postgres://postgres:admin123@database:5432/jukebox
volumes:
- pg_data:/var/lib/postgresql/data
restart: always
- ./jukebox:/opt/jukebox
depends_on:
- database
- webapp
links:
- database
restart: on-failure

migrate:
container_name: jukebox-migrate
build:
context: .
command: ["python3", "jukebox/database/migrations.py"]
command: ["python", "jukebox/database/migrations.py"]
environment:
DATABASE_URL: postgres://postgres:admin123@database:5432/jukebox
volumes:
Expand All @@ -43,5 +58,14 @@ services:
links:
- database

database:
image: postgres
environment:
POSTGRES_PASSWORD: admin123
POSTGRES_DB: jukebox
volumes:
- pg_data:/var/lib/postgresql/data
restart: always

volumes:
pg_data:
9 changes: 9 additions & 0 deletions misc/nginx/compose.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
server {
listen 8000;
listen [::]:8000;
server_name localhost;

location / {
proxy_pass http://webapp:8000;
}
}

0 comments on commit c5e975b

Please sign in to comment.