Dockerizing the project

This commit is contained in:
2026-03-04 10:47:06 +02:00
parent 519b683fc3
commit ced2950b60
7 changed files with 66 additions and 10 deletions
+30
View File
@@ -0,0 +1,30 @@
version: "3.9"
services:
db:
image: postgres:16
container_name: url_shortener_db
restart: always
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: url_db
volumes:
- postgres_data:/var/lib/postgresql/data
app:
build: .
container_name: url_shortener_app
depends_on:
- db
environment:
DATABASE_URL: postgresql+psycopg2://postgres:postgres@db:5432/url_db
BASE_URL: http://localhost:8000
ports:
- "8000:8000"
command: >
sh -c "alembic upgrade head &&
uvicorn app.main:app --host 0.0.0.0 --port 8000"
volumes:
postgres_data: