taito0 commited on
Commit
7c97dcf
·
verified ·
1 Parent(s): 7485f74

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +74 -0
Dockerfile ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ && rm -rf /var/lib/apt/lists/*
12
+
13
+ # Set up a new user named "user" with user ID 1000
14
+ RUN useradd -m -u 1000 user
15
+
16
+ # Switch to the "user" user
17
+ USER user
18
+
19
+ # Set home to the user's home directory
20
+ ENV HOME=/home/user \
21
+ PATH=/home/user/.local/bin:$PATH
22
+
23
+ # Set the working directory to the user's home directory
24
+ WORKDIR $HOME/alist
25
+
26
+ # Download the latest alist release
27
+ RUN curl -L $(curl -s https://api.github.com/repos/alist-org/alist/releases/latest | \
28
+ grep "browser_download_url.*linux-amd64.tar.gz" | \
29
+ cut -d '"' -f 4) | tar -zxvf - -C $HOME/alist
30
+
31
+ # Set up the environment
32
+ RUN chmod +x $HOME/alist/alist && \
33
+ mkdir -p $HOME/alist/data
34
+
35
+ # Create data/config.json file with database configuration
36
+ RUN echo '{\
37
+ "force": false,\
38
+ "address": "0.0.0.0",\
39
+ "port": 5244,\
40
+ "scheme": {\
41
+ "https": false,\
42
+ "cert_file": "",\
43
+ "key_file": ""\
44
+ },\
45
+ "cache": {\
46
+ "expiration": 60,\
47
+ "cleanup_interval": 120\
48
+ },\
49
+ "database": {\
50
+ "type": "ENV_Alist_DB_TYPE",\
51
+ "host": "ENV_Alist_DB_HOST",\
52
+ "port": ENV_Alist_DB_PORT,\
53
+ "user": "ENV_Alist_DB_USER",\
54
+ "password": "ENV_Alist_DB_PASSWORD",\
55
+ "name": "ENV_Alist_DB_NAME"\
56
+ }\
57
+ }' > $HOME/alist/data/config.json
58
+
59
+ # Create a startup script
60
+ RUN echo '#!/bin/bash\n\
61
+ sed -i "s/ENV_Alist_DB_TYPE/${Alist_DB_TYPE:-mysql}/g" $HOME/alist/data/config.json\n\
62
+ sed -i "s/ENV_Alist_DB_HOST/${Alist_DB_HOST:-localhost}/g" $HOME/alist/data/config.json\n\
63
+ sed -i "s/ENV_Alist_DB_PORT/${Alist_DB_PORT:-3306}/g" $HOME/alist/data/config.json\n\
64
+ sed -i "s/ENV_Alist_DB_USER/${Alist_DB_USER:-root}/g" $HOME/alist/data/config.json\n\
65
+ sed -i "s/ENV_Alist_DB_PASSWORD/${Alist_DB_PASSWORD:-password}/g" $HOME/alist/data/config.json\n\
66
+ sed -i "s/ENV_Alist_DB_NAME/${Alist_DB_NAME:-alist}/g" $HOME/alist/data/config.json\n\
67
+ $HOME/alist/alist server --data $HOME/alist/data' > $HOME/alist/start.sh && \
68
+ chmod +x $HOME/alist/start.sh
69
+
70
+ # Set the command to run when the container starts
71
+ CMD ["/bin/bash", "-c", "/home/user/alist/start.sh"]
72
+
73
+ # Expose the default Alist port
74
+ EXPOSE 5244