This commit is contained in:
MarkLo 2025-12-20 08:23:15 +08:00
parent 95b456faf7
commit 01caf393aa
2 changed files with 41 additions and 10 deletions

View File

@ -2,12 +2,15 @@
.git .git
.gitignore .gitignore
# Ignore backend files from root # Ignore frontend files (not needed for backend)
frontend/node_modules
frontend/.next
frontend/out
frontend/.turbo
# Ignore documentation # Ignore documentation
README.md README.md
*.md docs/
# Ignore results and cache # Ignore results and cache
results/ results/
@ -17,10 +20,13 @@ __pycache__/
*.pyd *.pyd
.pytest_cache/ .pytest_cache/
.coverage .coverage
.mypy_cache/
.ruff_cache/
# Environment files # Environment files
.env .env
.env.* .env.*
!.env.example
# Ignore development files # Ignore development files
.vscode/ .vscode/
@ -30,3 +36,22 @@ __pycache__/
# Ignore Mac files # Ignore Mac files
.DS_Store .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/

View File

@ -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 FROM python:3.11-slim as builder
# Set working directory # Set working directory
WORKDIR /app WORKDIR /app
# Install system dependencies # Install system dependencies (cached layer)
RUN apt-get update && apt-get install -y --no-install-recommends \ RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \ build-essential \
git \ git \
&& rm -rf /var/lib/apt/lists/* && 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 . COPY backend/requirements.txt .
# Install Python dependencies # Install Python dependencies with BuildKit cache mount
RUN pip install --no-cache-dir --upgrade pip && \ # This caches downloaded packages between builds, dramatically speeding up rebuilds
pip install --no-cache-dir -r requirements.txt RUN --mount=type=cache,target=/root/.cache/pip \
pip install --prefer-binary -r requirements.txt
# Production stage # Production stage
FROM python:3.11-slim FROM python:3.11-slim
@ -41,7 +48,6 @@ RUN mkdir -p /app/results
# Expose port # Expose port
EXPOSE 8000 EXPOSE 8000
# Run the application
# Run the application using the PORT environment variable (required by Railway) # Run the application using the PORT environment variable (required by Railway)
# Using --reload false to prevent hot-reload issues in production # Using --reload false to prevent hot-reload issues in production
CMD ["sh", "-c", "python -m backend --reload false --port ${PORT:-8000}"] CMD ["sh", "-c", "python -m backend --reload false --port ${PORT:-8000}"]