File tree Expand file tree Collapse file tree 3 files changed +16
-17
lines changed
Expand file tree Collapse file tree 3 files changed +16
-17
lines changed Original file line number Diff line number Diff line change @@ -8,14 +8,14 @@ COPY requirements.txt .
88RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt
99
1010# copy app source code
11- COPY app ./app
12- COPY alembic.ini ./alembic.ini
13- COPY alembic ./alembic
11+ COPY . .
12+
13+ RUN chmod +x entrypoint.sh
1414
1515# environment variables
1616ENV PYTHONUNBUFFERED=1
1717
1818# entrypoint: run migrations then start up
19- CMD ["sh" , "-c" , "alembic upgrade head && uvicorn app.main:app --host 0.0.0.0 --port 8000 " ]
19+ ENTRYPOINT ["./entrypoint.sh " ]
2020
2121
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+ set -e
3+
4+ echo " Waiting for database and running migrations..."
5+
6+ until alembic upgrade head; do
7+ echo " Migration failed, retrying in 2 seconds..."
8+ sleep 2
9+ done
10+
11+ echo " Migrations complete. Starting server..."
12+ exec uvicorn app.main:app --host 0.0.0.0 --port 8000
Original file line number Diff line number Diff line change @@ -28,19 +28,6 @@ services:
2828 interval : 5s
2929 timeout : 5s
3030 retries : 5
31-
32- migrate :
33- image : eventrelay-api:latest
34- command : alembic upgrade head
35- environment :
36- POSTGRES_USER : eventrelayuser
37- POSTGRES_PASSWORD : 123
38- POSTGRES_DB : eventrelay
39- POSTGRES_HOST : db
40- POSTGRES_PORT : 5432
41- depends_on :
42- db :
43- condition : service_healthy
4431
4532volumes :
4633 postgres_data:
You can’t perform that action at this time.
0 commit comments