Skip to content

Commit

Permalink
Merge pull request #104 from NIAEFEUP/fix/production-generates-modelspy
Browse files Browse the repository at this point in the history
FIX: production build now generates models.py
  • Loading branch information
LuisDuarte1 authored Aug 25, 2024
2 parents 73c906f + 581ecef commit 431f0b1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion django/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ COPY tts_be/ ./tts_be
COPY university/ ./university
COPY manage.py tasks.py ./

CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
COPY ./entrypoint_prod.sh ./entrypoint_prod.sh
ENTRYPOINT ["/usr/src/django/entrypoint_prod.sh"]
15 changes: 15 additions & 0 deletions django/entrypoint_prod.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

# Waits for PostgreSQL initialization.
until PGPASSWORD="${POSTGRES_PASSWORD}" psql -h "${POSTGRES_HOST}" -U "${POSTGRES_USER}" "${POSTGRES_DB}" -c 'select 1'; do
>&2 echo "PostgreSQL is unavailable - sleeping"
sleep 4
done
>&2 echo "PostgreSQL is up - executing command"

# Migrate the Django.
python manage.py inspectdb >university/models.py
python manage.py makemigrations
python manage.py migrate university --fake

python manage.py runserver 0.0.0.0:8000

0 comments on commit 431f0b1

Please sign in to comment.