Skip to content
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

Statically Linked Binary and MultiArch Docker images for ARM64 and AMD64 Architectures #23

Open
da-moon opened this issue Aug 26, 2021 · 14 comments
Labels
enhancement New feature or request

Comments

@da-moon
Copy link
Contributor

da-moon commented Aug 26, 2021

Is your feature request related to a problem? Please describe.

  • Convco, Is distributed as a deb package. this can make it difficult to use in non-Debian environments, such as Alpine based Docker images, which is the base image I use most often with Visual Studio Code Remote - Containers to set up my development environment
  • Many laptop manufacturers are moving to use aarch64 as their CPU architecture, especially after Apple released the M1 chip. I have a Surface Pro X and it is based on aarch64 and I have to compile Convco from the source there, which as you know, is a CPU-intensive task.

Describe the solution you'd like

  • static builds for both aarch64 and amd64 architecture
  • Multi-Arch Docker images with Convco statically built. I would like to be able to use COPY directive in my own Dockerfiles, like COPY --from=convco/convco:latest /usr/bin/convco /usr/local/bin/convco to add Convco to my image.

Describe alternatives you've considered

  • I have my own docker image in which I am cross-compiling and statically linking Convco
@da-moon da-moon added the enhancement New feature or request label Aug 26, 2021
@hdevalke
Copy link
Collaborator

The docker image is based on alpine, because of an issue in gitlab to use single binary images, see: #9 (comment) .

We can probably build for multiple architectures using images based on https://github.com/rust-embedded/cross.
Seems like docker hub removed the automated builds unless i register convco as an open source project. So i will have either register or change the workflow to build and push from a github action.

@da-moon
Copy link
Contributor Author

da-moon commented Aug 26, 2021

I can get it working for you if you are OK with using my alpine-rust-builder image. I already have cross-compiled Convco in Alpine Docker Image.

Setting up a job on Github actions is also quite easy, I have a bash script that you can use in Github actions to build the image using docker buildx plugin. Recently, I have moved on to using docker buildx bake which makes building and pushing images even easier. this is the github action I am using to build and push all my docker images.

@hdevalke
Copy link
Collaborator

hdevalke commented Sep 9, 2021

I am open for a pull request. I had trouble to cross compile using cross (linker problems).
It would be good to move the build of the images to github actions instead of docker hub auto builds

@da-moon
Copy link
Contributor Author

da-moon commented Sep 10, 2021

OK. I will open a pr tmrw

@da-moon
Copy link
Contributor Author

da-moon commented Sep 12, 2021

@hdevalke sorry about the delay; I was having difficulties with the Nvidia driver on my machine.
#28

@hdevalke
Copy link
Collaborator

Currently the build fails, because the version of curl should be updated.

 > [linux/amd64 upx-downloader 2/3] RUN                                                                                                                            apk add --no-cache                                                                                                             curl=7.78.0-r0                                                                                                               jq=1.6-r1                                                                                                                    xz=5.2.5-r0 ;:
#30 0.112 fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/main/x86_64/APKINDEX.tar.gz
#30 0.356 fetch https://dl-cdn.alpinelinux.org/alpine/v3.14/community/x86_64/APKINDEX.tar.gz
#30 0.629 ERROR: unable to select packages:
#30 0.668   curl-7.79.0-r0:
#30 0.668     breaks: world[curl=7.78.0-r0]

It still worked locally, but docker buildx .. was using a cache.
I think it is easier to remove the versions than to have to maintain them.

@da-moon
Copy link
Contributor Author

da-moon commented Sep 20, 2021

@hdevalke That's something I have been struggling with. hadolint complains if you don't pin versions, but I have experienced package breakage too often when I pinned releases. Initially, I thought it was because I was using edge packages but it looks like that's also the case in stable packages.
I will leave it to your discretion to keep/remove packages; same with the compression layer; if you think it is valuable, keep them; if you think the cons outweigh the pros, remove them.

@hdevalke
Copy link
Collaborator

I removed the versions, but now the build was stuck: https://github.com/convco/convco/runs/3645509471?check_suite_focus=true#step:6:808

I can't reproduce it locally though. I could remove the upx step, but I don't think the issue is caused by it.

@da-moon
Copy link
Contributor Author

da-moon commented Sep 22, 2021

I will explore this a bit and get back to you

@da-moon
Copy link
Contributor Author

da-moon commented Sep 27, 2021

I think we can drop patch-releases and use this approach hadolint/hadolint#204 (comment)

I will commit a fix soon

The problem of freezing might be due to build cache ( cache-from directive in docker-bake.hcl )

@hdevalke
Copy link
Collaborator

hdevalke commented Oct 2, 2021

I removed the upx step and the build was successfully. https://github.com/convco/convco/actions/runs/1296474571

@scizzorz
Copy link

Is there an update to this? I'd love to use convco to automate some release work, but I'm having trouble arranging the installation in our CI system because it's not Ubuntu / Debian based.

@hdevalke
Copy link
Collaborator

hdevalke commented Sep 1, 2023

The docker image already contains statically linked binaries. You should be able to use COPY --from=.. in your Dockerfile. The binary in the convco image is /entrypoint.

@scizzorz
Copy link

scizzorz commented Sep 1, 2023

Oh, great! Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants