docker enhancements

This commit is contained in:
Corban-Lee Jones 2024-08-11 23:55:36 +01:00
parent 873fcd986c
commit 115a23592c
3 changed files with 15 additions and 12 deletions

View File

@ -1,6 +1,6 @@
FROM python:3.11
FROM python:3.11.4-slim-buster
# set environment variables
# python related environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
@ -11,13 +11,13 @@ COPY requirements.txt /app/
RUN pip install --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt
# setup entrypoint file
COPY ./scripts/entrypoint.sh .
RUN chmod +x /app/scripts/entrypoint.sh
COPY . /app/
# running migrations
RUN python manage.py migrate
# collect static
RUN python manage.py collectstatic
ENTRYPOINT ["/app/scripts/entrypoint.sh"]
# gunicorn
CMD ["gunicorn", "--bind", "0.0.0.0:8000", "core.wsgi:application"]

8
scripts/entrypoint.sh Executable file
View File

@ -0,0 +1,8 @@
#!/bin/sh
RUN python manage.py collectstatic
python manage.py flush --no-input
python manage.py migrate
exec "$@"

View File

@ -1,5 +0,0 @@
echo migrating
python manage.py migrate
echo running without reload
python manage.py runserver 0.0.0.0:8000 --noreload