Spaces:
Running
Running
FROM dragon730/cloudpaste-backend:latest | |
# 设置工作目录 | |
WORKDIR /app | |
# 更新包并安装必要的系统级依赖 | |
# 包括 python3, py3-pip (用于pip), curl (用于WebDAV上传), bash (用于sync_data.sh的shebang), tar (用于打包解包) | |
RUN sed -i 's|https://mirrors.aliyun.com/alpine/latest-stable|https://dl-cdn.alpinelinux.org/alpine/latest-stable|g' /etc/apk/repositories && \ | |
apk update && \ | |
apk add --no-cache python3 py3-pip curl bash tar | |
# 创建Python虚拟环境并安装Python库依赖 | |
RUN python3 -m venv /app/venv && \ | |
/app/venv/bin/pip install --no-cache-dir webdavclient3 requests | |
# 复制同步脚本 | |
COPY sync_data.sh /app/sync_data.sh | |
# 设置权限 | |
RUN mkdir -p /data && \ | |
chmod 777 /data && \ | |
chmod +x /app/sync_data.sh | |
# 设置环境变量 | |
# ERROR: 0, WARN: 1, INFO: 2, DEBUG: 3, | |
ENV NODE_ENV=production | |
ENV LOG_LEVEL=2 | |
ENV RUNTIME_ENV=docker | |
ENV DATA_DIR=/data | |
ENV PORT=7860 | |
ENV ENCRYPTION_SECRET=PLEASE_CHANGE_THIS_IN_PRODUCTION | |
# 暴露端口 | |
EXPOSE 7860 | |
# 启动命令 | |
# 1. 启动 sync_data.sh 在后台 (&) | |
# 2. 使用 exec 启动 node server.js,使其成为容器的主进程 | |
CMD ["bash", "-c", "/app/sync_data.sh & exec node --expose-gc server.js"] | |