From 8ded3d2047599440112451c2fa40ebac6c2fb5fa Mon Sep 17 00:00:00 2001 From: Jonathan Inge Arvesen Folland Date: Mon, 3 Mar 2025 19:24:17 +0100 Subject: [PATCH] Update Dockerfile --- backend/Dockerfile | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index 58b9f17..d688af0 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,15 +1,22 @@ -# We Use an official Python runtime as a parent image +# Use an official Python runtime as a parent image FROM python:3.12-slim -# Allows docker to cache installed dependencies between builds -COPY requirements.txt requirements.txt -RUN pip install --no-cache-dir -r requirements.txt +# Set environment variables for better Python handling +ENV PYTHONUNBUFFERED 1 +ENV PYTHONDONTWRITEBYTECODE 1 -# Mounts the application code to the image -COPY . app +# Install dependencies +COPY requirements.txt /tmp/requirements.txt +RUN pip install --no-cache-dir -r /tmp/requirements.txt + +# Set the working directory in the container WORKDIR /app +# Copy the application code to the image +COPY . . + +# Expose the port that the app will run on EXPOSE 8000 -# Runs migrations and starts the production server -CMD ["sh", "-c", "python manage.py migrate && python manage.py runserver 0.0.0.0:8000"] \ No newline at end of file +# Run migrations and start the server +CMD ["sh", "-c", "python manage.py migrate && python manage.py runserver 0.0.0.0:8000"]