diff --git a/Dockerfile b/Dockerfile index 207638e..417bdef 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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"] \ No newline at end of file +CMD ["python", "-m", "app.main"] \ No newline at end of file diff --git a/compose.yaml b/compose.yaml index 7454556..86e6850 100644 --- a/compose.yaml +++ b/compose.yaml @@ -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