From 203c78c949ed0d42bf81880bb95690d0ea59220f Mon Sep 17 00:00:00 2001 From: paddy235 <3988263@qq.com> Date: Fri, 9 Jun 2023 16:17:21 +0800 Subject: [PATCH 1/4] Create docker-entrypoint.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 增加一个预处理脚本过程,适合后期调试,例如:查看环境变量 --- docker-entrypoint.sh | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 docker-entrypoint.sh diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100644 index 000000000..08cd0b15f --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,33 @@ +#!/bin/sh +# vim:sw=4:ts=4:et + +set -e + + +if [ "$1" = "ThingsPanel-Go" ]; then + if /usr/bin/find "/docker-entrypoint.d/" -mindepth 1 -maxdepth 1 -type f -print -quit 2>/dev/null | read v; then + echo >&3 "$0: /docker-entrypoint.d/ is not empty, will attempt to perform configuration" + + echo >&3 "$0: Looking for shell scripts in /docker-entrypoint.d/" + find "/docker-entrypoint.d/" -follow -type f -print | sort -V | while read -r f; do + case "$f" in + *.sh) + if [ -x "$f" ]; then + echo >&3 "$0: Launching $f"; + "$f" + else + # warn on shell scripts without exec bit + echo >&3 "$0: Ignoring $f, not executable"; + fi + ;; + *) echo >&3 "$0: Ignoring $f";; + esac + done + + echo >&3 "$0: Configuration complete; ready for start up" + else + echo >&3 "$0: No files found in /docker-entrypoint.d/, skipping configuration" + fi +fi + +exec "$@" From 8f5efaff83b94898182c20f4c4fb61385f0202e4 Mon Sep 17 00:00:00 2001 From: paddy235 <3988263@qq.com> Date: Fri, 9 Jun 2023 16:21:37 +0800 Subject: [PATCH 2/4] Update Dockerfile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit // 增加预处理过程,方便后期调试,例如独立运行本镜像查看环境等 --- Dockerfile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 506472efb..430704cad 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,7 +16,8 @@ ENV PLUGIN_HTTP_HOST=172.19.0.8:503 WORKDIR /go/src/app COPY --from=builder /go/src/app . EXPOSE 9999 -RUN chmod +x ThingsPanel-Go -RUN pwd -RUN ls -lrt -ENTRYPOINT [ "./ThingsPanel-Go" ] \ No newline at end of file +RUN mkdir /docker-entrypoint.d && \ + chmod +x ThingsPanel-Go docker-entrypoint.sh +// 增加预处理过程,方便后期调试,例如独立运行本镜像查看环境等 +ENTRYPOINT ["/go/src/app/docker-entrypoint.sh"] +CMD [ "./ThingsPanel-Go" ] From 1e995c6193654baef171c2ceb562135e6db70d53 Mon Sep 17 00:00:00 2001 From: paddy235 <3988263@qq.com> Date: Thu, 15 Jun 2023 11:36:48 +0800 Subject: [PATCH 3/4] Update docker-entrypoint.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复一个判断条件错误 --- docker-entrypoint.sh | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 08cd0b15f..7ef04e3ca 100644 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -1,32 +1,33 @@ -#!/bin/sh +#!/bin/bash # vim:sw=4:ts=4:et set -e +env -if [ "$1" = "ThingsPanel-Go" ]; then +if [[ "$1" =~ "ThingsPanel-Go" ]]; then if /usr/bin/find "/docker-entrypoint.d/" -mindepth 1 -maxdepth 1 -type f -print -quit 2>/dev/null | read v; then - echo >&3 "$0: /docker-entrypoint.d/ is not empty, will attempt to perform configuration" + echo "$0: /docker-entrypoint.d/ is not empty, will attempt to perform configuration" - echo >&3 "$0: Looking for shell scripts in /docker-entrypoint.d/" + echo "$0: Looking for shell scripts in /docker-entrypoint.d/" find "/docker-entrypoint.d/" -follow -type f -print | sort -V | while read -r f; do case "$f" in *.sh) if [ -x "$f" ]; then - echo >&3 "$0: Launching $f"; + echo "$0: Launching $f"; "$f" else # warn on shell scripts without exec bit - echo >&3 "$0: Ignoring $f, not executable"; + echo "$0: Ignoring $f, not executable"; fi ;; - *) echo >&3 "$0: Ignoring $f";; + *) echo "$0: Ignoring $f";; esac done - echo >&3 "$0: Configuration complete; ready for start up" + echo "$0: Configuration complete; ready for start up" else - echo >&3 "$0: No files found in /docker-entrypoint.d/, skipping configuration" + echo "$0: No files found in /docker-entrypoint.d/, skipping configuration" fi fi From 6f281b4cc0c777304b5b071e71c98af028770d6c Mon Sep 17 00:00:00 2001 From: paddy235 <3988263@qq.com> Date: Thu, 15 Jun 2023 11:38:10 +0800 Subject: [PATCH 4/4] Update Dockerfile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 增加bash和curl工具 --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 430704cad..effad2e41 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,7 +16,8 @@ ENV PLUGIN_HTTP_HOST=172.19.0.8:503 WORKDIR /go/src/app COPY --from=builder /go/src/app . EXPOSE 9999 -RUN mkdir /docker-entrypoint.d && \ +RUN apk --update add curl bash && 、 + mkdir /docker-entrypoint.d && \ chmod +x ThingsPanel-Go docker-entrypoint.sh // 增加预处理过程,方便后期调试,例如独立运行本镜像查看环境等 ENTRYPOINT ["/go/src/app/docker-entrypoint.sh"]