Browse Source

Added UP1 Docker Container

Tim Schuster 1 year ago
commit
67196c10f2
Signed by: Tim Schuster <mail@timschuster.info> GPG Key ID: F9E27097EFB77F61
2 changed files with 40 additions and 0 deletions
  1. 20
    0
      up1/Dockerfile
  2. 20
    0
      up1/start.sh

+ 20
- 0
up1/Dockerfile View File

@@ -0,0 +1,20 @@
1
+FROM node:alpine
2
+
3
+RUN apk --update add su-exec bash wget git unzip ca-certificates && \
4
+	cd / && git clone https://github.com/Upload/Up1 && \
5
+	cd /Up1/server && \
6
+	apk del wget unzip git && rm -rf /var/cache/apk/* && \
7
+	npm install
8
+	
9
+ADD start.sh /start.sh
10
+RUN chmod +x /start.sh
11
+
12
+EXPOSE 5000
13
+
14
+WORKDIR /Up1/server
15
+
16
+ENV NODE_ENV production
17
+
18
+ENTRYPOINT ["/start.sh"]
19
+
20
+CMD [""]

+ 20
- 0
up1/start.sh View File

@@ -0,0 +1,20 @@
1
+#!/bin/sh
2
+
3
+if [ ! -e /Up1/server/server.conf ]
4
+then
5
+        APIKEY=$(date +%s | md5sum | head -c 32)
6
+        sleep 5
7
+        DELETEKEY=$(date +%s | md5sum | head -c 32)
8
+        echo $APIKEY
9
+        echo $DELETEKEY
10
+
11
+        sed -re 's/"api_key": "c61540b5ceecd05092799f936e27755f"/"api_key": "'$APIKEY'"/;s/"delete_key": ""/"delete_key": "'$DELETEKEY'"/;s/"listen": ":80"/"listen": ":5000"/;s/"listen": ":443"/"listen": ":5443"/' server.conf.example > server.conf
12
+        sed "s/upload.config.api_key = '.*'/upload.config.api_key = '"$APIKEY"'/g" ../client/config.js.example > ../client/config.js
13
+        if [ -f certs/cert.pem ] && [ -f certs/key.pem ]
14
+        then
15
+                sed -ri 's#"cert": "./cert.pem"#"cert": "./certs/cert.pem"#;s#"key": "./key.pem"#"key": "./certs/key.pem"#;s#"enabled": false#"enabled": true#' server.conf
16
+        fi
17
+fi
18
+
19
+chown -R ${UID}:${GID} /Up1
20
+su-exec ${UID}:${GID} node server.js

Loading…
Cancel
Save