Skip to content

hack: support even more customization #211

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

Merged

Conversation

phlogistonjohn
Copy link
Collaborator

@phlogistonjohn phlogistonjohn commented Jul 21, 2025

Depends on: #210
Depends on: #212

This PR fleshes out something I've been wanting for a while, a way to record and repeatedly build custom samba server images. These customizations include things like bringing in samba, ceph, or other dependencies from special rpm repos; tweaking other build container build arguments; or using custom arguments not on the command line, so that I don't have to rely heavily on my shell history.

Another special customization is the ability to build and install sambacc from a git checkout. This allows for a faster and cleaner build and install of a sambacc development branch. It is based on the instructions https://github.com/samba-in-kubernetes/samba-container/blob/master/docs/development.md#build-stage

The pr starts off with various cleanup patches an prep work before adding the new config file (in pieces).

A config file looks something like this:

[image]
custom_repos =
    http://192.168.64.8:8016/pulp/content/samba-kmip/config.repo
    http://192.168.64.8:8016/pulp/content/ceph-fscrypt-x86_64/config.repo
    https://copr.fedorainfracloud.org/coprs/phlogistonjohn/sambacc-extras-deps/repo/centos-stream+epel-next-9/phlogistonjohn-sambacc-extras-deps-centos-stream+epel-next-9.repo
package_selection = forcedevbuilds
ceph_from_custom = 1
extra_arguments = --cache-ttl=6h

[sambacc]
base_image = sambacc:ci
sambacc_repo = https://github.com/phlogistonjohn/sambacc
sambacc_ver = jjm-keybridge
distname=latest

and can be run something like this: /hack/build-image --debug -i quay.io/phlogistonjohn/samba-server:custom-centos-amd64-x2 -C foo.ini

Copy link

dpulls bot commented Jul 22, 2025

🎉 All dependencies have been resolved !

Copy link

mergify bot commented Jul 22, 2025

This pull request now has conflicts with the target branch. Please resolve these conflicts and force push the updated branch.

@phlogistonjohn phlogistonjohn changed the title habk: support even more customization hack: support even more customization Jul 22, 2025
@phlogistonjohn phlogistonjohn force-pushed the jjm-custom-custom-2 branch 3 times, most recently from 91f5930 to a7a0ae7 Compare July 22, 2025 13:58
@phlogistonjohn phlogistonjohn force-pushed the jjm-custom-custom-2 branch 2 times, most recently from d26fb4e to 4e1f6c7 Compare August 1, 2025 15:31
@phlogistonjohn phlogistonjohn marked this pull request as ready for review August 1, 2025 15:36
@phlogistonjohn
Copy link
Collaborator Author

Do note that I am building this mainly for my use, as well as others on our dev community, but I don't expect a general audience. So I expect it to be niche and a tad obscure :-)

Copy link
Collaborator

@anoopcs9 anoopcs9 left a comment

Choose a reason for hiding this comment

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

Generally lgtm. See below for some comments.

The commit message for images/server: allow --ceph-from-custom=1 needs some cleanup and would you like placing an example .ini somewhere in the repository (with image and sambacc sections)?

Allow `--ceph-from-custom=1` to be equivalent to `--ceph-from-custom`.
This makes it easier to write a Dockerfile without conditionals tricks
when constructing the command based on build args.
Allow `--ceph-from-custom=0` for the same reason.
The former is better when used directly from the CLI but that's rare.

Signed-off-by: John Mulligan <[email protected]>
This build arg takes either `0` or `1` and defaults to 0. It can be used
to disable automatically setting up ceph repos as it tells the install
script that ceph repos are coming from the custom repos list.

Signed-off-by: John Mulligan <[email protected]>
Fit in line length.

Signed-off-by: John Mulligan <[email protected]>
Don't call the same function many times when that function's value is
never expected to change at this scope.

Signed-off-by: John Mulligan <[email protected]>
I find lambda to be a bit of an unpleasant thing and try to remove it
when possible. Since all uses of lambda in this code are calling
the same function we can remove the function (and unchanging) argument
and have the variable section map to the run function's remaining
kwargs.

Signed-off-by: John Mulligan <[email protected]>
I constantly rely on my shell history to make custom modifications to
create images based on work-in-progress package builds. Adding a
customizations file allows me to store things in a file so I can run:
```
./hack/build-image \
    -i quay.io/phlogistonjohn/samba-server:custom-centos-amd64-x2 \
    -C foo.ini
```
instead of a long line of embedded junk on the shell. No docs yet
because this is for me. :-)

Signed-off-by: John Mulligan <[email protected]>
Split up the function setting up the docker buildx or podman build
commands so that the higher level function is shorter overall.

Best viewed with git diff -w

Signed-off-by: John Mulligan <[email protected]>
Re-run `black` on the hack/build-image script.

Signed-off-by: John Mulligan <[email protected]>
In the functions that create docker buildx commands or podman build
commands allow passing a custom container file. This will be used by a
future change that writes a temporary edited container file that needs
to be passed to the container commands.

Signed-off-by: John Mulligan <[email protected]>
Add support for adding a sambacc section to the new customize config
that will create a modified version of the container file. This modified
container builds sambacc packages from a git branch (or tag) and then
installs that instead of the default install source.

It is basically a code version of the manual instructions [1] in the
repo.
[1] https://github.com/samba-in-kubernetes/samba-container/blob/master/docs/development.md#build-stage

Signed-off-by: John Mulligan <[email protected]>
@phlogistonjohn
Copy link
Collaborator Author

Updated. PTA(nother)L

Copy link
Collaborator

@avanthakkar avanthakkar left a comment

Choose a reason for hiding this comment

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

LGTM!

@mergify mergify bot merged commit 90587f0 into samba-in-kubernetes:master Aug 5, 2025
41 checks passed
@phlogistonjohn phlogistonjohn deleted the jjm-custom-custom-2 branch August 5, 2025 12:07
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