Make postgress run from it's own container
This commit is contained in:
@@ -13,11 +13,11 @@ source venv/bin/activate
|
|||||||
python -m uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
|
python -m uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
|
||||||
```
|
```
|
||||||
Then check:<br>
|
Then check:<br>
|
||||||
http://127.0.0.1:8000<br>
|
http://localhost:9995<br>
|
||||||
http://127.0.0.1:8000/docs
|
http://localhost:9995/docs
|
||||||
|
|
||||||
Test Short URL Endpoint:<br>
|
Test Short URL Endpoint:<br>
|
||||||
http://127.0.0.1:8000/shorten
|
http://localhost:9995/shorten
|
||||||
|
|
||||||
## Running a test
|
## Running a test
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
+10
-6
@@ -1,5 +1,3 @@
|
|||||||
version: "3.9"
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
db:
|
db:
|
||||||
image: postgres:16
|
image: postgres:16
|
||||||
@@ -11,20 +9,26 @@ services:
|
|||||||
POSTGRES_DB: url_db
|
POSTGRES_DB: url_db
|
||||||
volumes:
|
volumes:
|
||||||
- postgres_data:/var/lib/postgresql/data
|
- postgres_data:/var/lib/postgresql/data
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD-SHELL", "pg_isready -U postgres"]
|
||||||
|
interval: 5s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 5
|
||||||
|
|
||||||
app:
|
app:
|
||||||
build: .
|
build: .
|
||||||
container_name: url_shortener_app
|
container_name: url_shortener_app
|
||||||
depends_on:
|
depends_on:
|
||||||
- db
|
db:
|
||||||
|
condition: service_healthy
|
||||||
environment:
|
environment:
|
||||||
DATABASE_URL: postgresql+psycopg2://postgres:postgres@db:5432/url_db
|
DATABASE_URL: postgresql+psycopg2://postgres:postgres@db:5432/url_db
|
||||||
BASE_URL: http://localhost:8000
|
BASE_URL: http://localhost:9995
|
||||||
ports:
|
ports:
|
||||||
- "8000:8000"
|
- "9995:9995"
|
||||||
command: >
|
command: >
|
||||||
sh -c "alembic upgrade head &&
|
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:
|
volumes:
|
||||||
postgres_data:
|
postgres_data:
|
||||||
Reference in New Issue
Block a user