Spaces:
Running
Running
FROM ubuntu:22.04 | |
# Install necessary tools | |
RUN apt-get update && apt-get install -y \ | |
tar \ | |
gzip \ | |
file \ | |
jq \ | |
curl \ | |
sed \ | |
aria2 \ | |
unzip \ | |
&& 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" user | |
USER user | |
# Set home to the user's home directory | |
ENV HOME=/home/user \ | |
PATH=/home/user/.local/bin:$PATH | |
# Set the working directory to the user's home directory | |
WORKDIR $HOME/alist | |
RUN mkdir -p $HOME/alist/data | |
COPY --chown=user . $HOME/alist | |
#use auto gen cfg file start | |
RUN --mount=type=secret,id=MYSQL_HOST,mode=0444,required=true \ | |
--mount=type=secret,id=MYSQL_PORT,mode=0444,required=true \ | |
--mount=type=secret,id=MYSQL_USER,mode=0444,required=true \ | |
--mount=type=secret,id=MYSQL_PASSWORD,mode=0444,required=true \ | |
--mount=type=secret,id=MYSQL_DATABASE,mode=0444,required=true \ | |
ENV_MYSQL_HOST=$(cat /run/secrets/MYSQL_HOST) && \ | |
ENV_MYSQL_PORT=$(cat /run/secrets/MYSQL_PORT) && \ | |
ENV_MYSQL_USER=$(cat /run/secrets/MYSQL_USER) && \ | |
ENV_MYSQL_PASSWORD=$(cat /run/secrets/MYSQL_PASSWORD) && \ | |
ENV_MYSQL_DATABASE=$(cat /run/secrets/MYSQL_DATABASE) && \ | |
echo "{\n\ | |
\"force\": false,\n\ | |
\"address\": \"0.0.0.0\",\n\ | |
\"port\": 5244,\n\ | |
\"scheme\": {\n\ | |
\"https\": false,\n\ | |
\"cert_file\": \"\",\n\ | |
\"key_file\": \"\"\n\ | |
},\n\ | |
\"cache\": {\n\ | |
\"expiration\": 60,\n\ | |
\"cleanup_interval\": 120\n\ | |
},\n\ | |
\"database\": {\n\ | |
\"type\": \"mysql\",\n\ | |
\"host\": \"$ENV_MYSQL_HOST\",\n\ | |
\"port\": $ENV_MYSQL_PORT,\n\ | |
\"user\": \"$ENV_MYSQL_USER\",\n\ | |
\"password\": \"$ENV_MYSQL_PASSWORD\",\n\ | |
\"name\": \"$ENV_MYSQL_DATABASE\"\n\ | |
}\n\ | |
}" > $HOME/alist/test.json | |
#RUN --mount=type=secret,id=MYSQL_HOST,mode=0444,required=true \ | |
# --mount=type=secret,id=MYSQL_PORT,mode=0444,required=true \ | |
# --mount=type=secret,id=MYSQL_USER,mode=0444,required=true \ | |
# --mount=type=secret,id=MYSQL_PASSWORD,mode=0444,required=true \ | |
# --mount=type=secret,id=MYSQL_DATABASE,mode=0444,required=true \ | |
# ENV_MYSQL_HOST=$(cat /run/secrets/MYSQL_HOST) && \ | |
# ENV_MYSQL_PORT=$(cat /run/secrets/MYSQL_PORT) && \ | |
# ENV_MYSQL_USER=$(cat /run/secrets/MYSQL_USER) && \ | |
# ENV_MYSQL_PASSWORD=$(cat /run/secrets/MYSQL_PASSWORD) && \ | |
# ENV_MYSQL_DATABASE=$(cat /run/secrets/MYSQL_DATABASE) && \ | |
# sed -i "s/MYSQL_HOST/${ENV_MYSQL_HOST:-localhost}/g" $HOME/alist/test.json && \ | |
# sed -i "s/MYSQL_PORT/${ENV_MYSQL_PORT:-3306}/g" $HOME/alist/test.json && \ | |
# sed -i "s/MYSQL_USER/${ENV_MYSQL_USER:-root}/g" $HOME/alist/test.json && \ | |
# sed -i "s/MYSQL_PASSWORD/${ENV_MYSQL_PASSWORD:-password}/g" $HOME/alist/test.json && \ | |
# sed -i "s/MYSQL_DATABASE/${ENV_MYSQL_PASSWORD:-alist}/g" $HOME/alist/test.json | |
RUN cp -f $HOME/alist/test.json $HOME/alist/data/config.json | |
#end | |
RUN chmod +x $HOME/alist/tvbox | |
# Create a startup script that runs Alist and Aria2 | |
RUN echo '#!/bin/bash\n\ | |
aria2c --enable-rpc --rpc-listen-all --rpc-allow-origin-all --rpc-listen-port=6800 --daemon\n\ | |
/home/user/alist/tvbox server --data /home/user/alist/data/' > $HOME/alist/start.sh && \ | |
chmod +x $HOME/alist/start.sh | |
# Set the command to run when the container starts | |
CMD ["/bin/bash", "-c", "/home/user/alist/start.sh"] | |
# Expose the default Alist port | |
EXPOSE 5244 6800 |