Download Dockerfile from zlcy/study: direct link, hf CLI and curl.
- Browser
- Download file 2.27 kB
-
https://huggingface.co/spaces/zlcy/study/resolve/main/Dockerfile
- Command line
-
hf download hf://spaces/zlcy/study/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/spaces/zlcy/study/resolve/main/Dockerfile
2.27 kB
| ARG BUILDPLATFORM | |
| ARG TARGETPLATFORM | |
| ARG TARGETARCH | |
| FROM --platform=$BUILDPLATFORM node:22-alpine AS web-build | |
| WORKDIR /app/web | |
| COPY web/package.json web/bun.lock ./ | |
| RUN npm install | |
| COPY VERSION /app/VERSION | |
| COPY CHANGELOG.md /app/CHANGELOG.md | |
| COPY web ./ | |
| RUN NEXT_PUBLIC_APP_VERSION="$(cat /app/VERSION)" npm run build | |
| FROM --platform=$TARGETPLATFORM python:3.13-slim AS app | |
| ARG TARGETPLATFORM | |
| ARG TARGETARCH | |
| ENV PYTHONDONTWRITEBYTECODE=1 \ | |
| PYTHONUNBUFFERED=1 \ | |
| UV_LINK_MODE=copy | |
| WORKDIR /app | |
| # 安装系统依赖 | |
| # - git: Git 存储后端需要 | |
| # - libpq-dev: PostgreSQL 客户端库 | |
| # - gcc: 编译 psycopg2-binary 需要 | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| git \ | |
| libpq-dev \ | |
| gcc \ | |
| openssl \ | |
| && rm -rf /var/lib/apt/lists/* | |
| RUN pip install --no-cache-dir uv | |
| COPY pyproject.toml uv.lock ./ | |
| RUN uv sync --frozen --no-dev --no-install-project | |
| COPY main.py ./ | |
| COPY VERSION ./ | |
| COPY api ./api | |
| COPY assets ./assets | |
| COPY services ./services | |
| COPY utils ./utils | |
| COPY scripts ./scripts | |
| COPY bundled_skills ./bundled_skills | |
| COPY --from=web-build /app/web/out ./web_dist | |
| RUN python - <<'PY' | |
| from __future__ import annotations | |
| import gzip | |
| from pathlib import Path | |
| root = Path("web_dist") | |
| suffixes = {".css", ".html", ".js", ".json", ".map", ".svg", ".txt", ".xml"} | |
| for path in root.rglob("*"): | |
| if not path.is_file() or path.suffix.lower() not in suffixes or path.stat().st_size < 1024: | |
| continue | |
| gz_path = path.with_name(f"{path.name}.gz") | |
| with path.open("rb") as source, gzip.open(gz_path, "wb", compresslevel=9) as target: | |
| target.writelines(source) | |
| PY | |
| EXPOSE 7860 | |
| # ⚠️ 必须显式写 --no-access-log:uvicorn 的 access log **默认就是开的**, | |
| # `--access-log` 只是把默认值写出来,删掉它等于没改(实测线上照旧 285 KB/s、1800 行/秒)。 | |
| # 容器只有 2 个共享 vCPU,每条请求都多一次格式化 + write 系统调用,且日志会被 HF 全量流出去。 | |
| # 注意 main.py 末尾的 uvicorn.run(access_log=False) 在线上**不会执行**(这里是 CLI 启动), | |
| # 所以只改 main.py 无效,必须在这里保持一致。 | |
| CMD ["uv", "run", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860", "--no-access-log"] | |