diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..6457f76 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,9 @@ +.git +.gitignore +.venv39 +venv +__pycache__ +*.pyc +*.pyo +*.pyd +db.sqlite3 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0f05eba --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +# Use official lightweight Python 3.11 image +FROM python:3.11-slim + +# Prevent Python from writing .pyc files and enable unbuffered logging +ENV PYTHONDONTWRITEBYTECODE=1 +ENV PYTHONUNBUFFERED=1 + +WORKDIR /app + +# Install system dependencies required for building wheels (mysqlclient, Pillow) +RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential \ + default-libmysqlclient-dev \ + pkg-config \ + libjpeg-dev \ + zlib1g-dev \ + && rm -rf /var/lib/apt/lists/* + +# Copy requirements and install +COPY requirements.txt /app/ +RUN pip install --no-cache-dir -r requirements.txt + +# Copy the rest of the backend code +COPY . /app/ + +EXPOSE 8000 + +# Run the development server +CMD ["python", "website/manage.py", "runserver", "0.0.0.0:8000"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..93f6a21 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,41 @@ +version: '3.8' + +services: + backend: + build: + context: . + dockerfile: Dockerfile + container_name: recursion-backend + ports: + - "8000:8000" + volumes: + # Mount the website folder to preserve the db.sqlite3 and allow hot-reloading + - ./website:/app/website + env_file: + - ./website/.env + environment: + # Override the host-specific database path to the container path + - DATABASE_URL=sqlite:////app/website/db.sqlite3 + - FRONTEND_BASE_URL=http://localhost:3000 + restart: always + + frontend: + build: + context: ../RECursionNITD-Frontend + dockerfile: Dockerfile + container_name: recursion-frontend + ports: + - "3000:3000" + volumes: + - ../RECursionNITD-Frontend/src:/app/src + - ../RECursionNITD-Frontend/public:/app/public + env_file: + - ../RECursionNITD-Frontend/.env + environment: + - REACT_APP_BACKEND_URL=http://localhost:8000 + # Required for Create React App to stay alive in Docker + stdin_open: true + tty: true + restart: always + depends_on: + - backend