Crystal

Compilar um programa com linkagem estática

Como o musl-libc é uma opção melhor para compilar um binário com linkagem estática, use o Docker ou o Podman para compilar seu binário

podman run --rm -it -v $(pwd):/workspace -w /workspace crystallang/crystal:latest-alpine crystal build src/teste.cr --release --no-debug --progress --static

O mesmo, mas como Dockerfile

FROM crystallang/crystal:latest-alpine as builder
WORKDIR /src
COPY . .
RUN crystal build src/teste.cr --release --no-debug --progress --static

FROM scratch
COPY --from=builder /src/teste /teste
ENTRYPOINT ["/teste"]

Crie a imagem usando

podman build -t image_name .