Musl docker images #912
Labels
No labels
Bug
Cherry-picking
Database
Dependencies
Dependencies/Renovate
Difficulty
Easy
Difficulty
Hard
Difficulty
Medium
Documentation
Enhancement
Good first issue
Help wanted
Inherited
Matrix/Administration
Matrix/Appservices
Matrix/Auth
Matrix/Client
Matrix/Core
Matrix/Federation
Matrix/Hydra
Matrix/MSC
Matrix/Media
Meta
Meta/CI
Meta/Packaging
Priority
Blocking
Priority
High
Priority
Low
Security
Status/Blocked
Status
Confirmed
Status
Duplicate
Status
Invalid
Status
Needs Investigation
To-Merge
Wont fix
old/ci/cd
old/rust
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
continuwuation/continuwuity#912
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
So continuwuity historically provided static binaries built using Nix. Unfortunately due to changes in the build, that no longer works for cross compilation - and the team doesn't have the Nix knowledge to maintain it. Instead we want to build the binary using docker, building on our existing dynamic binary pipeline.
We want to build statically linked musl binaries. For that we need the static version of at least liburing built against musl, possibly some other stuff. Debian doesn't provide this. I've tried running a build process on alpine - unfortunately something in the build of our process needs to dynamically link stuff that doesn't work on alpine.
So what needs to happen is you need to update the main debian build image to switch between glibc and musl binaries - when building for glibc, do the process we already have in place. When building for musl, copy the libraries from an alpine container and configure package config to find the system dependencies there
See also:
#911
#740
@gan got static compiles working for ARM64 outside of docker: https://codeberg.org/skhron/continuwuity_compilation_lxc/src/branch/main/autostart.sh
I just tried translating the work of @gan into Dockerfile instructions, and it worked!
I have though only tried to build for target aarch64-alpine-linux-musl, so please test it with other targets as well, those who have the platforms available:
https://forgejo.ellis.link/oddlid/continuwuity/src/branch/docker_musl_build/docker/Dockerfile
Is that a cross-compile?
I haven’t tested if that works yet. I’ve only run it on my mac, where Docker is aarch64-linux.
This was more intended as a first step to get static compilation working at all, and then we can add more changes to get it working for cross-compilation, from/to any platform, if possible.
I did some quick tests now, and it does NOT work to cross-compile with the Dockerfile as is.
I tried some modifications to derive from rust:alpine instead of alpine:edge, since that image has rust installed via rustup, so that one can ”rustup target add”, but it seems we need gcc/g++ in cross-compile version as well, since it fails with ”unrecognized command-line option ’-m64’” during compilation.
Another thing I haven’t tried yet, is to run the build on another host platform and adjust ”—build-arg BUILD_TARGET=xxx” accordingly. I’ll report back after having tried that.
The latter should work fine, but we don't have any arm runners. I'll have a look when I get an opportunity. Challenge is probably figuring out the thing that this is doing that the one in the repo is not.
I’m sorry to report that running ”docker build —build-arg BUILD_TARGET=x84_64-alpine-linux-musl …” on an x86_64 linux host failed at the linking stage:
/usr/lib/gcc/x86_64-alpine-linux-musl/15.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: attempted static link of dynamic object
/usr/lib/liburing.so' /usr/lib/gcc/x86_64-alpine-linux-musl/15.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: attempted static link of dynamic object
/usr/lib/libstdc++.so'/usr/lib/gcc/x86_64-alpine-linux-musl/15.2.0/../../../../x86_64-alpine-linux-musl/bin/ld: attempted static link of dynamic object `/usr/lib/libc.so'
Why the same worked on arm64 but not x86_64 is a mystery to me.
So, this might not be a feasible solution after all.