-
-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use cross-compilation for CI, build the Docker image from source. #85
base: main
Are you sure you want to change the base?
Conversation
Thanks for this, great work! Were you able to cross compile the musl targets as well as the Windows arm64 binaries? |
I haven't tried, I'll look into it |
aarch64 Windows doesn't build due to this, that will have to wait until ring 0.17: briansmith/ring#1167 |
aarch64-unknown-linux-musl built just fine on Arch Linux, fails on Ubuntu though 🤷 |
x86_64-unknown-linux-musl seems to build just fine, couldn't get aarch64-unknown-linux-musl working though, not sure why, works on my machine ™️ Not sure what's different with Arch's musl packages, maybe they include arm64 builds or something, I tried installing musl:arm64 in github actions but it didn't work either |
Actually no, it also fails with the same error on Arch, I was building the x86 musl target instead of aarch64 |
I'll merge your changes once I am ready to launch v0.4 in about 4 to 6 weeks. I need to test the cross-compiled binaries properly. Whenever you have a chance please remove |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
I did some change on my version to allow using from source releases FROM docker.io/debian:bookworm-slim AS source
WORKDIR /source
ARG VERSION="0.3.8"
ADD https://github.com/stalwartlabs/mail-server/archive/refs/tags/v$VERSION.tar.gz /tmp/v$VERSION.tar.gz
RUN tar --strip-components=1 -C /source -xzf /tmp/v$VERSION.tar.gz And then - COPY . .
+ COPY --from=source /source . Maybe it's worth having one step only for the source |
55ca2de
to
59b0a16
Compare
I think its better to just checkout the version tag in git |
Not sure how to get musl cross-compile targets working, probably would need to build musl with musl-cross-make or use https://github.com/rust-cross/rust-musl-cross or something |
Yeah but you do not want to have the burden of git all of such stuff just to build an image. And having to clone. Etc.. Only from source ensures you can build the image from a production server without too much tooling |
But what if I want to build from the current working copy that is not a release ? This contribution, as it is, makes it easy for me to contribute, just because I want to build a image and test it against a random commit, or even a dirty working copy, and not from a registered tag released on github. Besides, I see an anti-pattern here : EDIT: And the dockerfile is in the project git's repository, it then sounds very natural to git clone and checkout the desired tag to get the proper Dockerfile and related code version... |
Then only use Look in this example how it was easy to apply patches on the source since I have it in a single step: https://github.com/wdes/mails.wdes.eu/blob/dfefb2ca9e70aa59409180b583e334c42fc60356/docker/Dockerfile#L4-L21
As I said, all approaches can remain, but using one single layer for the source helps everyone build the final image
yes and no, sometimes you need to build from source. Hello images not cross arch ^^ |
I don't think the Dockerfile in the root of the repo should worry about downloading any code. Maybe a separate |
Well, the musl target seems to just work with cross, aarch64 windoze should also work but ring needs to be updated to 0.17, ldap3 apparently still depends on ring 0.16 |
That should be fixed when this is merged inejge/ldap3#116 |
aarch64 mac build seems to have just worked |
Hi, thanks for all the work! Just so you know, I am currently working on version
So please do not spend too much time fixing the CI jobs as they will probably need to be tweaked for |
Ok I give up on aarch64-windoze for now, hickory-resolver didn't yet publish a version that doesn't depend on ring 0.16, they did bump it in the repo though.
As long as the database drivers aren't using native libraries, it should work fine /shrug. RocksDB is vendored in the crate, only FoundationDB seems to be particularly painful to deal with. |
https://github.com/33KK/mail-server/actions/runs/6955297536/job/18923787212 not sure whats going on here, whatever, will deal with this later i guess |
I've just fixed this on the development branch. It seems that one of those targets is a 32 bit platform and |
I did some tests on $ RUSTFLAGS="-C linker=aarch64-linux-gnu-gcc" cargo build --release --target aarch64-unknown-linux-gnu --no-default-features --features "sqlite postgres mysql rocks elastic s3 redis"
Compiling librocksdb-sys v0.11.0+8.1.1
error: failed to run custom build command for `librocksdb-sys v0.11.0+8.1.1`
Caused by:
process didn't exit successfully: `/home/a/mail-server/target/release/build/librocksdb-sys-104455b5f5c54342/build-script-build` (exit status: 101)
--- stderr
/usr/include/stdint.h:26:10: fatal error: 'bits/libc-header-start.h' file not found
thread 'main' panicked at /home/a/.cargo/registry/src/index.crates.io-6f17d22bba15001f/librocksdb-sys-0.11.0+8.1.1/build.rs:40:10:
unable to generate rocksdb bindings: ClangDiagnostic("/usr/include/stdint.h:26:10: fatal error: 'bits/libc-header-start.h' file not found\n")
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish... There is an open issue at the Rust-RocksDB repository regarding this issue but it seems that the devs behind Fuel seem to have found a workaround to be able to cross compile it. There's no rush to fix this, we'll continue using QEMU to compile Edit: I was using
|
RocksDB fails to link now, no idea why. May be relevant https://gitlab.com/famedly/conduit/-/merge_requests/261/diffs |
Hi @33KK , I finally "merged" your CI job and Dockerfile. I say "merged" because there were multiple conflicts after the Overall the CI jobs great, only the Thank you! |
actions-rs
Dockerfile
doesn't download binaries anymoreedge
tagAlso includes the opentelemetry update from #57 since it's necessary for this to build. This should be easy enough to adapt for the standalone JMAP/IMAP/SMTP servers.