添加 deploy 部署脚本

优化应用易用性
This commit is contained in:
bjdgyc
2024-01-31 17:44:35 +08:00
parent d45ecbf3b7
commit 2fc3c33880
20 changed files with 297 additions and 88 deletions

View File

@@ -16,39 +16,37 @@ ARG commitId="commitId"
ENV TZ=Asia/Shanghai
WORKDIR /server
COPY docker/init.sh /tmp/init.sh
COPY docker/init_build.sh /tmp/
COPY server/ /server/
COPY web/ui /server/ui
#RUN apk add gcc musl-dev bash
RUN sh /tmp/init.sh
RUN sh /tmp/init_build.sh
# anylink
FROM alpine:3.19
LABEL maintainer="github.com/bjdgyc"
ARG CN="no"
ENV TZ=Asia/Shanghai
ENV ANYLINK_IN_CONTAINER=true
WORKDIR /app
COPY docker/init_release.sh /tmp/
COPY --from=builder_golang /server/anylink /app/
COPY docker/docker_entrypoint.sh /app/
COPY ./server/bridge-init.sh /app/
COPY ./server/conf /app/conf
COPY ./systemd /app/systemd
COPY ./README.md /app/README.md
COPY ./LICENSE /app/LICENSE
COPY docker/docker_entrypoint.sh server/bridge-init.sh ./README.md ./LICENSE /app/
COPY ./deploy /app/deploy
COPY ./home /app/home
COPY ./server/conf /app/conf
#TODO 本地打包时使用镜像
#RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories
RUN apk add --no-cache bash iptables iproute2 tzdata \
&& chmod +x /app/docker_entrypoint.sh \
&& mkdir /app/log \
&& ls /app
RUN sh /tmp/init_release.sh
EXPOSE 443 8800
EXPOSE 443 8800 443/udp
#CMD ["/app/anylink"]
ENTRYPOINT ["/app/docker_entrypoint.sh"]

View File

@@ -18,6 +18,14 @@ case $var1 in
#iptables -t nat -A POSTROUTING -s "${IPV4_CIDR}" -o eth0+ -j MASQUERADE
#iptables -nL -t nat
# 启动服务 先判断配置文件是否存在
if [ ! -f /app/conf/profile.xml ]; then
/bin/cp -r /home/conf-bak/* /app/conf/
echo "After the configuration file is initialized, the container will be forcibly exited. Restart the container."
echo "配置文件初始化完成后,容器会强制退出,请重新启动容器。"
exit 1
fi
exec /app/anylink "$@"
;;
esac

View File

@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh
set -x

21
docker/init_release.sh Normal file
View File

@@ -0,0 +1,21 @@
#!/bin/sh
set -x
#TODO 本地打包时使用镜像
if [[ $CN == "yes" ]]; then
sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories
export GOPROXY=https://goproxy.cn
fi
apk add --no-cache bash iptables iproute2 tzdata
chmod +x /app/docker_entrypoint.sh
mkdir /app/log
#备份配置文件
cp -r /app/conf /home/conf-bak
tree /app
uname -a
date -Iseconds