Files
bttoxin-pipeline/docker/dockerfiles/Dockerfile.traefik
zly e44692600c Fix(pipeline): optimize docker build, fix zip structure, and update UI
- Docker:
  - Explicitly install pixi environments (digger, pipeline, webbackend) during build to prevent runtime network/DNS failures.
  - Optimize pnpm config (copy method) to fix EAGAIN errors.
- Backend:
  - Refactor ZIP bundling: use flat semantic directories (1_Toxin_Mining, etc.).
  - Fix "nested zip" issue by cleaning existing archives before bundling.
  - Exclude raw 'context' directory from final download.
- Frontend:
  - Update TutorialView documentation to match new result structure.
  - Improve TaskMonitor progress bar precision (1 decimal place).
  - Update i18n (en/zh) for new file descriptions.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-21 20:43:28 +08:00

83 lines
2.7 KiB
Docker

# BtToxin Pipeline - Production Dockerfile
# Optimized for Traefik deployment with unified context
# ===========================
# Stage 1: Builder (Environment & Code)
# ===========================
FROM ghcr.io/prefix-dev/pixi:latest AS builder
WORKDIR /app
# Copy entire project context (filtered by .dockerignore)
COPY . .
# Install dependencies
RUN pixi install -e digger -e pipeline -e webbackend
# Setup external database for BtToxin_Digger
# Using the copy from tools directory included in COPY . .
RUN DIGGER_PREFIX=$(pixi info --json | grep -A 5 '"name": "digger"' | grep '"prefix":' | cut -d '"' -f 4) && \
mkdir -p $DIGGER_PREFIX/bin/BTTCMP_db/bt_toxin && \
rm -rf $DIGGER_PREFIX/bin/BTTCMP_db/bt_toxin/* && \
cp -r /app/tools/bttoxin_digger/external_dbs/bt_toxin/* $DIGGER_PREFIX/bin/BTTCMP_db/bt_toxin/ && \
echo "Overwrote internal database with version from external_dbs"
# Create shell hook for webbackend environment
RUN pixi shell-hook -e webbackend > /shell-hook.sh && \
echo 'exec "$@"' >> /shell-hook.sh
# ===========================
# Stage 2: Frontend Builder
# ===========================
FROM node:20 AS frontend-builder
WORKDIR /app
ENV CI=true
# Optimization: Copy package files first to leverage Docker cache
COPY frontend/package.json frontend/pnpm-lock.yaml* ./
# Optimization: Limit concurrency to avoid EAGAIN errors
RUN npm install -g pnpm && \
pnpm config set registry https://registry.npmmirror.com && \
pnpm config set network-concurrency 1 && \
pnpm config set package-import-method copy && \
pnpm install --no-frozen-lockfile
# Copy remaining source code
COPY frontend/ .
RUN pnpm build
# ===========================
# Stage 3: Production (Runtime)
# ===========================
FROM ghcr.io/prefix-dev/pixi:latest AS production
WORKDIR /app
# Install runtime dependencies
RUN apt-get clean && \
apt-get update -o Acquire::CompressionTypes::Order::=gz -o Acquire::http::No-Cache=True -o Acquire::http::Pipeline-Depth=0 && \
apt-get install -y --no-install-recommends \
curl \
&& rm -rf /var/lib/apt/lists/*
# Copy entire prepared application directory (Code + Environment + Data)
COPY --from=builder /app /app
# Copy shell hook
COPY --from=builder /shell-hook.sh /shell-hook.sh
# Copy built frontend assets
COPY --from=frontend-builder /app/dist /app/frontend/dist
# Set permissions and cleanup
RUN chmod -R 755 /app/frontend/dist && \
mkdir -p /app/jobs && chmod 777 /app/jobs
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8000/health || exit 1
ENTRYPOINT ["/bin/bash", "/shell-hook.sh"]
CMD ["uvicorn", "backend.app.main_spa:app", "--host", "0.0.0.0", "--port", "8000"]