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

Use docker buildx for ftl-build containers #69

Merged
merged 15 commits into from
Sep 10, 2023
Merged

Conversation

DL6ER
Copy link
Member

@DL6ER DL6ER commented Jun 2, 2023

What does this implement/fix?

This is a complete rewrite of how the ftl-build containers are built. Instead of fine-tuned, hand-crafted and with intense care written individual docker files for every target architecture (that were always creating hours of work when the distro was upgraded), we switch to docker buildx with one simple Dockerfile used for everything. This makes maintenance a lot easier and greatly simplifies the overall process.

Furthermore, this resolves one particular issue we have had a few times in the past with the dependence on particular glibc versions by switching everything to musl-based so FTL will from now on ship as fully static batteries-included binaries that can run on the irrespective of the operating system version.

This PR removes support for armv4 (last supporting Debian release was Stretch) and armv5 as these architectures are not supported by Alpine. I tried to create an armv5 binary using debian:stretch and :bullseye as base image but it - to my surprise - created an armv6 binary we cannot use.

Update: We will still generate armv4T and armv5TE binaries using Debian builders. The dependency on a sufficiently recent GLIBC remains.

The resulting containers should be tagged v2.0

Related issue or feature (if applicable): N/A

Pull request in docs with documentation (if applicable): N/A


By submitting this pull request, I confirm the following:

  1. I have read and understood the contributors guide, as well as this entire template. I understand which branch to base my commits and Pull Requests against.
  2. I have commented my proposed changes within the code.
  3. I am willing to help maintain this change if there are issues with it later.
  4. It is compatible with the EUPL 1.2 license
  5. I have squashed any insignificant commits. (git rebase)

Checklist:

  • The code change is tested and works locally.
  • I based my code and PRs against the repositories developmental branch.
  • I signed off all commits. Pi-hole enforces the DCO for all contributions
  • I signed all my commits. Pi-hole requires signatures to verify authorship
  • I have read the above and my PR is ready for review.

DL6ER added 2 commits May 31, 2023 02:24
…p using fine-crafted hand-optimized individual containers for every target that tend to break in surprising ways on any major OS update

Signed-off-by: DL6ER <dl6er@dl6er.de>
… as armv6), tested with stretch and bullseye

Signed-off-by: DL6ER <dl6er@dl6er.de>
@DL6ER DL6ER added the ftl-build label Jun 2, 2023
@DL6ER DL6ER requested a review from yubiuser June 2, 2023 13:34
@DL6ER
Copy link
Member Author

DL6ER commented Jun 2, 2023

I left the removal of the Debian-based image intentionally in the git history. Just in case we decide to revisit Debian-based builds at some point.

@DL6ER DL6ER requested a review from PromoFaux June 2, 2023 13:39
DL6ER added 2 commits June 3, 2023 13:46
…atch, build on pushes to ftl-build related files

Signed-off-by: DL6ER <dl6er@dl6er.de>
Signed-off-by: DL6ER <dl6er@dl6er.de>
@DL6ER DL6ER force-pushed the ftl-build/buildx branch 2 times, most recently from 096695d to 1dcb90e Compare June 3, 2023 14:15
Signed-off-by: DL6ER <dl6er@dl6er.de>
@DL6ER DL6ER marked this pull request as draft June 3, 2023 15:22
@DL6ER DL6ER force-pushed the ftl-build/buildx branch 2 times, most recently from 9e87ab4 to fc75b95 Compare June 3, 2023 18:58
…d managed separately

Signed-off-by: DL6ER <dl6er@dl6er.de>
@DL6ER
Copy link
Member Author

DL6ER commented Jun 4, 2023

@PromoFaux Alongside this change the FTL binary names change to

  • pihole-FTL-amd64
  • pihole-FTL-386
  • pihole-FTL-armv6
  • pihole-FTL-armv7
  • pihole-FTL-arm64
  • pihole-FTL-riscv64

Not sure if this needs some modifications in the v6 docker container?

@DL6ER DL6ER requested review from PromoFaux and yubiuser June 4, 2023 16:57
@DL6ER DL6ER marked this pull request as ready for review June 4, 2023 16:57
# Run the full test suite to ensure that the container is still capable of running the tests
RUN git clone https://github.com/pi-hole/FTL.git \
RUN git clone https://github.com/pi-hole/FTL.git --branch "${GIT_BRANCH}" \

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will checkout sources for every platform you're building which is not optimal. You can just checkout against the build platform in a dedicated stage and mount the sources here. And for cache optim you should also init and checkout instead of cloning like: https://github.com/crazy-max/docker-fail2ban/blob/c779f371005948587ed90fcc28cfd819033a8083/Dockerfile#L6-L11

Signed-off-by: DL6ER <dl6er@dl6er.de>
Signed-off-by: DL6ER <dl6er@dl6er.de>
@DL6ER DL6ER force-pushed the ftl-build/buildx branch 7 times, most recently from 4c5be38 to 3ea78d3 Compare June 8, 2023 09:23
Signed-off-by: DL6ER <dl6er@dl6er.de>
Copy link
Member

@yubiuser yubiuser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You removed the pull_request trigger in ftl-build.yml (L3-6) so there is no need to check for that trigger anymore.

.github/actions/merge-and-push/action.yml Outdated Show resolved Hide resolved
.github/actions/merge-and-push/action.yml Outdated Show resolved Hide resolved
.github/workflows/ftl-build.yml Outdated Show resolved Hide resolved
.github/workflows/ftl-build.yml Outdated Show resolved Hide resolved
.github/workflows/ftl-build.yml Outdated Show resolved Hide resolved
.github/workflows/ftl-build.yml Outdated Show resolved Hide resolved
.github/workflows/ftl-build.yml Outdated Show resolved Hide resolved
container: alpine:3.18
- platform: linux/386
container: alpine:3.18
- platform: linux/arm/v5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the debian ones not be linux/arm/v4 and linux/arm/v5? Seems we have linux/arm/v6 twice...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just remember a very confusing conversation about this.
Pinging: @DL6ER

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, because Debian always builds for one architecture lower. In the sense of "if you have an armv6 you can definitely run armv5 binaries". Alpine doesn't do this.

That's why

  • debian/armv5 actually builds armv4 binaries,
  • debian/armv6 actually builds armv5 binaries, however
  • alpine/armv6 actually builds armv6

@PromoFaux
Copy link
Member

FTL will from now on ship as fully static batteries-included binaries that can run on the irrespective of the operating system version.

Forgive my naivety on this kind of thing, but does this mean we can drop some things from the dependencies? (i.e libidn, nettle etc)

@DL6ER
Copy link
Member Author

DL6ER commented Jul 9, 2023

Yes, everywhere except the non-static builds (armv4 and v5)

DL6ER and others added 2 commits July 30, 2023 19:27
Co-authored-by: yubiuser <ckoenig@posteo.de>
Signed-off-by: DL6ER <DL6ER@users.noreply.github.com>
Signed-off-by: DL6ER <DL6ER@users.noreply.github.com>
@DL6ER
Copy link
Member Author

DL6ER commented Jul 30, 2023

Interestingly, it seems that the most recent commit which did nothing else than docker/build-push-action@v3 -> v4 broke the final deployment step. The deployment to Docker hub works, but not any longer to GHCR. Maybe it is a hiccup.

@yubiuser
Copy link
Member

I checked the previous runs and compared them to the failed ones.
Usually the SHA that is pushed to Docker Hub and GHCR for each image (Alpine/Debian) should be the same. However now it tries to push another image/SHA to GHCR than to Docker Hub.

@yubiuser
Copy link
Member

Could the issue be this line:

working-directory: /tmp/digests/dockerhub/${{ inputs.platform }}

Where dockerhub is hard-coded. It was never an issue before but maybe now? There should be an ghcr dir as well so maybe GHCR needs its own digests now...

@PromoFaux
Copy link
Member

Co-authored-by: yubiuser <ckoenig@posteo.de>
Signed-off-by: Adam Warner <me@adamwarner.co.uk>
@DL6ER
Copy link
Member Author

DL6ER commented Aug 1, 2023

This seems to have fixed it. What else do we need for this PR to land? All FTL v6.0 builds are using this containers for a while: https://github.com/pi-hole/FTL/blob/4ac9f120f5750c2a179b2de86e0a35c64adbf5aa/.github/Dockerfile#L2

@yubiuser
Copy link
Member

yubiuser commented Aug 1, 2023

I think nothing. It's your PR if you think it's ready, lets us know to review.

@DL6ER DL6ER requested a review from a team September 9, 2023 15:54
Copy link
Member

@PromoFaux PromoFaux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Miles behind on reviews and things. Sorry!

@PromoFaux PromoFaux merged commit 3a63fd4 into master Sep 10, 2023
9 checks passed
@yubiuser yubiuser deleted the ftl-build/buildx branch September 10, 2023 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants