2023-05-10 05:30:20 -04:00
|
|
|
FROM alpine:3.17 as builder
|
2023-02-23 01:06:01 -05:00
|
|
|
|
2023-02-26 02:17:17 -05:00
|
|
|
ARG ZT_PORT
|
|
|
|
|
2023-02-23 01:06:01 -05:00
|
|
|
ENV TZ=Asia/Shanghai
|
2023-05-14 22:15:25 -04:00
|
|
|
ENV PROXY=https://ghself.markxu.online/
|
2023-02-23 01:06:01 -05:00
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
ADD . /app
|
|
|
|
|
2023-05-14 22:14:40 -04:00
|
|
|
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories &&
|
2023-05-14 22:15:25 -04:00
|
|
|
apk update && mkdir -p /usr/include/nlohmann/ && cd /usr/include/nlohmann/ && wget $(PROXY)https://github.com/nlohmann/json/releases/download/v3.10.5/json.hpp &&
|
2023-05-14 22:14:40 -04:00
|
|
|
apk add --no-cache git python3 npm make g++ zerotier-one &&
|
2023-05-14 22:15:25 -04:00
|
|
|
npm install -g node-gyp && mkdir /app -p && cd /app && git clone $(PROXY)https://github.com/key-networks/ztncui.git && cd /app/ztncui/src &&
|
2023-05-14 22:14:40 -04:00
|
|
|
cp /app/patch/binding.gyp . && npm install &&
|
|
|
|
echo 'HTTP_PORT=3443' >.env &&
|
|
|
|
echo 'NODE_ENV=production' >>.env &&
|
|
|
|
echo 'HTTP_ALL_INTERFACES=true' >>.env &&
|
|
|
|
echo "ZT_ADDR=localhost:${ZT_PORT}" >>.env && echo "${ZT_PORT}" >/app/zerotier-one.port &&
|
|
|
|
cp -v etc/default.passwd etc/passwd
|
|
|
|
|
2023-05-14 22:15:25 -04:00
|
|
|
RUN cd /app && git clone -v $(PROXY)https://github.com/zerotier/ZeroTierOne.git --depth 1 && zerotier-one -d && sleep 5s && ps -ef | grep zerotier-one | grep -v grep | awk '{print $1}' | xargs kill -9 &&
|
2023-05-14 22:14:40 -04:00
|
|
|
cd /var/lib/zerotier-one && zerotier-idtool initmoon identity.public >moon.json && cd /app/patch && python3 patch.py &&
|
|
|
|
cd /var/lib/zerotier-one && zerotier-idtool genmoon moon.json && mkdir moons.d && cp ./*.moon ./moons.d &&
|
|
|
|
cd /app/ZeroTierOne/attic/world/ && sh build.sh &&
|
|
|
|
sleep 5s &&
|
|
|
|
cd /app/ZeroTierOne/attic/world/ && ./mkworld &&
|
|
|
|
mkdir /app/bin -p && cp world.bin /app/bin/planet &&
|
|
|
|
TOKEN=$(cat /var/lib/zerotier-one/authtoken.secret) &&
|
|
|
|
echo "ZT_TOKEN=$TOKEN" >>/app/ztncui/src/.env
|
2023-02-23 01:06:01 -05:00
|
|
|
|
2023-05-10 05:33:32 -04:00
|
|
|
FROM alpine:3.17
|
2023-02-26 02:52:07 -05:00
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
COPY --from=builder /app/ztncui /app/ztncui
|
|
|
|
COPY --from=builder /app/bin /app/bin
|
|
|
|
COPY --from=builder /app/zerotier-one.port /app/zerotier-one.port
|
|
|
|
COPY --from=builder /var/lib/zerotier-one /var/lib/zerotier-one
|
|
|
|
|
2023-05-14 22:14:40 -04:00
|
|
|
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories &&
|
|
|
|
apk update && apk add --no-cache npm zerotier-one
|
2023-02-26 02:52:07 -05:00
|
|
|
|
|
|
|
VOLUME [ "/app","/var/lib/zerotier-one" ]
|
2023-02-23 01:06:01 -05:00
|
|
|
|
2023-05-14 22:14:40 -04:00
|
|
|
CMD /bin/sh -c "cd /var/lib/zerotier-one && ./zerotier-one -p$(cat /app/zerotier-one.port) -d; cd /app/ztncui/src;npm start"
|