From f2be69a107dd6837b9e47ea5abb0a8f53e7461b3 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 18 Oct 2021 19:22:37 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Create=20Dockerfile=20for=20the=20b?= =?UTF-8?q?ackend?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/Dockerfile | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 backend/Dockerfile diff --git a/backend/Dockerfile b/backend/Dockerfile new file mode 100644 index 0000000..e770b69 --- /dev/null +++ b/backend/Dockerfile @@ -0,0 +1,31 @@ +FROM python:3.9.7-bullseye +LABEL maintainer="Stefano Pigozzi " + +# Set the base workdir as seen in https://hub.docker.com/_/python/ +WORKDIR /usr/src/app + +# Install Poetry +RUN pip install 'poetry==1.1.11' + +# Copy the environment requirements into the docker image +COPY pyproject.toml ./pyproject.toml +COPY poetry.lock ./poetry.lock + +# Install the dependencies using Poetry +RUN poetry install --no-root + +# Copy the rest of the project into the container +COPY . . + +# Install the project using Poetry +RUN poetry install + +# Disable buffering as it may cause problems in logs +ENV PYTHONUNBUFFERED=1 + +# Tell Django where the settings module is +# I have no idea why this is needed +ENV DJANGO_SETTINGS_MODULE="sophon.settings" + +# Start the uvicorn server +ENTRYPOINT ["poetry", "run", "gunicorn", "sophon.asgi:application", "-k", "uvicorn.workers.UvicornWorker"]