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
.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/

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
# 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}"]