Files
autoclip/Dockerfile
5f8a24d9d6 v1.2.1 hotfix: make the Docker / local-script paths complete a full run (#88 ×7, #53) (#89)
* fix(docker): make the documented docker-compose path actually run

- .dockerignore: allow docker-entrypoint.sh / docker-dev-entrypoint.sh, which
  Dockerfile COPYs; excluding them made every 'docker build' fail (#1 #4 #9
  #47 #50 #88)
- add .gitattributes forcing LF on shell scripts so Windows clones can start
  the container (#73 #88)
- base image python:3.9-slim -> python:3.11-slim; current yt-dlp no longer
  supports 3.9 and only yields 360p via the android fallback (#88)
- celery worker in docker-compose / dev compose / start_autoclip.sh now
  consumes the queues task_routes actually targets
  (-Q celery,processing,video,notification,upload); without it tasks piled up
  in 'processing' and were never executed (#88)
- the four compose services share one image tag so it is built once
- docs: Python 3.10+ requirement, Linux bind-mount permission note

Co-authored-by: Kris K <zhouxiaoka@users.noreply.github.com>

* fix(backend): remove machine-specific paths and the Redis probe that failed every Docker project

- task_submission_utils: the queue-depth log after a successful send_task used
  redis.Redis(host='localhost') inside the try block, so under docker-compose
  (Redis at redis:6379) every project was marked failed right after being
  queued. Probe now uses REDIS_URL and only warns on failure (#88)
- youtube.py: yt-dlp was invoked via a hardcoded /Users/zhoukk venv path with
  a hardcoded cwd, so /parse returned 500 on every other machine. Use
  sys.executable -m yt_dlp with the data directory as cwd (#88)
- youtube.py: requesting five subtitle languages at once triggers HTTP 429 and
  aborts the download; default to zh-Hans,zh,en, overridable with
  AUTOCLIP_YT_SUBTITLE_LANGS (#88)
- llm_providers._build_full_input: JSON-serialise list/tuple input instead of
  str() so the scoring step no longer breaks on list payloads (#53)
- fix_project_thumbnails.py / SettingsPage.tsx: drop remaining hardcoded
  developer paths (the settings page was writing them into users'
  settings.json)
- delete backend/api/v1/youtube_improved.py (unreferenced)
- add regression tests for the submission path and input serialisation

Co-authored-by: Kris K <zhouxiaoka@users.noreply.github.com>

* ci: add docker-compose smoke job

Builds the image, starts redis + api + worker, and asserts: API health,
yt-dlp importable on the image's Python, Redis reachable through REDIS_URL
from the app container, and the worker consuming every routed queue
(celery, processing, video, notification, upload). Guards the failure modes
from #88 that nothing in CI previously exercised.

Co-authored-by: Kris K <zhouxiaoka@users.noreply.github.com>

* chore: bump desktop version to 1.2.1 and stop hardcoding app_version in the backend

Cargo.toml was still 1.1.0 while tauri.conf.json said 1.2.0. Align both (and
Cargo.lock) at 1.2.1. The Rust launcher now passes CARGO_PKG_VERSION to the
backend as AUTOCLIP_APP_VERSION so /settings reports the real version instead
of a fixed "1.0.0".

Co-authored-by: Kris K <zhouxiaoka@users.noreply.github.com>

* docs: 1.2.1 changelog; refresh HANDOFF with current status, PR/issue triage and plan

CHANGELOG 1.2.0 had absorbed old unreleased web-side items wholesale; keep
them but label them as historical. Fix the compare/release links that still
pointed at your-username.

Co-authored-by: Kris K <zhouxiaoka@users.noreply.github.com>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Kris K <zhouxiaoka@users.noreply.github.com>
2026-09-06 21:58:05 +08:00

108 lines
2.5 KiB
Docker
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# AutoClip Dockerfile
# 多阶段构建,优化镜像大小
# 第一阶段:构建前端
FROM node:18-slim AS frontend-builder
WORKDIR /app/frontend
# 安装必要的系统依赖
RUN apt-get update && apt-get install -y \
python3 \
make \
g++ \
&& rm -rf /var/lib/apt/lists/*
# 复制前端依赖文件
COPY frontend/package*.json ./
# 安装前端依赖(使用完整安装,包括devDependencies)
RUN npm ci
# 复制前端源代码
COPY frontend/ ./
# 构建前端
RUN npm run build
# 第二阶段:构建后端
# yt-dlp 已停止支持 Python 3.9(3.9 下 YouTube 提取只能靠 android client 回退,且仅有 360p)
FROM python:3.11-slim AS backend-builder
# 设置环境变量
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV PIP_NO_CACHE_DIR=1
ENV PIP_DISABLE_PIP_VERSION_CHECK=1
WORKDIR /app
# 安装系统依赖
RUN apt-get update && apt-get install -y \
build-essential \
curl \
ffmpeg \
&& rm -rf /var/lib/apt/lists/*
# 复制Python依赖文件
COPY requirements.txt ./
# 安装Python依赖
RUN pip install --no-cache-dir -r requirements.txt
# 第三阶段:最终镜像
FROM python:3.11-slim
# 设置环境变量
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONPATH=/app
# 创建非root用户
RUN groupadd -r autoclip && useradd -r -g autoclip autoclip
# 安装运行时依赖
RUN apt-get update && apt-get install -y \
ffmpeg \
curl \
&& rm -rf /var/lib/apt/lists/* \
&& apt-get clean
# 设置工作目录
WORKDIR /app
# 从构建阶段复制文件
COPY --from=backend-builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
COPY --from=backend-builder /usr/local/bin /usr/local/bin
COPY --from=frontend-builder /app/frontend/dist /app/frontend/dist
# 复制项目文件
COPY backend/ ./backend/
COPY scripts/ ./scripts/
COPY *.sh ./
COPY env.example .env
COPY docker-entrypoint.sh ./
# 创建必要的目录
RUN mkdir -p data/projects data/uploads data/temp data/output logs
# 设置权限
RUN chown -R autoclip:autoclip /app
RUN chmod +x *.sh
RUN chmod +x docker-entrypoint.sh
RUN chmod -R 755 data logs
# 切换到非root用户
USER autoclip
# 暴露端口
EXPOSE 8000 3000
# 健康检查
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8000/api/v1/health/ || exit 1
# 启动命令
ENTRYPOINT ["./docker-entrypoint.sh"]
CMD ["python", "-m", "uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port", "8000"]