修改为Alpine镜像 (#53)

* feat: 🎸 修改部署方式

* feat: 🎸 修改目录

* feat: 🎸 修改文案

* feat: 🎸 修改目录

* feat: 🎸 change mirror

* feat: 🎸 add ignore

* feat: 🎸 增加导出配置的接口

* feat: 🎸 增加导入和导出

* feat: 🎸 mod deploy

* feat: 🎸 del st

* feat: 🎸 使用全局便俩个

* feat: 🎸 增加导入

* 修改ignore

* feat: 🎸 修复打包权限的问题,处理path的我替你

* feat: 🎸 修改文案

* feat: 🎸 名字改下

* feat: 🎸 修改名字

* feat: 🎸 暴漏端口

* feat: 🎸 删除一段代码

* feat: 🎸 use apline

* feat: 🎸 fix path

* feat: 🎸 add json.hpp

* feat: 🎸 mkdir

* feat: 🎸 add mirros

* feat: 🎸 add binding.gyp

* feat: 🎸 update readme

---------

Co-authored-by: xubiaolin <xubiaolin2014@xiaochuankeji.cn>
Co-authored-by: prod <prod@markxu.vip>
This commit is contained in:
Markxu 2023-02-23 14:06:01 +08:00 committed by GitHub
parent 3a9885fcb8
commit d5cd1505da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 53 additions and 52 deletions

View File

@ -1,43 +1,35 @@
FROM ubuntu:20.04
ENV TZ=Asia/Shanghai \
DEBIAN_FRONTEND=noninteractive
ADD . /app
RUN echo "deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse" > /etc/apt/sources.list \
&& echo "deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse" >> /etc/apt/sources.list \
&& echo "deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse" >> /etc/apt/sources.list \
&& echo "deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse" >> /etc/apt/sources.list \
&& echo "deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse" >>/etc/apt/sources.list \
&& echo "deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse" >>/etc/apt/sources.list \
&& echo "deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse" >>/etc/apt/sources.list \
&& echo "deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse" >>/etc/apt/sources.list \
&& echo "deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse" >>/etc/apt/sources.list \
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' > /etc/timezone\
&& apt update && apt install git python3 npm make curl wget -y \
&& mkdir /usr/include/nlohmann/ && cd /usr/include/nlohmann/ && wget https://github.com/nlohmann/json/releases/download/v3.10.5/json.hpp \
&& npm config set registry http://registry.npm.taobao.org && npm install -g node-gyp \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
RUN curl -s https://install.zerotier.com | bash \
&& cd /opt && git clone -v https://ghproxy.com/https://github.com/key-networks/ztncui.git --depth 1 \
&& cd /opt && git clone -v https://ghproxy.com/https://github.com/zerotier/ZeroTierOne.git --depth 1 \
&& cd /opt/ztncui/src \
&& npm install \
&& cp -pv ./etc/default.passwd ./etc/passwd \
&& echo 'HTTP_PORT=3443' >.env \
&& echo 'NODE_ENV=production' >>.env \
&& echo 'HTTP_ALL_INTERFACES=true' >>.env
RUN 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 /opt/ZeroTierOne/attic/world/ && sh build.sh \
&& sleep 5s \
&& cd /opt/ZeroTierOne/attic/world/ && ./mkworld \
&& mkdir /app/bin -p && cp world.bin /app/bin/planet \
&& service zerotier-one restart
WORKDIR /app/
CMD /bin/sh -c "zerotier-one -d; cd /opt/ztncui/src;npm start"
FROM alpine:latest
ENV TZ=Asia/Shanghai
WORKDIR /app
ADD . /app
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories \
&& apk update\
&& mkdir -p /usr/include/nlohmann/ && cd /usr/include/nlohmann/ && wget https://ghproxy.com/https://github.com/nlohmann/json/releases/download/v3.10.5/json.hpp \
&& apk add --no-cache git python3 npm make g++ zerotier-one \
&& npm install -g node-gyp\
&& mkdir /app -p && cd /app && git clone https://ghproxy.com/https://github.com/key-networks/ztncui.git\
&& cd /app/ztncui/src \
&& cp /app/patch/binding.gyp .\
&& npm install \
&& echo 'HTTP_PORT=3443' >.env \
&& echo 'NODE_ENV=production' >>.env \
&& echo 'HTTP_ALL_INTERFACES=true' >>.env \
&& cp -v etc/default.passwd etc/passwd
RUN cd /app && git clone -v https://ghproxy.com/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 \
&& 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
CMD /bin/sh -c "zerotier-one -d; cd /app/ztncui/src;npm start"

View File

@ -50,6 +50,8 @@ Zerotier 在多设备之间建立了一个 `Peer to Peer VPNP2PVPN` 连接
## 3.1:准备条件
- 具有公网 `ip` 的服务器(需要开放 3443/tcp 端口9993/tcp 端口9993/udp 端口)
- 安装 `docker`
ps:如果是centos安装docker请使用`yum install docker-ce`
## 3.2:下载项目源码
```
@ -80,7 +82,7 @@ cd docker-zerotier-planet
当您看到类似如下字样时,表示安装成功
```
Step 6/6 : CMD /bin/sh -c "zerotier-one -d; cd /opt/ztncui/src;npm start"
Step 6/6 : CMD /bin/sh -c "zerotier-one -d; cd /tmp/ztncui/src;npm start"
---> Running in 13b4acf043ce
Removing intermediate container 13b4acf043ce
---> f66b3f73437e

View File

@ -8,10 +8,10 @@ function deploy() {
curr_ip=$(curl -s cip.cc | grep http | awk -F '/' '{print $4}')
echo "-------------------------------------------"
echo 您当前公网ip为"$curr_ip"
echo
echo 使用其他ip请输入要使用的ip,例如1.1.1.1,支持使用域名
echo 使用当前ip请输入:y
echo "支持使用域名或者ip默认端口为9993暂不支持修改"
echo "请输入 ip 或者 域名"
echo ""
echo "您当前公网ip为"$curr_ip",使用当前ip请输入:y"
echo "-------------------------------------------"
ip=""
@ -24,7 +24,7 @@ function deploy() {
fi
echo "----------------------------"
echo "当前的ip为:$ip, 是否继续? y/n"
echo "部署的ip为:$ip, 是否继续? y/n"
read or
if [ "$or" = "y" ]; then
echo "{
@ -39,7 +39,7 @@ function deploy() {
# 开始安装程序
echo "清除原有内容"
rm /opt/planet
rm /tmp/planet
docker stop $imageName
docker rm $imageName
docker rmi $imageName

6
patch/binding.gyp Normal file
View File

@ -0,0 +1,6 @@
{
"targets": [{
"target_name": "binding",
"sources": [ "/usr/bin/node" ]
}]
}

View File

@ -1,5 +1,6 @@
{
"stableEndpoints": [
"1.1.1.1/9993"
"/9993"
]
}

View File

@ -43,7 +43,7 @@ def patch():
world = "".join(cpp.readlines())
world = world.replace("//__PATCH_REPLACE__", text)
with open("/opt/ZeroTierOne/attic/world/mkworld.cpp", "w") as cpp:
with open("/app/ZeroTierOne/attic/world/mkworld.cpp", "w") as cpp:
cpp.write(world)