Download agy2api/Dockerfile from a3216/ds2api: direct link, hf CLI and curl.
- Browser
- Download file 1.27 kB
-
https://huggingface.co/spaces/a3216/ds2api/resolve/main/agy2api/Dockerfile
- Command line
-
hf download hf://spaces/a3216/ds2api/agy2api/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/spaces/a3216/ds2api/resolve/main/agy2api/Dockerfile
1.27 kB
| # Multi-stage build for agy2api | |
| FROM python:3.13-slim as base | |
| # Set environment variables | |
| ENV PYTHONUNBUFFERED=1 \ | |
| PYTHONDONTWRITEBYTECODE=1 \ | |
| PIP_NO_CACHE_DIR=1 \ | |
| PIP_DISABLE_PIP_VERSION_CHECK=1 \ | |
| TZ=Asia/Shanghai | |
| # Install tzdata, jemalloc and set timezone | |
| # jemalloc 替代 glibc malloc,大幅减少内存碎片化 | |
| RUN apt-get update && \ | |
| apt-get install -y --no-install-recommends tzdata libjemalloc2 && \ | |
| ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \ | |
| echo "Asia/Shanghai" > /etc/timezone && \ | |
| apt-get clean && \ | |
| rm -rf /var/lib/apt/lists/* | |
| # 使用 jemalloc 替代 glibc malloc | |
| # jemalloc 会主动将空闲内存归还给操作系统,避免 RSS 持续增长 | |
| ENV LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.2 | |
| # jemalloc 配置:启用后台线程回收、脏页衰减时间 5 秒(默认 10 秒) | |
| ENV MALLOC_CONF="background_thread:true,dirty_decay_ms:5000,muzzy_decay_ms:5000" | |
| WORKDIR /app | |
| # Copy only requirements first for better caching | |
| COPY requirements.txt . | |
| # Install Python dependencies | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy application code | |
| COPY . . | |
| # Expose port | |
| EXPOSE 7861 | |
| # 通过 web.py 启动,使 HOST/PORT 环境变量生效 | |
| CMD ["python", "web.py"] | |