diff --git a/Dockerfile b/Dockerfile index ff3e38b..b1c2278 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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"] diff --git a/scripts/entrypoint.sh b/scripts/entrypoint.sh new file mode 100755 index 0000000..abeac1f --- /dev/null +++ b/scripts/entrypoint.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +RUN python manage.py collectstatic + +python manage.py flush --no-input +python manage.py migrate + +exec "$@" \ No newline at end of file diff --git a/scripts/runserver.sh b/scripts/runserver.sh deleted file mode 100755 index a246a46..0000000 --- a/scripts/runserver.sh +++ /dev/null @@ -1,5 +0,0 @@ -echo migrating -python manage.py migrate - -echo running without reload -python manage.py runserver 0.0.0.0:8000 --noreload \ No newline at end of file