This repository was archived by the owner on Oct 28, 2024. It is now read-only.
File tree 4 files changed +58
-0
lines changed
4 files changed +58
-0
lines changed Original file line number Diff line number Diff line change
1
+ FROM python:3.11-slim
2
+
3
+ ENV PYTHONUNBUFFERED 1
4
+
5
+ COPY requirements.txt requirements.txt
6
+ RUN pip install -r requirements.txt
7
+
8
+ COPY oas.yaml oas.yaml
9
+ COPY waitlist waitlist
10
+ COPY src src
11
+ WORKDIR /src
File renamed without changes.
Original file line number Diff line number Diff line change
1
+ version : ' 3.9'
2
+
3
+ services :
4
+ api :
5
+ build : .
6
+ command : >
7
+ sh -c "python /waitlist/wait_for_postgres.py &&
8
+ python manage.py migrate &&
9
+ python manage.py runserver 0.0.0.0:8000"
10
+ env_file :
11
+ - api.env
12
+ ports :
13
+ - ' 8000:8000'
14
+ depends_on :
15
+ - db
16
+
17
+ db :
18
+ image : postgres
19
+ environment :
20
+ - POSTGRES_PASSWORD=admin
21
+ volumes :
22
+ - posts-db:/var/lib/postgresql/data
23
+
24
+ volumes :
25
+ posts-db:
Original file line number Diff line number Diff line change
1
+ import time
2
+
3
+ import psycopg2
4
+ from environs import Env
5
+
6
+ env = Env ()
7
+ env .read_env ()
8
+
9
+
10
+ def wait_for_postgres_to_come_up ():
11
+ deadline = time .time () + 120
12
+ while time .time () < deadline :
13
+ try :
14
+ return psycopg2 .connect (env .str ('DJANGO_DATABASE_URL' ))
15
+ except psycopg2 .OperationalError :
16
+ time .sleep (0.5 )
17
+ raise Exception ('Postgres never came up' )
18
+
19
+
20
+ if __name__ == '__main__' :
21
+ wait_for_postgres_to_come_up ()
22
+
You can’t perform that action at this time.
0 commit comments