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

CI/Linux: Build/publish Docker images used to create DEB packages #695

Merged
merged 1 commit into from
Sep 11, 2024

Conversation

guihkx
Copy link
Collaborator

@guihkx guihkx commented Sep 10, 2024

From now on, whenever we detect a modification to any of the 'ubuntu-*' Dockerfiles in the 'Dockerfiles' directory, a new image will be built first (with 'docker build'), and only then it will be used to actually build the app and generate DEB packages.

If no changes to these Dockerfiles are detected, we'll simply 'docker pull' the already-existing image from the GitHub Container Registry to build the app, which will give us a faster build time.

This new approach allows us to immediately test changes made to these Dockerfiles, without having to first build them locally, test them, push them to an OCI registry, and only then use them on GitHub Actions.

Please note that these images will only be pushed to the GitHub Container Registry if all three conditions below are met:

  • We are not on a pull request
  • We are on the master branch
  • We are on the 'nuttyartist/notes' repository

@nuttyartist If this gets merged, hopefully you don't have to do anything else and the images will automatically published to this page: https://github.com/nuttyartist/notes/pkgs/container/notes

If you guys like this idea, I can do the same for the RPM and AppImage build jobs next.

@guihkx
Copy link
Collaborator Author

guihkx commented Sep 10, 2024

I've tested the resulting DEB packages by installing and running them using podman on clean container images of their respective distributions:

  • Ubuntu 20.04 (command used: podman run --rm -e DISPLAY -v $XAUTHORITY:/root/.Xauthority:ro -v /tmp/.X11-unix:/tmp/.X11-unix -v ./notes_20.04.deb:/notes.deb ubuntu:20.04 bash -c 'apt-get update && apt-get install -y /notes.deb && notes')

    Screenshot

    image

  • Ubuntu 22.04 (command used: podman run --rm -e DISPLAY -v $XAUTHORITY:/root/.Xauthority:ro -v /tmp/.X11-unix:/tmp/.X11-unix -v ./notes_22.04.deb:/notes.deb ubuntu:22.04 bash -c 'apt-get update && apt-get install -y /notes.deb && notes')

    Screenshot

    image

  • Ubuntu 23.10 (command used: podman run --rm -e DISPLAY -v $XAUTHORITY:/root/.Xauthority:ro -v /tmp/.X11-unix:/tmp/.X11-unix -v ./notes_23.10.deb:/notes.deb ubuntu:23.10 bash -c 'apt-get update && apt-get install -y /notes.deb && notes')

    Screenshot

    image

@nuttyartist
Copy link
Owner

That's really great, @guihkx. Thanks!

If you guys like this idea, I can do the same for the RPM and AppImage build jobs next.

Yes, that would be awesome.

From now on, whenever we detect a modification to any of the 'ubuntu-*'
Dockerfiles in the 'Dockerfiles' directory, a new image will be built
first (with 'docker build'), and only then it will be used to actually
build the app and generate DEB packages.

If no changes to these Dockerfiles are detected, we'll simply
'docker pull' the already-existing image from the GitHub Container
Registry to build the app, which will give us a faster build time.

This new approach allows us to immediately test changes made to these
Dockerfiles, without having to first build them locally, test them,
push them to an OCI registry, and only then use them on GitHub Actions.

Please note that these images will only be pushed to the GitHub Container
Registry if _all_ three conditions below are met:

- We _are not_ on a pull request
- We _are_ on the master branch
- We _are_ on the 'nuttyartist/notes' repository
@guihkx
Copy link
Collaborator Author

guihkx commented Sep 10, 2024

v2 changes (final):

  • Updated the Build, package and lint build step to also mount the $GITHUB_OUTPUT file inside the container, so we can set variables useful for GitHub Actions from there.
  • Moved the Grab deb package name build step into the Dockerfiles/ubuntu_deb_entrypoint.sh build script.
  • Removed leftover FIXME comments.
  • Added useful comments to Dockerfiles explaining that you must mount the current git tree into the /src directory inside the container.

@guihkx guihkx merged commit 51ba67b into nuttyartist:master Sep 11, 2024
17 checks passed
@guihkx guihkx deleted the ci-linux-docker-publish-deb branch September 11, 2024 23:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants