Spaces:
Sleeping
Sleeping
Create Dockerfile
Browse files- Dockerfile +27 -0
Dockerfile
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 基础镜像:uv python3.12 轻量版
|
| 2 |
+
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim
|
| 3 |
+
|
| 4 |
+
# 1. 安装 git 并清理 apt 缓存,减少镜像体积
|
| 5 |
+
RUN apt-get update && \
|
| 6 |
+
apt-get install -y --no-install-recommends git && \
|
| 7 |
+
apt-get clean && \
|
| 8 |
+
rm -rf /var/lib/apt/lists/*
|
| 9 |
+
|
| 10 |
+
# 2. 克隆代码到 /app 目录(自动创建 /app,无需手动mkdir)
|
| 11 |
+
RUN git clone https://github.com/erxiansheng/gemininixiang.git /app
|
| 12 |
+
|
| 13 |
+
# 3. 创建缓存目录,使用合理权限(避免 777 宽松权限)
|
| 14 |
+
RUN mkdir /.cache && chmod -R 777 /.cache
|
| 15 |
+
|
| 16 |
+
# 5. 切换工作目录
|
| 17 |
+
WORKDIR /app
|
| 18 |
+
|
| 19 |
+
# 6. 暴露端口
|
| 20 |
+
EXPOSE 8000
|
| 21 |
+
|
| 22 |
+
# 7. 使用 uv 安装依赖(适配基础镜像,替代 pip)
|
| 23 |
+
# --no-cache-dir 进一步减少缓存文件,缩小镜像体积
|
| 24 |
+
RUN uv pip install --no-cache-dir -r requirements.txt
|
| 25 |
+
|
| 26 |
+
# 9. 启动命令
|
| 27 |
+
CMD ["python", "server.py"]
|