Merge pull request #43 from linuxserver/code-server-golang-multi

code-server-golang: multi arch, fix PATH setting
This commit is contained in:
aptalca 2020-05-20 14:19:04 -04:00 committed by GitHub
commit e367672363
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 6 deletions

View File

@ -9,12 +9,16 @@ RUN \
if [ -z ${GO_VERSION+x} ]; then \
GO_VERSION=$(curl -sX GET https://golang.org/dl/ | grep -o '<span.*>.*linux-amd64.*</span>' | grep -oP '(?<=go).*(?=.linux)'); \
fi && \
mkdir -p /root-layer/usr/local && \
mkdir -p /root-layer/golang && \
curl -o \
/tmp/golang.tar.gz -L \
/root-layer/golang/golang_x86_64.tar.gz -L \
https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz && \
tar xzf /tmp/golang.tar.gz -C \
/root-layer/usr/local
curl -o \
/root-layer/golang/golang_armv7l.tar.gz -L \
https://dl.google.com/go/go${GO_VERSION}.linux-armv6l.tar.gz && \
curl -o \
/root-layer/golang/golang_aarch64.tar.gz -L \
https://dl.google.com/go/go${GO_VERSION}.linux-arm64.tar.gz
COPY root/ /root-layer/

View File

@ -1,10 +1,19 @@
#!/usr/bin/with-contenv bash
echo "ensuring golang is in PATH"
if grep -q '^PATH=' /etc/services.d/code-server/run; then
if ! grep -q '^PATH=.*/usr/local/go/bin.*' /etc/services.d/code-server/run; then
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
else
sed -i '/^#!\/usr\/bin/a \\n# Added by codeserver-golang\nexport PATH=$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
else
echo "Golang already installed, skipping"
fi