forked from NiuTrans/ToFu
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
Latest commit
65 lines (54 loc) · 3.54 KB
/
Copy pathDockerfile
File metadata and controls
65 lines (54 loc) · 3.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# ═══════════════════════════════════════════════════════════════
# Tofu (豆腐) — Docker Image
# ═══════════════════════════════════════════════════════════════
#
# Build: docker build -t tofu .
# Run: docker run -d -p 15000:15000 -v tofu-data:/app/data --name tofu tofu
#
# Or use docker-compose: docker compose up -d
#
# ═══════════════════════════════════════════════════════════════
FROM python:3.12-slim AS base
# ── System dependencies ─────────────────────────────────────
RUN apt-get update && apt-get install -y --no-install-recommends \
# Build tools for compiled Python packages
gcc g++ \
# Playwright / browser automation system deps
libnss3 libnspr4 libatk1.0-0 libatk-bridge2.0-0 \
libcups2 libdrm2 libxkbcommon0 libxcomposite1 \
libxdamage1 libxrandr2 libgbm1 libpango-1.0-0 \
libcairo2 libasound2 libxshmfence1 \
# Fast code search (ripgrep — 5x faster grep, fd-find — 3x faster find)
ripgrep fd-find \
# General utilities
curl ca-certificates git \
# Equal PostgreSQL backend ships its local server toolchain; any
# distro-created cluster is removed because live pgdata belongs only
# under /app/data and is initialized by the Storage Sidecar.
postgresql \
&& rm -rf /var/lib/postgresql/* /var/lib/apt/lists/*
# ── App directory ───────────────────────────────────────────
WORKDIR /app
# ── Python dependencies (cached layer) ──────────────────────
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# ── Playwright browser (optional — for advanced page fetching)
RUN python -m playwright install chromium --with-deps
# ── Copy application code ──────────────────────────────────
COPY . .
# ── Create runtime directories ─────────────────────────────
RUN mkdir -p /app/data /app/logs /app/uploads
# ── Environment defaults ───────────────────────────────────
ENV PORT=15000 \
BIND_HOST=0.0.0.0 \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1
# ── Expose port ────────────────────────────────────────────
EXPOSE 15000
# ── Health check ───────────────────────────────────────────
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
CMD curl -fsS http://localhost:15000/api/health || exit 1
# ── Entrypoint ─────────────────────────────────────────────
# SQLite defaults; exact TOFU_DB_BACKEND=postgres selects the equal PG backend.
ENV TOFU_SERVER_WORKER=1 TOFU_MANAGED_BY=docker
CMD ["python", "server.py"]