version: "3.9" services: build-exe: image: python:3.11-slim working_dir: /app volumes: - .:/app # 使用 PyInstaller 生成单文件可执行程序,输出在 ./dist command: > bash -lc "\ python --version && \ apt-get update && apt-get install -y --no-install-recommends binutils && \ pip install --no-cache-dir pyinstaller && \ pyinstaller --onefile --name update_tags update_tags.py && \ ls -lah dist \ " restart: "no" # 可选:清理构建产物 clean: image: alpine:3.19 working_dir: /app volumes: - .:/app command: sh -c "rm -rf build dist __pycache__ *.spec" restart: "no"