|
FROM ubuntu:22.04 |
|
|
|
# Install necessary tools |
|
RUN apt-get update && apt-get install -y \ |
|
tar \ |
|
gzip \ |
|
file \ |
|
jq \ |
|
curl \ |
|
sed \ |
|
&& 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 |
|
|
|
# Download the latest alist release |
|
RUN curl -L $(curl -s https://api.github.com/repos/alist-org/alist/releases/latest | \ |
|
grep "browser_download_url.*linux-amd64.tar.gz" | \ |
|
cut -d '"' -f 4) | tar -zxvf - -C $HOME/alist |
|
|
|
# Set up the environment |
|
RUN chmod +x $HOME/alist/alist && \ |
|
mkdir -p $HOME/alist/data |
|
|
|
# Create data/config.json file with database configuration |
|
RUN 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": "ENV_Alist_DB_TYPE",\ |
|
"host": "ENV_Alist_DB_HOST",\ |
|
"port": ENV_Alist_DB_PORT,\ |
|
"user": "ENV_Alist_DB_USER",\ |
|
"password": "ENV_Alist_DB_PASSWORD",\ |
|
"name": "ENV_Alist_DB_NAME"\ |
|
}\ |
|
}' > $HOME/alist/data/config.json |
|
|
|
# Create a startup script |
|
RUN echo '#!/bin/bash\n\ |
|
sed -i "s/ENV_Alist_DB_TYPE/${Alist_DB_TYPE:-mysql}/g" $HOME/alist/data/config.json\n\ |
|
sed -i "s/ENV_Alist_DB_HOST/${Alist_DB_HOST:-localhost}/g" $HOME/alist/data/config.json\n\ |
|
sed -i "s/ENV_Alist_DB_PORT/${Alist_DB_PORT:-3306}/g" $HOME/alist/data/config.json\n\ |
|
sed -i "s/ENV_Alist_DB_USER/${Alist_DB_USER:-root}/g" $HOME/alist/data/config.json\n\ |
|
sed -i "s/ENV_Alist_DB_PASSWORD/${Alist_DB_PASSWORD:-password}/g" $HOME/alist/data/config.json\n\ |
|
sed -i "s/ENV_Alist_DB_NAME/${Alist_DB_NAME:-alist}/g" $HOME/alist/data/config.json\n\ |
|
$HOME/alist/alist server |
|
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 |