File size: 1,968 Bytes
c4a2bc9 76e5e24 c4a2bc9 967ac02 44d9312 76e5e24 4602151 76e5e24 4b8a47c 967ac02 76e5e24 967ac02 4b8a47c c4a2bc9 44d9312 76e5e24 3521d29 f25e67d 4602151 f25e67d 76e5e24 3521d29 f25e67d 44d9312 c4a2bc9 f25e67d c4a2bc9 f25e67d c4a2bc9 4b8a47c 4602151 76e5e24 44d9312 3521d29 4602151 4b8a47c 76e5e24 3521d29 4602151 76e5e24 3521d29 4602151 4b8a47c 967ac02 44d9312 3521d29 76e5e24 3521d29 76e5e24 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | # 基础镜像
FROM python:3.11-slim
# 环境变量
ENV DEBIAN_FRONTEND=noninteractive \
PYTHONUNBUFFERED=1 \
UV_SYSTEM_PYTHON=1
# 1. 安装系统依赖
RUN apt-get update && apt-get install -y \
curl \
git \
nginx \
build-essential \
python3-dev \
libgl1 \
libglib2.0-0 \
&& rm -rf /var/lib/apt/lists/*
# 2. 安装 Node.js 20
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
apt-get install -y nodejs
# 3. 安装 uv
RUN pip install --no-cache-dir uv
# 设置工作目录
WORKDIR /app
# 4. 拉取代码 (因为 Space 默认不包含代码,必须手动拉取)
RUN git clone https://github.com/666ghj/MiroFish.git /tmp/repo && \
cp -r /tmp/repo/* . && \
rm -rf /tmp/repo
# 5. 复制配置文件 (覆盖仓库里的配置)
COPY . .
# 6. 后端依赖安装 (关键修复步骤)
WORKDIR /app/backend
RUN rm -f uv.lock && \
if [ -f pyproject.toml ]; then \
echo "Found pyproject.toml, exporting requirements..."; \
# 导出带哈希的依赖列表
uv export --format requirements-txt --output-file export_req.txt; \
# [修复] 删除 '-e .' 这一行,解决 pip hash 冲突报错
sed -i '/^-e/d' export_req.txt; \
# 安装依赖
pip install --no-cache-dir -r export_req.txt; \
elif [ -f requirements.txt ]; then \
pip install --no-cache-dir -r requirements.txt; \
else \
echo "No dependencies found, skipping..."; \
fi
# 7. 前端依赖安装
WORKDIR /app/frontend
RUN npm install --legacy-peer-deps
# 8. Nginx 配置
RUN rm -f /etc/nginx/sites-enabled/default
COPY nginx.conf /etc/nginx/conf.d/default.conf
# 9. 启动脚本权限
WORKDIR /app
COPY start.sh .
RUN chmod +x start.sh
# 10. 权限放行
RUN chmod -R 777 /app && \
chmod -R 777 /var/log/nginx && \
chmod -R 777 /var/lib/nginx && \
mkdir -p /var/run/nginx && \
chmod -R 777 /var/run/nginx
EXPOSE 7860
CMD ["./start.sh"] |