From f979403d7efa35c7882c58d8703054bc9d1881af Mon Sep 17 00:00:00 2001 From: Jonathan Inge Arvesen Folland Date: Mon, 3 Mar 2025 21:33:33 +0100 Subject: [PATCH] Update Dockerfile --- backend/Dockerfile | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index d688af0..1884a5f 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,22 +1,15 @@ -# Use an official Python runtime as a parent image +# We Use an official Python runtime as a parent image FROM python:3.12-slim -# Set environment variables for better Python handling -ENV PYTHONUNBUFFERED 1 -ENV PYTHONDONTWRITEBYTECODE 1 +# Allows docker to cache installed dependencies between builds +COPY requirements.txt requirements.txt +RUN pip install --no-cache-dir -r requirements.txt -# 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 +# Mounts the application code to the image +COPY . app WORKDIR /app -# Copy the application code to the image -COPY . . - -# Expose the port that the app will run on EXPOSE 8000 -# Run migrations and start the server +# Runs migrations and starts the production server CMD ["sh", "-c", "python manage.py migrate && python manage.py runserver 0.0.0.0:8000"]