edwagbb commited on
Commit
7ff3af3
·
verified ·
1 Parent(s): 955ad1f

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +72 -0
Dockerfile ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/alist-org/alist/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
+ CMD echo '{\
38
+ "force": false,\
39
+ "address": "0.0.0.0",\
40
+ "port": 7860,\
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": ENV_MYSQL_PORT,\
54
+ "user": "ENV_MYSQL_USER",\
55
+ "password": "ENV_MYSQL_PASSWORD",\
56
+ "name": "ENV_MYSQL_DATABASE"\
57
+ }\
58
+ }' > $HOME/alist/data/config.json && \
59
+ echo '#!/bin/bash\n\
60
+ sed -i "s/ENV_MYSQL_HOST/${MYSQL_HOST:-localhost}/g" $HOME/alist/data/config.json\n\
61
+ sed -i "s/ENV_MYSQL_PORT/${MYSQL_PORT:-3306}/g" $HOME/alist/data/config.json\n\
62
+ sed -i "s/ENV_MYSQL_USER/${MYSQL_USER:-root}/g" $HOME/alist/data/config.json\n\
63
+ sed -i "s/ENV_MYSQL_PASSWORD/${MYSQL_PASSWORD:-password}/g" $HOME/alist/data/config.json\n\
64
+ sed -i "s/ENV_MYSQL_DATABASE/${MYSQL_DATABASE:-alist}/g" $HOME/alist/data/config.json\n\
65
+ aria2c --enable-rpc --rpc-listen-all --rpc-allow-origin-all --rpc-listen-port=6800 --daemon\n\
66
+ $HOME/alist/alist server --data $HOME/alist/data' > $HOME/alist/start.sh && \
67
+ chmod +x $HOME/alist/start.sh &&\
68
+ /bin/bash -c "/home/user/alist/start.sh"
69
+
70
+ # Expose the default Alist port
71
+ EXPOSE 7860
72
+ #5244 6800