Crystal: Run CI on Alpine/musl

Created on 15 Oct 2018  路  3Comments  路  Source: crystal-lang/crystal

Since musl is the only way to reliably compile with statically linked libraries, I'd suggest to improve its support level. Mainly, automatic tests would be great.
This shouldn't be very difficult to integrate into CI. Both travis and circle support docker images and the specs can just be executed in an alpine image for i686-linux-musl and x86_64-linux-musl.

/cc #6903 #6917

Most helpful comment

I've updated a Dockerfile which can be used at a base: https://github.com/j8r/dockerfiles/blob/master/crystal-alpine/Dockerfile
It uses packages of Alpine Latest, and use crystal and shards from the Edge channel.

All 3 comments

It may be the time to have an official Alpine-based Docker image.
Options are:

The official crystal package of Alpine is good, the problem is only the edge channel, which has no stability guarantees, can be up-to-date against the latest Crystal release.

I've updated a Dockerfile which can be used at a base: https://github.com/j8r/dockerfiles/blob/master/crystal-alpine/Dockerfile
It uses packages of Alpine Latest, and use crystal and shards from the Edge channel.

I've created an experimental CI job test_alpine in #7420. It doesn't work though, because the alpine docker image has an outdated Crystal version which can't compile current master.

Following @j8r's proposal, the path to solving that would be to provide our own docker image for alpine. Simply following alpine:edge is not a solution because in the time between new Crystal version is released and the aport is updated, ci builds would fail on breaking changes.

For a docker image, we don't even need to use APK at all, we just need to build the compiler and attach it to the image. In fact, we're already building a compiler for alpine in the distribution-scripts. It's an intermediate step and used to produce a static binary. Essentially, we could just take that alpine compiler and put it in a docker image.

Once #7196 is fixed, the generic linux compiler should also work on alpine. I guess that is the simplest solution, because we don't need different compiler builds, just a single one distributed in different formats.
Then it's just a piece of cake to build a docker image based on alpine:latest which installs the dependencies and the generic linux tar.gz.

Was this page helpful?
0 / 5 - 0 ratings