From 5aeb1615c1fc16a94cb060671460d45d6cf1235c Mon Sep 17 00:00:00 2001 From: aptalca Date: Sat, 30 Jul 2022 16:50:42 -0400 Subject: [PATCH] switch to hybrid --- Dockerfile | 6 ++--- README.md | 8 +++--- .../dependencies.d/init-mods | 0 .../run | 25 +++++++++++++++++++ .../type | 1 + .../up | 1 + .../init-mod-code-server-golang-add-package | 0 .../init-mod-code-server-golang-add-package | 0 8 files changed, 34 insertions(+), 7 deletions(-) create mode 100644 root/etc/s6-overlay/s6-rc.d/init-mod-code-server-golang-add-package/dependencies.d/init-mods create mode 100755 root/etc/s6-overlay/s6-rc.d/init-mod-code-server-golang-add-package/run create mode 100644 root/etc/s6-overlay/s6-rc.d/init-mod-code-server-golang-add-package/type create mode 100644 root/etc/s6-overlay/s6-rc.d/init-mod-code-server-golang-add-package/up create mode 100644 root/etc/s6-overlay/s6-rc.d/init-mods-package-install/dependencies.d/init-mod-code-server-golang-add-package create mode 100644 root/etc/s6-overlay/s6-rc.d/user/contents.d/init-mod-code-server-golang-add-package diff --git a/Dockerfile b/Dockerfile index ca636a5f..2bb4afe9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,13 +11,13 @@ RUN \ fi && \ mkdir -p /root-layer/golang && \ curl -o \ - /root-layer/golang/golang_x86_64.tar.gz -L \ + /root-layer/golang/golang_x86_64.tar.gz -fL \ https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz && \ curl -o \ - /root-layer/golang/golang_armv7l.tar.gz -L \ + /root-layer/golang/golang_armv7l.tar.gz -fL \ https://go.dev/dl/go${GO_VERSION}.linux-armv6l.tar.gz && \ curl -o \ - /root-layer/golang/golang_aarch64.tar.gz -L \ + /root-layer/golang/golang_aarch64.tar.gz -fL \ https://go.dev/dl/go${GO_VERSION}.linux-arm64.tar.gz COPY root/ /root-layer/ diff --git a/README.md b/README.md index 6074ff4a..6e9fcf26 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -# Golang - Docker mod for code-server +# Golang - Docker mod for code-server and openvscode-server -This mod adds golang/go to code-server. +This mod adds golang/go to code-server and openvscode-server. -In code-server docker arguments, set an environment variable `DOCKER_MODS=linuxserver/mods:code-server-golang` +In code-server or openvscode-server docker arguments, set an environment variable `DOCKER_MODS=linuxserver/mods:code-server-golang` If adding multiple mods, enter them in an array separated by `|`, such as `DOCKER_MODS=linuxserver/mods:code-server-golang|linuxserver/mods:code-server-mod2` @@ -18,4 +18,4 @@ If adding multiple mods, enter them in an array separated by `|`, such as `DOCKE - `linuxserver/mods:code-server-golang` will install the latest stable release, which is `1.14.2` as of 2020/05/07 - `linuxserver/mods:code-server-golang-1.14.2` will install the specific `1.14.2` release -Visit https://hub.docker.com/r/linuxserver/mods/tags?page=1&name=code-server-golang to see all available tags \ No newline at end of file +Visit https://hub.docker.com/r/linuxserver/mods/tags?page=1&name=code-server-golang to see all available tags diff --git a/root/etc/s6-overlay/s6-rc.d/init-mod-code-server-golang-add-package/dependencies.d/init-mods b/root/etc/s6-overlay/s6-rc.d/init-mod-code-server-golang-add-package/dependencies.d/init-mods new file mode 100644 index 00000000..e69de29b diff --git a/root/etc/s6-overlay/s6-rc.d/init-mod-code-server-golang-add-package/run b/root/etc/s6-overlay/s6-rc.d/init-mod-code-server-golang-add-package/run new file mode 100755 index 00000000..b5050088 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-mod-code-server-golang-add-package/run @@ -0,0 +1,25 @@ +#!/usr/bin/with-contenv bash + +echo "**** ensuring golang is in PATH ****" +if grep -q -E '^(export )?PATH=' /etc/services.d/code-server/run; then + if ! grep -q -E '^(export )?PATH=.*/usr/local/go/bin.*' /etc/services.d/code-server/run; then + sed -i '/PATH/ s/$/:\/usr\/local\/go\/bin/' /etc/services.d/code-server/run + fi + if ! grep -q -E '^(export )?PATH=.*/config/go/bin:.*' /etc/services.d/code-server/run; then + sed -i 's/PATH=/PATH=\/config\/go\/bin:/g' /etc/services.d/code-server/run + fi +else + sed -i '/^#!\/usr\/bin/a \\n# Added by codeserver-golang\nexport PATH=/config/go/bin:$PATH:/usr/local/go/bin' /etc/services.d/code-server/run +fi + +ARCH=$(uname -m) +if [ -f "/golang/golang_${ARCH}.tar.gz" ]; then + echo "**** Installing golang ****" + tar xzf "/golang/golang_${ARCH}.tar.gz" -C /usr/local + rm -rf /golang + + echo "**** Adding gcc to package install list, to make CGO work ****" + echo "gcc" >> /mod-repo-packages-to-install.list +else + echo "**** Golang already installed, skipping ****" +fi diff --git a/root/etc/s6-overlay/s6-rc.d/init-mod-code-server-golang-add-package/type b/root/etc/s6-overlay/s6-rc.d/init-mod-code-server-golang-add-package/type new file mode 100644 index 00000000..3d92b15f --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-mod-code-server-golang-add-package/type @@ -0,0 +1 @@ +oneshot \ No newline at end of file diff --git a/root/etc/s6-overlay/s6-rc.d/init-mod-code-server-golang-add-package/up b/root/etc/s6-overlay/s6-rc.d/init-mod-code-server-golang-add-package/up new file mode 100644 index 00000000..91d8bfd9 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/init-mod-code-server-golang-add-package/up @@ -0,0 +1 @@ +/etc/s6-overlay/s6-rc.d/init-mod-code-server-golang-add-package/run \ No newline at end of file diff --git a/root/etc/s6-overlay/s6-rc.d/init-mods-package-install/dependencies.d/init-mod-code-server-golang-add-package b/root/etc/s6-overlay/s6-rc.d/init-mods-package-install/dependencies.d/init-mod-code-server-golang-add-package new file mode 100644 index 00000000..e69de29b diff --git a/root/etc/s6-overlay/s6-rc.d/user/contents.d/init-mod-code-server-golang-add-package b/root/etc/s6-overlay/s6-rc.d/user/contents.d/init-mod-code-server-golang-add-package new file mode 100644 index 00000000..e69de29b