Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ FROM python:3.9
WORKDIR /app/backend

COPY requirements.txt /app/backend

RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y gcc default-libmysqlclient-dev pkg-config \
&& rm -rf /var/lib/apt/lists/*


# Install app dependencies
# Install dependencies
RUN pip install mysqlclient
RUN pip install --no-cache-dir -r requirements.txt

COPY . /app/backend

EXPOSE 8000
#RUN python manage.py migrate
#RUN python manage.py makemigrations

CMD ["python3", "manage.py", "runserver", "0.0.0.0:8000"]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Production-unsafe: Django development server should not be used in containerized/production environments.

The runserver command is Django's development server and has significant security, performance, and stability limitations. It should only be used during local development and never in production, staging, or any other non-local environment.

For containerized deployments, use a production WSGI application server such as:

  • Gunicorn (most common)
  • uWSGI
  • Waitress
  • Daphne (for async apps)

Recommended fix using Gunicorn:

First, add gunicorn to requirements.txt, then update the CMD:

-CMD ["python3", "manage.py", "runserver", "0.0.0.0:8000"]
+CMD ["gunicorn", "your_project_name.wsgi:application", "--bind", "0.0.0.0:8000", "--workers", "4"]

Replace your_project_name with your actual Django project name.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In Dockerfile around line 20, the image currently uses Django's development
server via CMD ["python3", "manage.py", "runserver", "0.0.0.0:8000"], which is
unsafe for production; switch to a production WSGI server by adding gunicorn to
requirements.txt and replacing the CMD to run gunicorn for your Django project
(use your Django project module name, bind to 0.0.0.0:8000, set a sensible
worker count and timeout, and optionally set --chdir to the project directory).
Ensure the Dockerfile exposes the port and that the ENTRYPOINT/CMD runs gunicorn
with the correct module path (e.g., your_project_name.wsgi:application),
worker/options configured for the container, and that gunicorn is installed in
the image.