Added proper wait for database and removed the wipe entire databases thingy LOL
This commit is contained in:
parent
7667e54635
commit
39a9566e40
@ -15,7 +15,6 @@ RUN mkdir -p $HOME && \
|
||||
|
||||
WORKDIR $APP_HOME
|
||||
|
||||
RUN
|
||||
COPY ./requirements.txt $APP_HOME
|
||||
RUN pip install --upgrade pip && \
|
||||
pip install -r requirements.txt
|
||||
|
||||
@ -1,14 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
echo "Waiting for postgres..."
|
||||
|
||||
#while ! nc -z $SQL_HOST $SQL_PORT; do
|
||||
# sleep 0.1
|
||||
#done
|
||||
|
||||
python wait_for_db.py
|
||||
echo "PostgreSQL started"
|
||||
|
||||
python manage.py flush --no-input
|
||||
python manage.py makemigrations
|
||||
python manage.py migrate
|
||||
python manage.py collectstatic --noinput
|
||||
|
||||
15
app/wait_for_db.py
Normal file
15
app/wait_for_db.py
Normal file
@ -0,0 +1,15 @@
|
||||
import socket
|
||||
import time
|
||||
import os
|
||||
|
||||
port = int(os.environ["SQL_PORT"]) # 5432
|
||||
db_name = os.environ["SQL_DATABASE"]
|
||||
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
while True:
|
||||
try:
|
||||
s.connect((db_name, port))
|
||||
s.close()
|
||||
break
|
||||
except socket.error as ex:
|
||||
time.sleep(0.1)
|
||||
@ -26,7 +26,7 @@ services:
|
||||
container_name: bloonsworld-db
|
||||
image: postgres:17
|
||||
volumes:
|
||||
- ./.data/postgres_data:/var/lib/postgresql/data/
|
||||
- ./.data/postgres_data:/var/lib/postgresql/data/:rw
|
||||
environment:
|
||||
- POSTGRES_USER=$SQL_USER
|
||||
- POSTGRES_PASSWORD=$SQL_PASSWORD
|
||||
|
||||
Loading…
Reference in New Issue
Block a user