1
0
kmahyyg 4 жил өмнө
parent
commit
d06c97367b
7 өөрчлөгдсөн 74 нэмэгдсэн , 4 устгасан
  1. 10 3
      Dockerfile
  2. 26 1
      README.md
  3. 5 0
      denv
  4. 3 0
      fileserv/go.mod
  5. 12 0
      fileserv/main.go
  6. 9 0
      start_ztncui.sh
  7. 9 0
      supervisord.conf

+ 10 - 3
Dockerfile

@@ -23,6 +23,7 @@ RUN apt update -y && \
 FROM golang:buster AS argong
 WORKDIR /buildsrc
 COPY argon2g ./
+COPY fileserv ./
 RUN mkdir -p binaries && \
     cd argon2g && \
     go mod download && \
@@ -36,7 +37,10 @@ RUN mkdir -p binaries && \
     git clone https://github.com/tianon/gosu && \
     cd gosu && \
     go mod download && \
-    go build -o ../binaries/gosu -ldflags='-s -w' -trimpath
+    go build -o ../binaries/gosu -ldflags='-s -w' -trimpath && \
+    cd .. && \
+    cd fileserv && \
+    go build -ldflags='-s -w' -trimpath -o ../binaries/fileserv main.go
 
 
 # START RUNNER
@@ -58,6 +62,7 @@ RUN unzip ./artifact.zip && \
 COPY --from=argong /buildsrc/binaries/gosu /bin/gosu
 COPY --from=argong /buildsrc/binaries/minica /usr/local/bin/minica
 COPY --from=argong /buildsrc/binaries/argon2g /usr/local/bin/argon2g
+COPY --from=argong /buildsrc/binaries/fileserv /usr/local/bin/gfileserv
 
 COPY start_zt1.sh /start_zt1.sh
 COPY start_ztncui.sh /start_ztncui.sh
@@ -66,10 +71,12 @@ COPY supervisord.conf /etc/supervisord.conf
 RUN chmod 4755 /bin/gosu && \
     chmod 0755 /usr/local/bin/minica && \
     chmod 0755 /usr/local/bin/argon2g && \
+    chmod 0755 /usr/local/bin/gfileserv && \
     chmod 0755 /start_*.sh
 
-EXPOSE 3000
-EXPOSE 9993
+EXPOSE 3000/tcp
+EXPOSE 9993/udp
+EXPOSE 3180/tcp
 
 VOLUME ["/opt/key-networks/ztncui/etc"]
 VOLUME [ "/var/lib/zerotier-one" ]

+ 26 - 1
README.md

@@ -1,8 +1,33 @@
 # ztncui-aio
 
 Licensed Under AGPL v3
-
 ## Usage
 
+```bash
+$ git clone https://github.com/kmahyyg/ztncui-aio # if you wanna use env file, you need to clone, else not.
+$ docker pull kmahyyg/ztncui-aio
+$ docker run -d -p3000:3000 -p9993:9993 -p3180:3180\
+    -v /mydata/ztncui:/opt/key-networks/ztncui/etc \
+    -v /mydata/zt1:/var/lib/zerotier-one \
+    --env-file ./denv <CHANGE HERE ACCORDING TO NEXT PART> \
+    kmahyyg/ztncui-aio
+```
+
 ## Supported Configuration via persistent storage
 
+For ZTNCUI: https://github.com/key-networks/ztncui
+
+| REQUIRED | Name | Explanation | Default Value |
+|  no  | HTTPS_HOST | Only Listen on HTTPS_HOST:HTTPS_PORT | NO DEFAULT |
+| no | HTTPS_PORT | HTTPS_PORT | 3443 |
+| no | HTTP_PORT | HTTP_PORT | 3000 |
+| no | HTTP_ALL_INTERFACES | Listen on all interfaces | NO DEFAULT |
+
+This image additional specific:
+
+| REQUIRED | Name | Explanation | Default Value |
+| no | MYDOMAIN | generate TLS certs on the fly (if not exists) | ztncui.docker.test |
+| no | ZTNCUI_PASSWD | generate admin password on the fly (if not exists) | password |
+| YES | MYADDR | your ip address, public ip address preferred | NO DEFAULT |
+
+Also, this image exposed an http server at port 3180, you could save file in `/mydata/ztncui/myfs/` to serve it. (You could use this to build your own root server and distribute planet file)

+ 5 - 0
denv

@@ -0,0 +1,5 @@
+HTTP_ALL_INTERFACES=yes
+HTTP_PORT=3000
+MYADDR=1.2.3.4
+ZTNCUI_PASSWD=Th1sPa55W0rd
+MYDOMAIN=ztncui.docker.test

+ 3 - 0
fileserv/go.mod

@@ -0,0 +1,3 @@
+module fileserv
+
+go 1.15

+ 12 - 0
fileserv/main.go

@@ -0,0 +1,12 @@
+package main
+
+import (
+	"log"
+	"net/http"
+)
+
+func main() {
+	var fs http.FileSystem = http.Dir("/opt/key-networks/ztncui/etc/myfs")
+	var fsHandler = http.FileServer(fs)
+	log.Fatal(http.ListenAndServe(":3180", fsHandler))
+}

+ 9 - 0
start_ztncui.sh

@@ -29,16 +29,24 @@ else
   [ ! -z $HTTPS_PORT ] && echo "HTTPS_PORT=$HTTPS_PORT" >> /opt/key-networks/ztncui/.env
 fi
 
+echo "ZTNCUI ENV CONFIGURATION: "
+cat ./.env
+echo "CURRENT CONTAINER ENV: "
+printenv
+
 mkdir -p etc/storage 
 mkdir -p etc/tls
+mkdir -p etc/myfs # for planet files
 
 if [ ! -f etc/passwd ]; then
+    echo "Default Password File Not Exists... Generating..."
     cd etc/passwd
     echo $ZTNCUI_PASSWD | /usr/bin/argon2g 
     cd ../../
 fi
 
 if [ ! -f etc/tls/fullchain.pem ] || [ ! -f etc/tls/privkey.pem ]; then
+    echo "Cannot detect TLS Certs, Generating..."
     cd etc/tls
     /usr/bin/minica -domains "$MYDOMAIN"
     cp -f "$MYDOMAIN/cert.pem" fullchain.pem
@@ -50,4 +58,5 @@ chown -R zerotier-one:zerotier-one /opt/key-networks/ztncui
 chmod 0755 /opt/key-networks/ztncui/ztncui
 chown root:root /opt/key-networks/ztncui/ztncui
 
+unset ZTNCUI_PASSWD
 gosu zerotier-one:zerotier-one /opt/key-networks/ztncui/ztncui

+ 9 - 0
supervisord.conf

@@ -15,3 +15,12 @@ startretries=3
 priority=10
 redirect_stderr=true
 stdout_logfile=/var/log/docker-ztncui.log
+
+[program:ztplaserv]
+command=/usr/local/bin/fileserv
+autostart=true
+startsecs=10
+startretries=3
+priority=15
+redirect_stderr=true
+stdout_logfile=/var/log/docker-ztplaserv.log