HongShi418 commited on
Commit
518a4a2
·
verified ·
1 Parent(s): e94231e

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +62 -13
Dockerfile CHANGED
@@ -1,26 +1,75 @@
1
  FROM ubuntu:22.04
2
 
3
- # 安装依赖
4
  RUN apt-get update && apt-get install -y \
5
- curl tar gzip jq aria2 \
 
 
 
 
 
 
6
  && rm -rf /var/lib/apt/lists/*
7
 
8
- # 创建用户
9
  RUN useradd -m -u 1000 user
 
 
10
  USER user
11
- ENV HOME=/home/user
12
- WORKDIR $HOME/openlist
13
 
14
- # 下载 OpenList 最新版本
 
 
 
 
 
 
 
15
  RUN curl -sL https://api.github.com/repos/openlistteam/openlist/releases/latest | \
16
  jq -r '.assets[] | select(.name | test("linux-amd64.tar.gz$")) | .browser_download_url' | \
17
- xargs curl -L | tar -zxvf - -C .
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
 
19
- # 设置权限
20
- RUN chmod +x openlist
 
 
 
 
 
 
 
 
21
 
22
- # 复制配置文件
23
- COPY --chown=user:user data/config.json data/config.json
24
 
25
- # 启动命令
26
- CMD ["./openlist", "server", "--data", "./data"]
 
1
  FROM ubuntu:22.04
2
 
3
+ # Install necessary tools
4
  RUN apt-get update && apt-get install -y \
5
+ tar \
6
+ gzip \
7
+ file \
8
+ jq \
9
+ curl \
10
+ sed \
11
+ aria2 \
12
  && rm -rf /var/lib/apt/lists/*
13
 
14
+ # Set up a new user named "user" with user ID 1000
15
  RUN useradd -m -u 1000 user
16
+
17
+ # Switch to the "user" user
18
  USER user
 
 
19
 
20
+ # Set home to the user's home directory
21
+ ENV HOME=/home/user \
22
+ PATH=/home/user/.local/bin:$PATH
23
+
24
+ # Set the working directory to the user's home directory
25
+ WORKDIR $HOME/alist
26
+
27
+ # Download the latest alist release using jq for robustness
28
  RUN curl -sL https://api.github.com/repos/openlistteam/openlist/releases/latest | \
29
  jq -r '.assets[] | select(.name | test("linux-amd64.tar.gz$")) | .browser_download_url' | \
30
+ xargs curl -L | tar -zxvf - -C $HOME/alist
31
+
32
+ # Set up the environment
33
+ RUN chmod +x $HOME/alist/alist && \
34
+ mkdir -p $HOME/alist/data
35
+
36
+ # Create data/config.json file with database configuration
37
+ RUN echo '{\
38
+ "force": false,\
39
+ "address": "0.0.0.0",\
40
+ "port": 5244,\
41
+ "scheme": {\
42
+ "https": false,\
43
+ "cert_file": "",\
44
+ "key_file": ""\
45
+ },\
46
+ "cache": {\
47
+ "expiration": 60,\
48
+ "cleanup_interval": 120\
49
+ },\
50
+ "database": {\
51
+ "type": "mysql",\
52
+ "host": "ENV_MYSQL_HOST",\
53
+ "port": 3306,\
54
+ "user": "ENV_MYSQL_USER",\
55
+ "password": "ENV_MYSQL_PASSWORD",\
56
+ "name": "ENV_MYSQL_DATABASE"\
57
+ }\
58
+ }' > $HOME/alist/data/config.json
59
 
60
+ # Create a startup script that runs Alist and Aria2
61
+ RUN echo '#!/bin/bash\n\
62
+ sed -i "s/ENV_MYSQL_HOST/${MYSQL_HOST:-localhost}/g" $HOME/alist/data/config.json\n\
63
+ sed -i "s/ENV_MYSQL_PORT/${MYSQL_PORT:-3306}/g" $HOME/alist/data/config.json\n\
64
+ sed -i "s/ENV_MYSQL_USER/${MYSQL_USER:-root}/g" $HOME/alist/data/config.json\n\
65
+ sed -i "s/ENV_MYSQL_PASSWORD/${MYSQL_PASSWORD:-password}/g" $HOME/alist/data/config.json\n\
66
+ sed -i "s/ENV_MYSQL_DATABASE/${MYSQL_DATABASE:-alist}/g" $HOME/alist/data/config.json\n\
67
+ aria2c --enable-rpc --rpc-listen-all --rpc-allow-origin-all --rpc-listen-port=6800 --daemon\n\
68
+ $HOME/alist/alist server --data $HOME/alist/data' > $HOME/alist/start.sh && \
69
+ chmod +x $HOME/alist/start.sh
70
 
71
+ # Set the command to run when the container starts
72
+ CMD ["/bin/bash", "-c", "/home/user/alist/start.sh"]
73
 
74
+ # Expose the default Alist port
75
+ EXPOSE 5244 6800