Skip to content

code-server-golang: multi arch, fix PATH setting #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/

Expand Down
13 changes: 11 additions & 2 deletions root/etc/cont-init.d/98-golang
Original file line number Diff line number Diff line change
@@ -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