From d0e928607087b48da877f80b2abeda8c13d1bd73 Mon Sep 17 00:00:00 2001 From: Bibo Hao Date: Thu, 7 Nov 2024 22:24:20 +0800 Subject: [PATCH] add components: Caddy & Supervisord & CRAN (#108) * add components: Caddy & Supervisord & CRAN * update pip alias * chmod +x perm to scripts --- docker_atom/Dockerfile | 1 + .../localize/run-config-mirror-aliyun-pub.sh | 6 +++++ .../localize/run-config-mirror-aliyun-vpc.sh | 6 +++++ .../localize/run-config-mirror-default.sh | 5 +++++ .../localize/run-config-mirror-tencent-pub.sh | 6 +++++ .../localize/run-config-mirror-tencent-vpc.sh | 6 +++++ .../localize/run-config-mirror-tsinghua.sh | 6 +++++ docker_atom/work/script-setup-net.sh | 22 +++++++++++++++++++ docker_atom/work/script-setup-sys.sh | 12 ++++++++++ docker_atom/work/script-setup.sh | 9 -------- docker_base/Dockerfile | 1 + 11 files changed, 71 insertions(+), 9 deletions(-) create mode 100644 docker_atom/work/script-setup-net.sh diff --git a/docker_atom/Dockerfile b/docker_atom/Dockerfile index ca680db..f5514d8 100644 --- a/docker_atom/Dockerfile +++ b/docker_atom/Dockerfile @@ -41,6 +41,7 @@ RUN set -eux && cd /tmp \ # if /etc/profile haven't been executed, execute it. && echo -e "${LINE_CHK_FLAG} \n$(cat /etc/bash.bashrc)" > /etc/bash.bashrc \ && echo '[ $BASH ] && [ -f /root/.bashrc ] && . /root/.bashrc' >> /etc/bash.bashrc \ + && chmod +x /opt/utils/*.sh /opt/utils/localize/*.sh \ # Clean up and display components version information... && source /opt/utils/script-utils.sh && install__clean diff --git a/docker_atom/work/localize/run-config-mirror-aliyun-pub.sh b/docker_atom/work/localize/run-config-mirror-aliyun-pub.sh index 33b99e2..b99f16a 100644 --- a/docker_atom/work/localize/run-config-mirror-aliyun-pub.sh +++ b/docker_atom/work/localize/run-config-mirror-aliyun-pub.sh @@ -43,3 +43,9 @@ if [ -f "$(which go)" ]; then export GOPROXY=https://mirrors.aliyun.com/goproxy/ go env | grep 'PROXY' fi + +if [ -f "$(which R)" ]; then + echo "Found R, setting CRAN mirror" + echo "options(repos=structure(c(CRAN=\"https://mirrors.aliyun.com/CRAN/\")))" >> /etc/R/Rprofile.site + R -e "options('repos');" +fi diff --git a/docker_atom/work/localize/run-config-mirror-aliyun-vpc.sh b/docker_atom/work/localize/run-config-mirror-aliyun-vpc.sh index e7e03d8..ae649f6 100644 --- a/docker_atom/work/localize/run-config-mirror-aliyun-vpc.sh +++ b/docker_atom/work/localize/run-config-mirror-aliyun-vpc.sh @@ -43,3 +43,9 @@ if [ -f "$(which go)" ]; then export GOPROXY=https://mirrors.cloud.aliyuncs.com/goproxy/ go env | grep 'PROXY' fi + +if [ -f "$(which R)" ]; then + echo "Found R, setting CRAN mirror" + echo "options(repos=structure(c(CRAN=\"http://mirrors.cloud.aliyuncs.com/CRAN/\")))" >> /etc/R/Rprofile.site + R -e "options('repos');" +fi diff --git a/docker_atom/work/localize/run-config-mirror-default.sh b/docker_atom/work/localize/run-config-mirror-default.sh index 8529198..efeddb5 100644 --- a/docker_atom/work/localize/run-config-mirror-default.sh +++ b/docker_atom/work/localize/run-config-mirror-default.sh @@ -23,3 +23,8 @@ if [ -f "$(which go)" ]; then echo "Found golang, getting GO env:" go env | sort fi + +if [ -f "$(which R)" ]; then + echo "Found R, getting CRAN mirror" + R -e "options('repos');" +fi diff --git a/docker_atom/work/localize/run-config-mirror-tencent-pub.sh b/docker_atom/work/localize/run-config-mirror-tencent-pub.sh index 04f7a52..e7840be 100644 --- a/docker_atom/work/localize/run-config-mirror-tencent-pub.sh +++ b/docker_atom/work/localize/run-config-mirror-tencent-pub.sh @@ -43,3 +43,9 @@ if [ -f "$(which go)" ]; then export GOPROXY=https://mirrors.tencent.com/go/ go env | grep 'PROXY' fi + +if [ -f "$(which R)" ]; then + echo "Found R, setting CRAN mirror" + echo "options(repos=structure(c(CRAN=\"http://mirrors.tencent.com/CRAN/\")))" >> /etc/R/Rprofile.site + R -e "options('repos');" +fi diff --git a/docker_atom/work/localize/run-config-mirror-tencent-vpc.sh b/docker_atom/work/localize/run-config-mirror-tencent-vpc.sh index 891b73d..abfe824 100644 --- a/docker_atom/work/localize/run-config-mirror-tencent-vpc.sh +++ b/docker_atom/work/localize/run-config-mirror-tencent-vpc.sh @@ -43,3 +43,9 @@ if [ -f "$(which go)" ]; then export GOPROXY=https://mirrors.tencentyun.com/go/ go env | grep 'PROXY' fi + +if [ -f "$(which R)" ]; then + echo "Found R, setting CRAN mirror" + echo "options(repos=structure(c(CRAN=\"http://mirrors.tencentyun.com/CRAN/\")))" >> /etc/R/Rprofile.site + R -e "options('repos');" +fi diff --git a/docker_atom/work/localize/run-config-mirror-tsinghua.sh b/docker_atom/work/localize/run-config-mirror-tsinghua.sh index 3953c93..10bf31b 100644 --- a/docker_atom/work/localize/run-config-mirror-tsinghua.sh +++ b/docker_atom/work/localize/run-config-mirror-tsinghua.sh @@ -43,3 +43,9 @@ if [ -f "$(which go)" ]; then export GOPROXY=https://goproxy.cn go env | grep 'PROXY' fi + +if [ -f "$(which R)" ]; then + echo "Found R, setting CRAN mirror" + echo "options(repos=structure(c(CRAN=\"https://mirrors.tuna.tsinghua.edu.cn/CRAN/\")))" >> /etc/R/Rprofile.site + R -e "options('repos');" +fi diff --git a/docker_atom/work/script-setup-net.sh b/docker_atom/work/script-setup-net.sh new file mode 100644 index 0000000..f19fdb2 --- /dev/null +++ b/docker_atom/work/script-setup-net.sh @@ -0,0 +1,22 @@ +source /opt/utils/script-utils.sh + + +setup_traefik() { + TRAEFIK_VERSION=$(curl -sL https://github.com/traefik/traefik/releases.atom | grep 'releases/tag' | head -1 | grep -Po '\d[\d.]+') \ + && TRAEFIK_URL="https://github.com/traefik/traefik/releases/download/v${TRAEFIK_VERSION}/traefik_v${TRAEFIK_VERSION}_linux_$(dpkg --print-architecture).tar.gz" \ + && install_tar_gz "${TRAEFIK_URL}" traefik \ + && ln -sf /opt/traefik /usr/bin/ ; + + type traefik && echo "@ Version of traefik: $(traefik version)" || return -1 ; +} + +setup_caddy() { + OS="linux" && ARCH="amd64" \ + && VER_CADDY=$(curl -sL https://github.com/caddyserver/caddy/releases.atom | grep "releases/tag" | grep -v 'beta' | head -1 | grep -Po '(\d[\d|.]+)') \ + && URL_CADDY="https://github.com/caddyserver/caddy/releases/download/v${VER_CADDY}/caddy_${VER_CADDY}_${OS}_${ARCH}.tar.gz" \ + && echo "Downloading Caddy ${VER_CADDY} from ${URL_CADDY}" \ + && curl -o /tmp/TMP.tgz -sL $URL_CADDY && tar -C /tmp/ -xzf /tmp/TMP.tgz && rm /tmp/TMP.tgz \ + && mkdir -pv /opt/bin/ && mv /tmp/caddy /opt/bin/ && ln -sf /opt/bin/caddy /usr/local/bin/ ; + + type caddy && echo "@ Version of caddy: $(caddy version)" || return -1 ; +} diff --git a/docker_atom/work/script-setup-sys.sh b/docker_atom/work/script-setup-sys.sh index 9443baf..d87285a 100644 --- a/docker_atom/work/script-setup-sys.sh +++ b/docker_atom/work/script-setup-sys.sh @@ -12,6 +12,18 @@ setup_tini() { } +setup_supervisord() { + OS="linux" && ARCH="amd64" \ + && VER_SUPERVISORD=$(curl -sL https://github.com/QPod/supervisord/releases.atom | grep "releases/tag" | head -1 | grep -Po '(\d[\d|.]+)') \ + && URL_SUPERVISORD="https://github.com/QPod/supervisord/releases/download/v${VER_SUPERVISORD}/supervisord_${VER_SUPERVISORD}_${OS}_${ARCH}.tar.gz" \ + && echo "Downloading Supervisord ${VER_SUPERVISORD} from ${URL_SUPERVISORD}" \ + && curl -o /tmp/TMP.tgz -sL $URL_SUPERVISORD && tar -C /tmp/ -xzf /tmp/TMP.tgz && rm /tmp/TMP.tgz \ + && mkdir -pv /opt/bin/ && mv /tmp/supervisord /opt/bin/ && ln -sf /opt/bin/supervisord /usr/local/bin/ ; + + type supervisord && echo "@ Version of supervisord: $(supervisord version)" || return -1 ; +} + + setup_systemd() { apt-get -qq update -yq --fix-missing \ && apt-get -qq install -yq --no-install-recommends systemd systemd-cron \ diff --git a/docker_atom/work/script-setup.sh b/docker_atom/work/script-setup.sh index c9729e2..80b8fe3 100644 --- a/docker_atom/work/script-setup.sh +++ b/docker_atom/work/script-setup.sh @@ -234,15 +234,6 @@ setup_lua_rocks() { type luarocks && echo "@ Version of luarocks: $(luarocks --version)" || return -1 ; } -setup_traefik() { - TRAEFIK_VERSION=$(curl -sL https://github.com/traefik/traefik/releases.atom | grep 'releases/tag' | head -1 | grep -Po '\d[\d.]+') \ - && TRAEFIK_URL="https://github.com/traefik/traefik/releases/download/v${TRAEFIK_VERSION}/traefik_v${TRAEFIK_VERSION}_linux_$(dpkg --print-architecture).tar.gz" \ - && install_tar_gz "${TRAEFIK_URL}" traefik \ - && ln -sf /opt/traefik /usr/bin/ ; - - type traefik && echo "@ Version of traefik: $(traefik version)" || return -1 ; -} - setup_bazel() { VER_BAZEL=$(curl -sL https://github.com/bazelbuild/bazel/releases.atom | grep 'releases/tag' | head -1 | grep -Po '\d[\d.]+' ) \ diff --git a/docker_base/Dockerfile b/docker_base/Dockerfile index b3924d0..a747179 100644 --- a/docker_base/Dockerfile +++ b/docker_base/Dockerfile @@ -33,6 +33,7 @@ RUN set -eux && source /opt/utils/script-setup.sh && source /opt/utils/script-se echo "No default python found in OS." ; \ fi \ && ln -sf "${CONDA_PREFIX}"/bin/python3.* /usr/bin/ \ + && ln -sf "${CONDA_PREFIX}"/bin/pip /usr/bin/ \ && ln -sf "/usr/bin/python${PYTHON_VERSION}" /usr/bin/python \ && ln -sf "/usr/bin/python${PYTHON_VERSION}" /usr/bin/python3 \ && lsb_release -a \