HongShi418 commited on
Commit
c848830
·
verified ·
1 Parent(s): ade1757

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +12 -61
Dockerfile CHANGED
@@ -1,75 +1,26 @@
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/openlist
26
 
27
- # Download the latest OpenList 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/openlist
31
-
32
- # Set up the environment
33
- RUN chmod +x $HOME/openlist/openlist && \
34
- mkdir -p $HOME/openlist/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/openlist/data/config.json
59
 
60
- # Create a startup script that runs OpenList and Aria2
61
- RUN echo '#!/bin/bash\n\
62
- sed -i "s/ENV_MYSQL_HOST/${MYSQL_HOST:-localhost}/g" $HOME/openlist/data/config.json\n\
63
- sed -i "s/ENV_MYSQL_PORT/${MYSQL_PORT:-3306}/g" $HOME/openlist/data/config.json\n\
64
- sed -i "s/ENV_MYSQL_USER/${MYSQL_USER:-root}/g" $HOME/openlist/data/config.json\n\
65
- sed -i "s/ENV_MYSQL_PASSWORD/${MYSQL_PASSWORD:-password}/g" $HOME/openlist/data/config.json\n\
66
- sed -i "s/ENV_MYSQL_DATABASE/${MYSQL_DATABASE:-openlist}/g" $HOME/openlist/data/config.json\n\
67
- aria2c --enable-rpc --rpc-listen-all --rpc-allow-origin-all --rpc-listen-port=6800 --daemon\n\
68
- $HOME/openlist/openlist server --data $HOME/openlist/data' > $HOME/openlist/start.sh && \
69
- chmod +x $HOME/openlist/start.sh
70
 
71
- # Set the command to run when the container starts
72
- CMD ["/bin/bash", "-c", "/home/user/openlist/start.sh"]
73
 
74
- # Expose the default OpenList port
75
- EXPOSE 5244 6800
 
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"]