Crystal

Build a statically linked program

Since musl-libc is a better option to build a statically linked binary, use Docker or Podman to build your binary.

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

The same, but as 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"]

Create the image using

podman build -t image_name .