From 147a90b2c20e756713ddc8cc9cdb835b304fc08d Mon Sep 17 00:00:00 2001 From: saiusesgithub Date: Mon, 26 Jan 2026 14:26:16 +0530 Subject: [PATCH] dockerized the project --- .dockerignore | 37 +++++++++++++++++++++++++++++++++++++ README.md | 12 +++++++++++- backend/Dockerfile | 27 +++++++++++++++++++++++++++ docker-compose.yml | 21 +++++++++++++++++++++ 4 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 .dockerignore create mode 100644 backend/Dockerfile create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..9b38ecd --- /dev/null +++ b/.dockerignore @@ -0,0 +1,37 @@ +# Git +.git +.gitignore + +# Node +node_modules +npm-debug.log +dist +coverage + +# Python +__pycache__ +*.pyc +*.pyo +*.pyd +.Python +env +venv +pip-log.txt +pip-delete-this-directory.txt +.tox +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.log +.pytest_cache + +# Docker +docker-compose.yml +Dockerfile +.dockerignore + +# Environment +.env diff --git a/README.md b/README.md index 3f7d51f..3fde6af 100644 --- a/README.md +++ b/README.md @@ -352,7 +352,17 @@ This section explains how to run Coderrr locally from source for development or git clone https://github.com/Akash-nath29/Coderrr.git cd Coderrr ``` -### 2. Backend Setup (FastAPI) +### 2. Backend Setup +You can run the backend using Docker (recommended) or set it up manually. + +#### Option A: Docker (Recommended) + +```bash +docker compose up --build +``` +The backend will be started at `http://localhost:5000` with hot-reloading enabled. + +#### Option B: Manual Setup (FastAPI) ```bash cd backend diff --git a/backend/Dockerfile b/backend/Dockerfile new file mode 100644 index 0000000..fade26e --- /dev/null +++ b/backend/Dockerfile @@ -0,0 +1,27 @@ +# Use official Python 3.11 slim image +FROM python:3.11-slim + +# Set working directory +WORKDIR /app + +# Set environment variables +ENV PYTHONDONTWRITEBYTECODE=1 \ + PYTHONUNBUFFERED=1 + +# Install system dependencies (if any needed, e.g. for build tools) +# RUN apt-get update && apt-get install -y --no-install-recommends gcc && rm -rf /var/lib/apt/lists/* + +# Copy requirements first to leverage cache +COPY requirements.txt . + +# Install Python dependencies +RUN pip install --no-cache-dir -r requirements.txt + +# Copy application code +COPY . . + +# Expose the API port +EXPOSE 5000 + +# Run the application +CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "5000"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..d60ebf6 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,21 @@ + + +services: + backend: + build: + context: ./backend + dockerfile: Dockerfile + container_name: coderrr-backend + ports: + - "5000:5000" + volumes: + - ./backend:/app + environment: + - HOST=0.0.0.0 + - PORT=5000 + # Load environment variables from .env file if it exists + env_file: + - .env + # Override command to enable hot reloading for development + command: uvicorn main:app --host 0.0.0.0 --port 5000 --reload + restart: unless-stopped