Spaces:
Paused
Paused
Update Dockerfile
Browse files123345678910115671489161710192021112223241213271415163031323334353637383940414243444546474849505152535455565758171860616263646566676869192021717222232474752526FROM ubuntu:22.04
# Install necessary tools# 安装依赖RUN apt-get update && apt-get install -y \ tar \ gzip \ file \ jq \ curl \ sed \ aria2 \ curl tar gzip jq aria2 \ && rm -rf /var/lib/apt/lists/*
# Set up a new user named "user" with user ID 1000# 创建用户RUN useradd -m -u 1000 user
# Switch to the "user" userUSER user
# Set home to the user's home directoryENV HOME=/home/user \ENV HOME=/home/user PATH=/home/user/.local/bin:$PATH
# Set the working directory to the user's home directoryWORKDIR $HOME/openlist
# Download the latest OpenList release using jq for robustness# 下载 OpenList 最新版本RUN curl -sL https://api.github.com/repos/openlistteam/openlist/releases/latest | \ jq -r '.assets[] | select(.name | test("linux-amd64.tar.gz$")) | .browser_download_url' | \ xargs curl -L | tar -zxvf - -C $HOME/openlist
# Set up the environmentRUN chmod +x $HOME/openlist/openlist && \ mkdir -p $HOME/openlist/data
# Create data/config.json file with database configurationRUN echo '{\ "force": false,\ "address": "0.0.0.0",\ "port": 5244,\ "scheme": {\ "https": false,\ "cert_file": "",\ "key_file": ""\ },\ "cache": {\ "expiration": 60,\ "cleanup_interval": 120\ },\ "database": {\ "type": "mysql",\ "host": "ENV_MYSQL_HOST",\ "port": 3306,\ "user": "ENV_MYSQL_USER",\ "password": "ENV_MYSQL_PASSWORD",\ "name": "ENV_MYSQL_DATABASE"\ }\}' > $HOME/openlist/data/config.json xargs curl -L | tar -zxvf - -C .
# Create a startup script that runs OpenList and Aria2RUN echo '#!/bin/bash\n\sed -i "s/ENV_MYSQL_HOST/${MYSQL_HOST:-localhost}/g" $HOME/openlist/data/config.json\n\sed -i "s/ENV_MYSQL_PORT/${MYSQL_PORT:-3306}/g" $HOME/openlist/data/config.json\n\sed -i "s/ENV_MYSQL_USER/${MYSQL_USER:-root}/g" $HOME/openlist/data/config.json\n\sed -i "s/ENV_MYSQL_PASSWORD/${MYSQL_PASSWORD:-password}/g" $HOME/openlist/data/config.json\n\sed -i "s/ENV_MYSQL_DATABASE/${MYSQL_DATABASE:-openlist}/g" $HOME/openlist/data/config.json\n\aria2c --enable-rpc --rpc-listen-all --rpc-allow-origin-all --rpc-listen-port=6800 --daemon\n\$HOME/openlist/openlist server --data $HOME/openlist/data' > $HOME/openlist/start.sh && \ chmod +x $HOME/openlist/start.sh# 设置权限RUN chmod +x openlist
# Set the command to run when the container startsCMD ["/bin/bash", "-c", "/home/user/openlist/start.sh"]# 复制配置文件COPY --chown=user:user data/config.json data/config.json
# Expose the default OpenList portEXPOSE 5244 6800# 启动命令CMD ["./openlist", "server", "--data", "./data"]Dockerfile+12-61