diff --git a/backend/Dockerfile b/backend/Dockerfile index 323cc11..5a43e77 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,21 +1,21 @@ -FROM python:3.8-slim +FROM python:3.8-slim +ENV PYTHONUNBUFFERED 1 +ENV PATH="/opt/venv/bin:$PATH" -ENV PYTHONUNBUFFERED 1 +RUN apt-get update; \ + apt-get install -y build-essential gcc; \ + python -m venv /opt/venv; \ + python -m pip install --upgrade pip; \ + mkdir /code; -RUN apt-get update; \ - apt-get install -y build-essential gcc; \ - python -m venv /opt/venv; \ - python -m pip install --upgrade pip; +WORKDIR /code -ENV PATH="/opt/venv/bin:$PATH" +COPY setup.py /code/ +COPY requirements.txt /code/ -RUN mkdir /code +RUN pip install -r requirements.txt -WORKDIR /code +COPY . /code/ -COPY setup.py /code/ -COPY requirements.txt /code/ - -RUN pip install -r requirements.txt - -COPY . /code/ +RUN chmod 777 scripts/entrypoint.sh +ENTRYPOINT ["scripts/entrypoint.sh"] diff --git a/backend/app_be/wsgi.py b/backend/app_be/wsgi.py index 8addf73..000c14b 100644 --- a/backend/app_be/wsgi.py +++ b/backend/app_be/wsgi.py @@ -11,6 +11,6 @@ import os from django.core.wsgi import get_wsgi_application -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{{ app_be }}.settings") +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "app_be.settings") application = get_wsgi_application() diff --git a/backend/scripts/entrypoint.sh b/backend/scripts/entrypoint.sh new file mode 100644 index 0000000..b70ddcf --- /dev/null +++ b/backend/scripts/entrypoint.sh @@ -0,0 +1,10 @@ +#!/bin/bash +# executes the manage.py commands to setup and starts the server + +echo "setup" +python manage.py makemigrations +python manage.py makemigrations app_be +python manage.py migrate + +echo "run server" +gunicorn app_be.wsgi:application -b 0.0.0.0 -p 8000 diff --git a/backend/setup.py b/backend/setup.py index 949dd83..6242ef7 100644 --- a/backend/setup.py +++ b/backend/setup.py @@ -21,7 +21,8 @@ setup(name='waecm-2021-group-04', 'python-dotenv==0.17.1', 'feedsearch==1.0.12', 'Pillow==8.2.0', - 'python-dateutil==2.8.1' + 'python-dateutil==2.8.1', + 'gunicorn==20.1.0' ], license='BSD License', # example license description='DESCRIPTION')