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

Add rootless container builds via Docker/Podman #419

Merged
merged 1 commit into from
Mar 30, 2023

Conversation

atc0005
Copy link
Owner

@atc0005 atc0005 commented Mar 30, 2023

  • update builder image Dockerfile
    • copy project/repo content into container at build time - explicitly changing owner:group to builduser
    • explicitly create new builduser user and group
      • this is explicitly used for Docker-based builds
    • set /builds as the working directory
    • add new .dockerignore file to exclude the same items as the .gitignore file
    • set Git safe.directory logic at system level
  • update Makefile recipes
    • add separate docker/podman variants of container-based project build recipes - each uses slightly different logic to achieve rootless container execution
    • explicitly emit the tool used to perform specific tasks
      • this can be useful to help explain why a generated builder image does not appear in the docker image ls output as a sysadmin might expect (if it was instead built with the docker command)
    • rename/remove the helper build recipe from the help recipe output (not useful to call directly)
    • to explicitly run the build container as the builduser user that is created during build image generation when using Docker to build/run containers (Podman uses different settings)
    • to send xz compressed output to stdout, then redirect to a target file
      • this works around failures to chmod and chgrp the compressed copy of input files when run within a non-root container
    • to explicitly bind mount the release_assets path into /builds/release_assets (using the same Makefile variable) read/write (instead of relying on implied read/write access)
    • to explicitly use /builds as the working directory

This collection of changes allows reliably building this project using either Docker or Podman via a "rootless" container.

- update builder image Dockerfile
  - copy project/repo content into container at build time
    - explicitly changing owner:group to `builduser`
  - explicitly create new `builduser` user and group
    - this is explicitly used for Docker-based builds
  - set `/builds` as the working directory
  - add new `.dockerignore` file to exclude the same items as the
    `.gitignore` file
  - set Git `safe.directory` logic at system level
- update Makefile recipes
  - add separate docker/podman variants of container-based project
    build recipes
      - each uses slightly different logic to achieve rootless
        container execution
  - explicitly emit the tool used to perform specific tasks
    - this can be useful to help explain why a generated builder image
      does not appear in the `docker image ls` output as a sysadmin
      might expect (if it was instead built with the `docker` command)
  - rename/remove the helper build recipe from the `help` recipe
    output (not useful to call directly)
  - to explicitly run the build container as the `builduser` user that
    is created during build image generation when using Docker to
    build/run containers (Podman uses different settings)
  - to send `xz` compressed output to stdout, then redirect to a
    target file
    - this works around failures to `chmod` and `chgrp` the compressed
      copy of input files when run within a non-root container
  - to explicitly bind mount the `release_assets` path into
    `/builds/release_assets` (using the same Makefile variable)
    read/write (instead of relying on implied read/write access)
  - to explicitly use `/builds` as the working directory

This collection of changes allows reliably building this project using
either Docker or Podman via a "rootless" container.
@atc0005 atc0005 added enhancement New feature or request builds CI labels Mar 30, 2023
@atc0005 atc0005 added this to the Next Release milestone Mar 30, 2023
@atc0005 atc0005 self-assigned this Mar 30, 2023
@atc0005 atc0005 merged commit f4a8769 into master Mar 30, 2023
@atc0005 atc0005 deleted the add-rootless-container-build-support branch March 30, 2023 11:10
atc0005 added a commit that referenced this pull request Mar 31, 2023
This was intended to be included along with the recent rootless
container builds work.

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

Successfully merging this pull request may close these issues.

1 participant