From 01caf393aa43493058723eea2543f67dcbeb16bb Mon Sep 17 00:00:00 2001 From: MarkLo Date: Sat, 20 Dec 2025 08:23:15 +0800 Subject: [PATCH] --- .dockerignore | 31 ++++++++++++++++++++++++++++--- backend/Dockerfile | 20 +++++++++++++------- 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/.dockerignore b/.dockerignore index e07b5138..1f4e7868 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,12 +2,15 @@ .git .gitignore -# Ignore backend files from root - +# Ignore frontend files (not needed for backend) +frontend/node_modules +frontend/.next +frontend/out +frontend/.turbo # Ignore documentation README.md -*.md +docs/ # Ignore results and cache results/ @@ -17,10 +20,13 @@ __pycache__/ *.pyd .pytest_cache/ .coverage +.mypy_cache/ +.ruff_cache/ # Environment files .env .env.* +!.env.example # Ignore development files .vscode/ @@ -30,3 +36,22 @@ __pycache__/ # Ignore Mac files .DS_Store + +# Ignore test files +**/tests/ +**/test_*.py +**/*_test.py + +# Ignore assets not needed for backend +assets/ +web_screenshot/ +llm_logo/ +report/ + +# Ignore lock files (use requirements.txt) +uv.lock +poetry.lock + +# Ignore CLI (if not needed) +cli/ + diff --git a/backend/Dockerfile b/backend/Dockerfile index e04e7bbc..bb0a4901 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,21 +1,28 @@ -# Multi-stage build for FastAPI backend +# syntax=docker/dockerfile:1.4 +# Multi-stage build for FastAPI backend with optimized caching + FROM python:3.11-slim as builder # Set working directory WORKDIR /app -# Install system dependencies +# Install system dependencies (cached layer) RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ git \ && rm -rf /var/lib/apt/lists/* -# Copy requirements from backend directory +# Upgrade pip once (cached layer) +RUN pip install --no-cache-dir --upgrade pip + +# Copy ONLY requirements first for better layer caching +# This layer only rebuilds when requirements.txt changes COPY backend/requirements.txt . -# Install Python dependencies -RUN pip install --no-cache-dir --upgrade pip && \ - pip install --no-cache-dir -r requirements.txt +# Install Python dependencies with BuildKit cache mount +# This caches downloaded packages between builds, dramatically speeding up rebuilds +RUN --mount=type=cache,target=/root/.cache/pip \ + pip install --prefer-binary -r requirements.txt # Production stage FROM python:3.11-slim @@ -41,7 +48,6 @@ RUN mkdir -p /app/results # Expose port EXPOSE 8000 -# Run the application # Run the application using the PORT environment variable (required by Railway) # Using --reload false to prevent hot-reload issues in production CMD ["sh", "-c", "python -m backend --reload false --port ${PORT:-8000}"]