forked from mtusi2026/mtusi2026lab3
feat: separate migrator service for safe db initialization
This commit is contained in:
+1
-1
@@ -24,4 +24,4 @@ EXPOSE 8080
|
||||
HEALTHCHECK --interval=30s --timeout=3s --start-period=20s --retries=5 \
|
||||
CMD python -c "import urllib.request,sys; sys.exit(0 if urllib.request.urlopen('http://127.0.0.1:8080/health/ready', timeout=2).status==200 else 1)"
|
||||
|
||||
CMD ["sh", "-c", "alembic upgrade head && python -m app.main"]
|
||||
CMD ["python", "-m", "app.main"]
|
||||
@@ -26,6 +26,15 @@ services:
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
|
||||
migrator:
|
||||
build: .
|
||||
command: alembic upgrade head
|
||||
environment:
|
||||
DATABASE_URL: postgresql+asyncpg://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
|
||||
api:
|
||||
build: .
|
||||
environment:
|
||||
@@ -37,6 +46,8 @@ services:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
migrator:
|
||||
condition: service_completed_successfully
|
||||
|
||||
nginx:
|
||||
image: nginx:1.25-alpine
|
||||
|
||||
Reference in New Issue
Block a user