Spaces:
Running
Running
# 使用官方Ubuntu基础镜像 | |
FROM ubuntu:22.04 | |
EXPOSE 5244 | |
# 设置环境变量 | |
ENV TZ=Asia/Shanghai \ | |
APP_HOME=/OpenList \ | |
VIRTUAL_ENV=$APP_HOME/venv | |
# 设置时区 | |
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && \ | |
echo $TZ > /etc/timezone | |
# 安装系统依赖(包括python3-venv) | |
RUN apt-get update && \ | |
apt-get install -y wget tar python3 python3-pip python3-venv && \ | |
rm -rf /var/lib/apt/lists/* | |
# 创建应用目录 | |
WORKDIR $APP_HOME | |
# 设置虚拟环境和安装Python依赖 | |
RUN python3 -m venv $VIRTUAL_ENV && \ | |
. $VIRTUAL_ENV/bin/activate && \ | |
pip install --no-cache-dir --upgrade pip setuptools wheel && \ | |
pip install --no-cache-dir huggingface_hub | |
# 下载并解压 OpenList | |
RUN wget -q https://github.com/OpenListTeam/OpenList/releases/download/beta/openlist-linux-amd64.tar.gz && \ | |
tar -xzf openlist-linux-amd64.tar.gz && \ | |
find . -type f -name "openlist" -exec mv {} . \; && \ | |
rm -rf openlist-linux-amd64.tar.gz *linux-amd64* | |
# 创建数据目录并设置权限 | |
RUN mkdir -p $APP_HOME/data && \ | |
chmod -R 777 $APP_HOME/data | |
# 复制并设置脚本权限 | |
COPY sync_data.sh ./ | |
RUN chmod +x openlist sync_data.sh | |
# 设置非root用户运行 | |
RUN useradd -m openlistuser && \ | |
chown -R openlistuser:openlistuser $APP_HOME | |
USER openlistuser | |
# 启动服务 | |
CMD ./sync_data.sh && ./openlist server |