From 2dfd625b5ed9f96ed29f92612e2838e02697499a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Katariina=20J=C3=A4rvenm=C3=A4ki?= Date: Wed, 4 Mar 2026 11:59:39 +0200 Subject: [PATCH] Make postgress run from it's own container --- README.md | 6 +++--- docker-compose.yml | 16 ++++++++++------ test.db | Bin 32768 -> 0 bytes 3 files changed, 13 insertions(+), 9 deletions(-) delete mode 100644 test.db diff --git a/README.md b/README.md index 56118da..0896889 100644 --- a/README.md +++ b/README.md @@ -13,11 +13,11 @@ source venv/bin/activate python -m uvicorn app.main:app --reload --host 0.0.0.0 --port 8000 ``` Then check:
-http://127.0.0.1:8000
-http://127.0.0.1:8000/docs +http://localhost:9995
+http://localhost:9995/docs Test Short URL Endpoint:
-http://127.0.0.1:8000/shorten +http://localhost:9995/shorten ## Running a test ```bash diff --git a/docker-compose.yml b/docker-compose.yml index 67eea49..56b48a7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -version: "3.9" - services: db: image: postgres:16 @@ -11,20 +9,26 @@ services: POSTGRES_DB: url_db volumes: - postgres_data:/var/lib/postgresql/data + healthcheck: + test: ["CMD-SHELL", "pg_isready -U postgres"] + interval: 5s + timeout: 5s + retries: 5 app: build: . container_name: url_shortener_app depends_on: - - db + db: + condition: service_healthy environment: DATABASE_URL: postgresql+psycopg2://postgres:postgres@db:5432/url_db - BASE_URL: http://localhost:8000 + BASE_URL: http://localhost:9995 ports: - - "8000:8000" + - "9995:9995" command: > sh -c "alembic upgrade head && - uvicorn app.main:app --host 0.0.0.0 --port 8000" + uvicorn app.main:app --host 0.0.0.0 --port 9995" volumes: postgres_data: \ No newline at end of file diff --git a/test.db b/test.db deleted file mode 100644 index 32c0952eda4287d15152e7a947ee4b2250b99716..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 32768 zcmeI(%WvaE90zbac9TuiWR^pSinM4}LZVS$iJfHIN<2*KLPY9rTnDkz3d>DQ*EElA z>{b;lhg}dSZd}+4e*jm``~`6B0dYYbmkV6>#DST-oo+!$tCe>1wd!O%9{*_gV=}oh|tC_dx`}!@qI1w+K$i5MaW~xh~;I$j>nSZy*W>mIw z5_Edk_EdB1{8R>?WA)})Z_Y(C*VAIH_n3EPpLCnP?KSvUbkM=Fv8{hd$M@)-LHT{U z=ryt*$+1j6E#8+x0sK3iZeZ6t4VM?38w9EuKA0C{ znRHtG;nK~Eblq!(#Q(uwSSpo+HAOHafKmY;|fB*y_009UdvR#J3(;lZ?3KRffM*Ef$ImW^-e3I06siJJ=* z_ggsCIo@B^1mo#7!xC8&w79CB?zMNjm0=T(oKKu~Z>_*P?NO~wwIsJ$C|<}auCLx$ zFXT!$60CtT`Bor5ke|r!EP(?85P$##AOHafKmY;|fB*y_0D)&F@QSn{4yX9xl@&Q7 zsiRvH3lP%FQht;_v2t=v(&EEN7Z(fq^Z$DS`HtKpKayXcSqD)O1Rwwb2tWV=5P$## zAOHafKww4$uFGs2#lLN$kYAM-RPoX+2huf}ZJM}r%fxFk+b-~5n+5vw|8s%-M$X9} z-dG!2u9zB2n1Rwwb2tWV=5P$##AOHaf%(B3oB#N@kKP8EOMk10Fk0&|F z)me5y-yr}22tWV=5P$##AOHafKmYk5r~m)}