bluebrown / go-template-cli

render json, yaml & toml with go templates, from the command line
BSD Zero Clause License
30 stars 6 forks source link

binary builds incompatible with alpine linux #23

Open rriemann opened 3 weeks ago

rriemann commented 3 weeks ago

Hi Nico,

thank you very much for this tool. I need to generate some more files that helmfile can do and I can reuse most of the concepts thanks to tpl.

The people I work with build their stuff with alpine images. I tried to add your tool's binary straight from github, but it does not work. I assume the problem is that you build with glibc and alpine does not have it. It would be awesome if you could also support Alpine!

Minimal broken example:

FROM docker.io/alpine:edge@sha256:166710df254975d4a6c4c407c315951c22753dcaa829e020a3fd5d18fff70dd2

ARG TPL_VERSION=0.3.1

RUN \
 # tpl
 wget -q "https://github.com/bluebrown/go-template-cli/releases/download/v${TPL_VERSION}/tpl-linux-amd64" -O /usr/bin/tpl \
 && chmod +x /usr/bin/tpl
podman run --rm -it tpl-testing
/ # tpl 
/bin/sh: tpl: not found
/ # ldd tpl
/lib/ld-musl-x86_64.so.1: cannot load tpl: No such file or directory
/ # ldd $(which tpl)
        /lib64/ld-linux-x86-64.so.2 (0x7f9eb09e1000)
        libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7f9eb09e1000)
Error relocating /usr/bin/tpl: __vfprintf_chk: symbol not found
Error relocating /usr/bin/tpl: __fprintf_chk: symbol not found
bluebrown commented 3 weeks ago

Hi, sure we can do that. I think I need to fix my docker image as well as the one in the registry is outdated.

Howerver, for the time being, you can also do something like this. Its not as efficient but may be good enough if you build infrequently. As added bonus you know the binrary contains what you think it does.

FROM golang:alpine
RUN go install github.com/bluebrown/tpl@latest
FROM alpine
COPY --from=0 /go/bin/tpl //bin/