Skip to content

Commit e367672

Browse files
authored
Merge pull request #43 from linuxserver/code-server-golang-multi
code-server-golang: multi arch, fix PATH setting
2 parents 260a0f0 + d0e6055 commit e367672

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

Dockerfile

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,16 @@ RUN \
99
if [ -z ${GO_VERSION+x} ]; then \
1010
GO_VERSION=$(curl -sX GET https://golang.org/dl/ | grep -o '<span.*>.*linux-amd64.*</span>' | grep -oP '(?<=go).*(?=.linux)'); \
1111
fi && \
12-
mkdir -p /root-layer/usr/local && \
12+
mkdir -p /root-layer/golang && \
1313
curl -o \
14-
/tmp/golang.tar.gz -L \
14+
/root-layer/golang/golang_x86_64.tar.gz -L \
1515
https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz && \
16-
tar xzf /tmp/golang.tar.gz -C \
17-
/root-layer/usr/local
16+
curl -o \
17+
/root-layer/golang/golang_armv7l.tar.gz -L \
18+
https://dl.google.com/go/go${GO_VERSION}.linux-armv6l.tar.gz && \
19+
curl -o \
20+
/root-layer/golang/golang_aarch64.tar.gz -L \
21+
https://dl.google.com/go/go${GO_VERSION}.linux-arm64.tar.gz
1822

1923
COPY root/ /root-layer/
2024

root/etc/cont-init.d/98-golang

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
#!/usr/bin/with-contenv bash
22

33
echo "ensuring golang is in PATH"
4-
if grep -q '^PATH=' /etc/services.d/code-server/run; then
5-
if ! grep -q '^PATH=.*/usr/local/go/bin.*' /etc/services.d/code-server/run; then
4+
if grep -q -E '^(export )?PATH=' /etc/services.d/code-server/run; then
5+
if ! grep -q -E '^(export )?PATH=.*/usr/local/go/bin.*' /etc/services.d/code-server/run; then
66
sed -i '/PATH/ s/$/:\/usr\/local\/go\/bin/' /etc/services.d/code-server/run
77
fi
88
else
99
sed -i '/^#!\/usr\/bin/a \\n# Added by codeserver-golang\nexport PATH=$PATH:/usr/local/go/bin' /etc/services.d/code-server/run
1010
fi
11+
12+
ARCH=$(uname -m)
13+
if [ -f "/golang/golang_${ARCH}.tar.gz" ]; then
14+
echo "Installing golang"
15+
tar xzf "/golang/golang_${ARCH}.tar.gz" -C /usr/local
16+
rm -rf /golang
17+
else
18+
echo "Golang already installed, skipping"
19+
fi

0 commit comments

Comments
 (0)