'Install and use golang in cloud-init script
As part of a cloud-init script of a oci vm instance I am trying to install golang and use it to compile caddy with xcaddy. My script will be executed from the could-init runcmd ./install.sh and looks like so...
#!/usr/bin/env bash
wget https://golang.org/dl/go1.16.3.linux-amd64.tar.gz
tar -C /usr/local -xzf go1.16.3.linux-amd64.tar.gz
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/xcaddy/gpg.key' | sudo apt-key add -
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/xcaddy/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-xcaddy.list
apt update
apt install xcaddy
echo 'PATH=$PATH:/usr/local/go/bin' >> /root/.bashrc
exec bash
echo $PATH
xcaddy build --with github.com/caddy-dns/cloudflare
mv caddy /usr/bin/
groupadd --system caddy
useradd --system --gid caddy --create-home --home-dir /var/lib/caddy --shell /usr/sbin/nologin --comment "Caddy web server" caddy
But the xbuild fails with the error GOLANG not found on path and I can't figure out why.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
