Dockerfile 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. npm install && \
  19. pkg -c ./package.json -t "node${NODEJS_MAJOR}-linux-x64" bin/www -o ztncui && \
  20. zip -r /build/artifact.zip ztncui node_modules/argon2/build/Release
  21. # BUILD GO UTILS
  22. FROM golang:bullseye AS argong
  23. WORKDIR /buildsrc
  24. COPY argon2g /buildsrc/argon2g
  25. COPY fileserv /buildsrc/fileserv
  26. ENV CGO_ENABLED=0
  27. RUN mkdir -p binaries && \
  28. cd argon2g && \
  29. go mod download && \
  30. go build -ldflags='-s -w' -trimpath -o ../binaries/argon2g && \
  31. cd .. && \
  32. git clone https://github.com/jsha/minica && \
  33. cd minica && \
  34. go mod download && \
  35. go build -ldflags='-s -w' -trimpath -o ../binaries/minica && \
  36. cd .. && \
  37. git clone https://github.com/tianon/gosu && \
  38. cd gosu && \
  39. go mod download && \
  40. go build -o ../binaries/gosu -ldflags='-s -w' -trimpath && \
  41. cd .. && \
  42. cd fileserv && \
  43. go build -ldflags='-s -w' -trimpath -o ../binaries/fileserv main.go
  44. # START RUNNER
  45. FROM debian:bullseye-slim AS runner
  46. RUN apt update -y && \
  47. apt install curl gnupg2 ca-certificates unzip supervisor net-tools procps --no-install-recommends -y && \
  48. groupadd -g 2222 zerotier-one && \
  49. useradd -u 2222 -g 2222 zerotier-one && \
  50. curl -sL -o ztone.sh https://install.zerotier.com && \
  51. bash ztone.sh && \
  52. rm -f ztone.sh && \
  53. apt clean -y && \
  54. rm -rf /var/lib/zerotier-one && \
  55. rm -rf /var/lib/apt/lists/*
  56. WORKDIR /opt/key-networks/ztncui
  57. COPY --from=builder /build/artifact.zip .
  58. RUN unzip ./artifact.zip && \
  59. rm -f ./artifact.zip
  60. COPY --from=argong /buildsrc/binaries/gosu /bin/gosu
  61. COPY --from=argong /buildsrc/binaries/minica /usr/local/bin/minica
  62. COPY --from=argong /buildsrc/binaries/argon2g /usr/local/bin/argon2g
  63. COPY --from=argong /buildsrc/binaries/fileserv /usr/local/bin/gfileserv
  64. COPY start_zt1.sh /start_zt1.sh
  65. COPY start_ztncui.sh /start_ztncui.sh
  66. COPY supervisord.conf /etc/supervisord.conf
  67. RUN chmod 0755 /bin/gosu && \
  68. chmod 0755 /usr/local/bin/minica && \
  69. chmod 0755 /usr/local/bin/argon2g && \
  70. chmod 0755 /usr/local/bin/gfileserv && \
  71. chmod 0755 /start_*.sh
  72. EXPOSE 3000/tcp
  73. EXPOSE 3180/tcp
  74. EXPOSE 8000/tcp
  75. EXPOSE 3443/tcp
  76. EXPOSE 9993/udp
  77. WORKDIR /
  78. VOLUME ["/opt/key-networks/ztncui/etc"]
  79. VOLUME [ "/var/lib/zerotier-one" ]
  80. ENTRYPOINT [ "/usr/bin/supervisord" ]