Dockerfile 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. FROM debian:bullseye-slim AS builder
  2. ENV NODEJS_MAJOR=16
  3. ARG DEBIAN_FRONTEND=noninteractive
  4. LABEL MAINTAINER="Key Networks https://key-networks.com"
  5. LABEL Description="ztncui (a ZeroTier network controller user interface) + ZeroTier network controller"
  6. ADD VERSION .
  7. # BUILD ZTNCUI IN FIRST STAGE
  8. WORKDIR /build
  9. RUN apt update -y && \
  10. apt install curl gnupg2 ca-certificates zip unzip build-essential git --no-install-recommends -y && \
  11. curl -sL -o node_inst.sh https://deb.nodesource.com/setup_${NODEJS_MAJOR}.x && \
  12. bash node_inst.sh && \
  13. apt install -y nodejs --no-install-recommends && \
  14. rm -f node_inst.sh && \
  15. git clone https://github.com/key-networks/ztncui && \
  16. npm install -g node-gyp pkg && \
  17. cd ztncui/src && \
  18. git checkout -b "issue#98" && \
  19. npm install && \
  20. pkg -c ./package.json -t "node${NODEJS_MAJOR}-linux-x64" bin/www -o ztncui && \
  21. zip -r /build/artifact.zip ztncui node_modules/argon2/build/Release
  22. # BUILD GO UTILS
  23. FROM golang:bullseye AS argong
  24. WORKDIR /buildsrc
  25. COPY argon2g /buildsrc/argon2g
  26. COPY fileserv /buildsrc/fileserv
  27. ENV CGO_ENABLED=0
  28. RUN mkdir -p binaries && \
  29. cd argon2g && \
  30. go mod download && \
  31. go build -ldflags='-s -w' -trimpath -o ../binaries/argon2g && \
  32. cd .. && \
  33. git clone https://github.com/jsha/minica && \
  34. cd minica && \
  35. go mod download && \
  36. go build -ldflags='-s -w' -trimpath -o ../binaries/minica && \
  37. cd .. && \
  38. git clone https://github.com/tianon/gosu && \
  39. cd gosu && \
  40. go mod download && \
  41. go build -o ../binaries/gosu -ldflags='-s -w' -trimpath && \
  42. cd .. && \
  43. cd fileserv && \
  44. go build -ldflags='-s -w' -trimpath -o ../binaries/fileserv main.go
  45. # START RUNNER
  46. FROM debian:bullseye-slim AS runner
  47. RUN apt update -y && \
  48. apt install curl gnupg2 ca-certificates unzip supervisor net-tools procps --no-install-recommends -y && \
  49. groupadd -g 2222 zerotier-one && \
  50. useradd -u 2222 -g 2222 zerotier-one && \
  51. curl -sL -o ztone.sh https://install.zerotier.com && \
  52. bash ztone.sh && \
  53. rm -f ztone.sh && \
  54. apt clean -y && \
  55. rm -rf /var/lib/zerotier-one && \
  56. rm -rf /var/lib/apt/lists/*
  57. WORKDIR /opt/key-networks/ztncui
  58. COPY --from=builder /build/artifact.zip .
  59. RUN unzip ./artifact.zip && \
  60. rm -f ./artifact.zip
  61. COPY --from=argong /buildsrc/binaries/gosu /bin/gosu
  62. COPY --from=argong /buildsrc/binaries/minica /usr/local/bin/minica
  63. COPY --from=argong /buildsrc/binaries/argon2g /usr/local/bin/argon2g
  64. COPY --from=argong /buildsrc/binaries/fileserv /usr/local/bin/gfileserv
  65. COPY start_zt1.sh /start_zt1.sh
  66. COPY start_ztncui.sh /start_ztncui.sh
  67. COPY supervisord.conf /etc/supervisord.conf
  68. RUN chmod 0755 /bin/gosu && \
  69. chmod 0755 /usr/local/bin/minica && \
  70. chmod 0755 /usr/local/bin/argon2g && \
  71. chmod 0755 /usr/local/bin/gfileserv && \
  72. chmod 0755 /start_*.sh
  73. EXPOSE 3000/tcp
  74. EXPOSE 3180/tcp
  75. EXPOSE 8000/tcp
  76. EXPOSE 3443/tcp
  77. EXPOSE 9993/udp
  78. WORKDIR /
  79. VOLUME ["/opt/key-networks/ztncui/etc"]
  80. VOLUME [ "/var/lib/zerotier-one" ]
  81. ENTRYPOINT [ "/usr/bin/supervisord" ]