Running Caddy and Go on ARMv6 Alpine Linux
My goal was compiling Caddy for my old Raspberry Pi 1 Model B. Caddy only provides an ARMv7 binary which isn’t compatible to the original Pis ARMv6. My Raspi is running on Hypriot, the Docker distribution for the Pi, therefore I wanted Caddy to run in a container as well. I chose my own Alpine Linux base image as its foundation.
As Caddy is written in Go, compiling it from source should be very easy:
- go get github.com/mholt/caddy/caddy
- cd into your website’s directory
- Run caddy (assuming $GOPATH/bin is in your $PATH)
While trying to get Go running in my Alpine container I encountered a small problem.
Go officialy provides an ARMv6 binary package, which is able to natively run on the Pi. But when trying to run this package in my Alpine container, a rather nondescriptive error blocked me:
/bin/sh: go: not found
I admit I needed longer than expected to solve this problem. After strace
ing, debugging and a lot of Internet research without result, using a simple file
gave me the deciding hint:
/go # file $(which go)
/usr/local/go/bin/go: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, not stripped
Go is looking for /lib/ld-linux-armhf.so.3
which isn’t available on a minimal Alpine Linux installation. Running apk add libc6-compat
finally solved this problem.