Skip to content

Commit

Permalink
Merge pull request #105 from NIAEFEUP/develop
Browse files Browse the repository at this point in the history
Fix: Production image now automatically generates models.py
  • Loading branch information
tomaspalma committed Aug 25, 2024
2 parents 2e85bb4 + 431f0b1 commit 9aac67d
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 9aac67d

Please sign in to comment.