Skip to content

musl build for cross-platform docker images #620

@joepio

Description

@joepio

Musl images can be even lighter, as it includes used libraries we can skip a runtime like alpine. It should also eliminate some runtime issues I've had in the past (related to glibc mostly).

But I think we can't build musl for aarch64 because of a problem in ring. So I either have to remove multi-platform docker builds, or wait for an upstream fix.

What I tried

See musl-docker branch

Example of failed CI action

#18 1218.1   cc1: error: unrecognized command-line option '-m64'
  • Tried adding ENV RUSTFLAGS='-C linker=x86_64-linux-gnu-gcc'
  • Tried adding linux-musl-dev dependency
  • Tried clux/muslrust/
  • Tried even more envs, no luck

I think the problem is that Cargo is using the wrong linker while building on ARM64.

I also think this is wrong: --target x86_64-unknown-linux-musl as I should probably have aarch64-unknown-linux-musl. But how do I differentiate the target between builds? I use this docker push action which deals with pushing various builds. But I can't pass opts here.

      - name: Build and push Docker image
        uses: docker/build-push-action@v4
        with:
          context: .
          push: true
          provenance: false
          platforms: linux/amd64,linux/arm64
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}

Should I get rid of this action and manually use matrix?

Or is there a way I can use a --target that is dynamic / conditional on the current architecture?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions