Fresh copy of alpine with golang.

For this, I wanted a simple cli development environment also, so we will install git, vim, zsh, ohmyzsh, and fzf. You might want to install vim first;

apk add vim

Then, just paste the code below into a script.

vim fresh-alpine-with-go-zsh-and-fzf.ash;
#!/bin/ash
#
#############################################################
#                                                           #
#  Fresh Alpine Linux with all the Go things, zsh, and fzf  #
#  -Richard Stanley                                         #
#     -Thanks- YouTuber; /watch?v=tirOEF8Bnj8               #
#                                                           #
#############################################################
#
GO_VERSION=go1.20.6.linux-amd64.tar.gz # change_me
apk update
apk add patchelf gcompat curl tar shadow
apk add git vim zsh bash
curl https://dl.google.com/go/$GO_VERSION --output $GO_VERSION
mv $GO_VERSION /usr/local/bin/$GO_VERSION
cd /usr/local/bin
tar -xf $GO_VERSION
rm $GO_VERSION
cd go/bin
patchelf --set-interpreter /lib/libc.musl-x86_64.so.1 go
# gcompat include libresolv.so.2 # may not need
# To replace ash with zsh;
sed "s/root:x:0:0:root:\/root:\/bin\/ash/root:x:0:0:root:\/root:\/bin\/zsh/" -i /etc/passwd
# add the go path to the zsh root environment
grep -qxF 'PATH=$PATH:/usr/local/bin/go/bin' foo.bar || echo 'PATH=$PATH:/usr/local/bin/go/bin' >> .zshrc
#!/bin/zsh
# Install ohmyzsh;
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
cd ~/;
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
~/.fzf/install
exit;

Make it executable, and execute;

chmod +x fresh-alpine-with-go-zsh-and-fzf.ash && ./fresh-alpine-with-go-zsh-and-fzf.ash

When prompted by ohmyzsh if you want to make zsh default shell, you can select no, since that’s what sed does with root privileges.

Log back into alpine. LXC container size; 364.65 MiB

You get the gist