bhgi commited on
Commit
698084c
·
verified ·
1 Parent(s): f377d51

Follow linux.do tutorial

Browse files
Files changed (1) hide show
  1. Dockerfile +28 -9
Dockerfile CHANGED
@@ -1,11 +1,30 @@
1
- FROM openlistteam/openlist:v4.1.10
2
-
3
- EXPOSE 5244
4
-
5
- USER root
6
-
7
- RUN mkdir -p /opt/openlist/data && chmod 777 /opt/openlist/data
8
-
9
  WORKDIR /opt/openlist
 
 
10
 
11
- CMD ["./openlist", "server"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM openlistteam/openlist:latest
 
 
 
 
 
 
 
2
  WORKDIR /opt/openlist
3
+ USER root
4
+ EXPOSE 5244
5
 
6
+ CMD sh -c "\
7
+ ./openlist server & PID=$!; \
8
+ echo 'Starting...'; \
9
+ i=0; while ! wget -q --spider http://127.0.0.1:5244/api/public/settings; do \
10
+ sleep 2; i=$((i+1)); \
11
+ [ $i -ge 15 ] && echo 'Timeout' && kill $PID && exit 1; \
12
+ done; \
13
+ [ -z \"$OPENLIST_ADMIN_PASSWORD\" ] && echo 'No password' && exit 1; \
14
+ TOKEN=$(wget -qO- --post-data=\"{\\\"username\\\":\\\"admin\\\",\\\"password\\\":\\\"$OPENLIST_ADMIN_PASSWORD\\\"}\" \
15
+ --header='Content-Type: application/json' http://127.0.0.1:5244/api/auth/login 2>/dev/null | grep -o '\"token\":\"[^\"]*\"' | cut -d'\"' -f4); \
16
+ if [ ${#TOKEN} -gt 20 ]; then \
17
+ for n in 1 2 3 4 5 6 7 8 9 10; do \
18
+ BODY=$(printenv STORAGE_JSON_$n); \
19
+ [ -n \"$BODY\" ] || continue; \
20
+ echo \"$BODY\" > /tmp/p.json; \
21
+ if grep -q '\"mount_path\"' /tmp/p.json; then \
22
+ wget -qO- --post-file=/tmp/p.json \
23
+ --header=\"Content-Type: application/json\" \
24
+ --header=\"Authorization: $TOKEN\" \
25
+ http://127.0.0.1:5244/api/admin/storage/create 2>/dev/null; \
26
+ fi; \
27
+ rm -f /tmp/p.json; \
28
+ done; \
29
+ fi; \
30
+ wait $PID"