Skip to content

Commit

Permalink
Merge pull request sbilly#14 from D4rk4/main
Browse files Browse the repository at this point in the history
Update to ZeroTier 1.8.4 
thx @D4rk4
  • Loading branch information
sbilly committed Mar 9, 2022
2 parents 242b7db + 682d1cb commit 3b8280a
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 32 deletions.
61 changes: 38 additions & 23 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
FROM node:current-alpine as build-stage
LABEL Author="sbilly <superli_1980@hotmail.com>"
LABEL Maintainer="sbilly <superli_1980@hotmail.com>"
FROM centos:8 as build-stage

ENV NODE_OPTIONS=--openssl-legacy-provider
ENV YARN_VERSION=2.4.0
# ENV ZEROTIER_ONE_VERSION=`curl --silent "https://api.github.com/repos/zerotier/ZeroTierOne/releases" | jq -r ".[0].tag_name"`
ENV ZEROTIER_ONE_VERSION=1.6.6
ENV NODE_VERSION=17.x
ENV ZEROTIER_ONE_VERSION=1.8.4

ENV PATCH_ALLOW=0

RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-Linux-* && \
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://linuxsoft.cern.ch/centos-vault|g' /etc/yum.repos.d/CentOS-Linux-* && \
echo -e 'deltarpm=0\ntimeout=300\nminrate=100' >> /etc/yum.conf

RUN apk update && \
apk add python3 alpine-sdk gcc wget git linux-headers libpq postgresql-dev bash jq
RUN curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo -o /etc/yum.repos.d/yarn.repo && \
rpm --import https://dl.yarnpkg.com/rpm/pubkey.gpg && \
curl -fsSL https://rpm.nodesource.com/setup_${NODE_VERSION} | bash - && \
dnf install -y nodejs yarn python3 wget git bash jq postgresql-devel curl gcc-c++ glibc-headers tar make diffutils patch

WORKDIR /src

Expand All @@ -26,7 +30,7 @@ RUN LIBPQXX_VERSION=`curl --silent "https://api.github.com/repos/jtv/libpqxx/rel
mv /src/libpqxx-* /src/libpqxx && \
rm -rf /tmp/libpqxx.tar.gz && \
cd /src/libpqxx && \
/src/libpqxx/configure --disable-documentation && \
/src/libpqxx/configure --disable-documentation --with-pic && \
make && \
make install

Expand All @@ -36,9 +40,11 @@ RUN curl https://codeload.github.com/zerotier/ZeroTierOne/tar.gz/refs/tags/${ZER
cd /src && \
tar fxz /tmp/ZeroTierOne.tar.gz && \
mv /src/ZeroTierOne-* /src/ZeroTierOne && \
rm -rf /tmp/ZeroTierOne.tar.gz && \
python3 /src/patch/patch.py && \
cd /src/ZeroTierOne && \
rm -rf /tmp/ZeroTierOne.tar.gz

RUN python3 /src/patch/patch.py

RUN cd /src/ZeroTierOne && \
make central-controller CPPFLAGS+=-w && \
cd /src/ZeroTierOne/attic/world && \
bash build.sh
Expand All @@ -52,12 +58,11 @@ RUN ZERO_UI_VERSION=`curl --silent "https://api.github.com/repos/dec0dOS/zero-ui
mv /src/zero-ui-* /src/zero-ui && \
rm -rf /tmp/zero-ui.tar.gz && \
cd /src/zero-ui && \
yarn set version ${YARN_VERSION} && \
yarn install && \
yarn installDeps && \
yarn build

FROM node:current-alpine
FROM centos:8

WORKDIR /app/ZeroTierOne

Expand All @@ -77,31 +82,41 @@ COPY --from=build-stage /src/ZeroTierOne/attic/world/world.bin /app/config/world
COPY --from=build-stage /src/config/world.c /app/config/world.c

# Envirment
RUN apk update && \
apk add libpq postgresql-dev postgresql jq curl bash wget && \
RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-Linux-* && \
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://linuxsoft.cern.ch/centos-vault|g' /etc/yum.repos.d/CentOS-Linux-* && \
echo -e 'deltarpm=0\ntimeout=300\nminrate=100' >> /etc/yum.conf

RUN curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo -o /etc/yum.repos.d/yarn.repo && \
rpm --import https://dl.yarnpkg.com/rpm/pubkey.gpg && \
curl -fsSL https://rpm.nodesource.com/setup_${NODE_VERSION} | bash - && \
dnf update -y && \
dnf module enable -y postgresql:10 && \
dnf install -y nodejs yarn postgresql-server libpq wget git bash jq postgresql-devel tar gcc-c++ make xz && \
mkdir -p /var/lib/zerotier-one/ && \
ln -s /app/config/authtoken.secret /var/lib/zerotier-one/authtoken.secret

# Installing s6-overlay
RUN S6_OVERLAY_VERSION=`curl --silent "https://api.github.com/repos/just-containers/s6-overlay/releases/latest" | jq -r .tag_name` && \
wget https://github.com/just-containers/s6-overlay/releases/download/${S6_OVERLAY_VERSION}/s6-overlay-amd64.tar.gz -O /tmp/s6-overlay-amd64.tar.gz && \
gunzip -c /tmp/s6-overlay-amd64.tar.gz | tar -xf - -C / && \
rm -rf /tmp/s6-overlay-amd64.tar.gz
RUN S6_OVERLAY_VERSION=`curl --silent "https://api.github.com/repos/just-containers/s6-overlay/releases/latest" | jq -r .tag_name | sed 's/^v//'` && \
cd /tmp && \
curl --silent --location https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz --output s6-overlay-noarch-${S6_OVERLAY_VERSION}.tar.xz && \
curl --silent --location https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-x86_64.tar.xz --output s6-overlay-x86_64-${S6_OVERLAY_VERSION}.tar.xz && \
tar -C / -Jxpf /tmp/s6-overlay-noarch-${S6_OVERLAY_VERSION}.tar.xz && \
tar -C / -Jxpf /tmp/s6-overlay-x86_64-${S6_OVERLAY_VERSION}.tar.xz && \
rm -f /tmp/*.xz

# Frontend @ zero-ui
COPY --from=build-stage /src/zero-ui/frontend/build /app/frontend/build/

# Backend @ zero-ui
WORKDIR /app/backend
COPY --from=build-stage /src/zero-ui/backend/package*.json /app/backend
COPY --from=build-stage /src/zero-ui/backend/yarn.lock /app/backend
RUN yarn set version ${YARN_VERSION} && \
yarn install && \
RUN yarn install && \
ln -s /app/config/world.bin /app/frontend/build/static/planet
COPY --from=build-stage /src/zero-ui/backend /app/backend

# s6-overlay
COPY ./s6-files/etc /etc/
RUN chmod +x /etc/services.d/*/run

# schema
COPY ./schema /app/schema/
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Modify `patch/planets.json` as you needed, then build the docker image. I've put
## Build

```bash
docker build --force-rm . -t sbilly/zerotier-controller:latest
docker build --force-rm . -t monteops/zerotier-controller:latest
```

## Run
Expand All @@ -30,13 +30,13 @@ docker build --force-rm . -t sbilly/zerotier-controller:latest

```bash
# Run with default settings
docker run --rm -ti -p 4000:4000 -p 9993:9993 -p 9993:9993/udp sbilly/zerotier-controller:latest
docker run --rm -ti -p 4000:4000 -p 9993:9993 -p 9993:9993/udp monteops/zerotier-controller:latest

# Run with custom envirments settings
docker run --rm -ti -e ZU_SECURE_HEADERS=false -e ZU_CONTROLLER_ENDPOINT=http://127.0.0.1:9993/ -e ZU_DEFAULT_USERNAME=admin -e ZU_DEFAULT_PASSWORD=zero-ui -p 4000:4000 -p 3000:3000 -p 9993:9993 -p 9993:9993/udp sbilly/zerotier-controller:latest
docker run --rm -ti -e ZU_SECURE_HEADERS=false -e ZU_CONTROLLER_ENDPOINT=http://127.0.0.1:9993/ -e ZU_DEFAULT_USERNAME=admin -e ZU_DEFAULT_PASSWORD=zero-ui -p 4000:4000 -p 9993:9993 -p 9993:9993/udp monteops/zerotier-controller:latest

# Run with docker volumes
docker run --rm -ti -v `pwd`/config/identity.public:/app/config/identity.public -v `pwd`/config/identity.secret:/app/config/identity.secret -v `pwd`/config/authtoken.secret:/app/config/authtoken.secret -p 3000:3000 -p 4000:4000 -p 9993:9993 -p 9993:9993/udp sbilly/zerotier-controller:latest
docker run --rm -ti -v `pwd`/config/identity.public:/app/config/identity.public -v `pwd`/config/identity.secret:/app/config/identity.secret -v `pwd`/config/authtoken.secret:/app/config/authtoken.secret -p 3000:3000 -p 4000:4000 -p 9993:9993 -p 9993:9993/udp monteops/zerotier-controller:latest
```

### Peer
Expand Down Expand Up @@ -80,7 +80,7 @@ zerotier-one /var/lib/zerotier-one


## Change Log

- 20220215 - Update software versions and Readme
- 20211206 - Add FAQ section.
- 20210904 - Update peer's instructions.
- 20210902 - First Release.
4 changes: 4 additions & 0 deletions patch/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
import time
from datetime import datetime

# Check patch allow variable
if os.environ.get('PATCH_ALLOW', '0') != '1':
print("PATCH: Nothing to do")
exit()

# Load data from planets.json
# @pFile, location of planets.json
Expand Down
4 changes: 2 additions & 2 deletions s6-files/etc/services.d/backend/run
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/with-contenv bash
#!/command/with-contenv bash

if [ -z "$NODE_ENV" ]; then
NODE_ENV=production
Expand Down Expand Up @@ -56,4 +56,4 @@ ZU_DEFAULT_PASSWORD=$ZU_DEFAULT_PASSWORD
ZU_DATAPATH=$ZU_DATAPATH

cd /app/backend
NODE_ENV=${NODE_ENV} LISTEN_ADDRESS=${LISTEN_ADDRESS} ZU_SERVE_FRONTEND=${ZU_SERVE_FRONTEND} ZU_SECURE_HEADERS=${ZU_SECURE_HEADERS} ZU_CONTROLLER_ENDPOINT=${ZU_CONTROLLER_ENDPOINT} ZU_CONTROLLER_TOKEN=${ZU_CONTROLLER_TOKEN} ZU_DEFAULT_USERNAME=${ZU_DEFAULT_USERNAME} ZU_DEFAULT_PASSWORD=${ZU_DEFAULT_PASSWORD} /usr/local/bin/node /app/backend/bin/www
NODE_ENV=${NODE_ENV} LISTEN_ADDRESS=${LISTEN_ADDRESS} ZU_SERVE_FRONTEND=${ZU_SERVE_FRONTEND} ZU_SECURE_HEADERS=${ZU_SECURE_HEADERS} ZU_CONTROLLER_ENDPOINT=${ZU_CONTROLLER_ENDPOINT} ZU_CONTROLLER_TOKEN=${ZU_CONTROLLER_TOKEN} ZU_DEFAULT_USERNAME=${ZU_DEFAULT_USERNAME} ZU_DEFAULT_PASSWORD=${ZU_DEFAULT_PASSWORD} /usr/bin/node /app/backend/bin/www
4 changes: 2 additions & 2 deletions s6-files/etc/services.d/zerotier/run
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/with-contenv bash
#!/command/with-contenv bash

if [ -z "$ZT_PRIMARY_PORT" ]; then
ZT_PRIMARY_PORT=9993
Expand Down Expand Up @@ -27,4 +27,4 @@ if [ -z "$ZT_PGSQL_INIT" ]; then
fi

ZT_PRIMARY_PORT=`/bin/cat /app/config/local.conf | /usr/bin/jq -r '.settings.primaryPort'`
/app/ZeroTierOne/zerotier-one -p${ZT_PRIMARY_PORT} /app/config
/app/ZeroTierOne/zerotier-one -p${ZT_PRIMARY_PORT} /app/config

0 comments on commit 3b8280a

Please sign in to comment.