blue-build / modules

BlueBuild standard modules used for building your Atomic Images
Apache License 2.0
22 stars 26 forks source link

feat: versioning modules #208

Open xynydev opened 2 months ago

xynydev commented 2 months ago

We should discuss the approach to use for versioning modules. Of course using the module repository image hash or something like that could work, but it would be best IMO if it was possible to use SemVer for the modules, and pin each module to a major version such that non-breaking changes are automatically updated to.

gmpinder commented 2 months ago

In the recipe we could have a top level property where you can specify the version of the modules image you want. We could default it to the current major version or to latest and let the user decide to override that

xynydev commented 2 months ago

Versioning for individual modules would be better, though. Not sure how that would work, but I have some ideas I'll post later.

xynydev commented 1 month ago

Turns out I didn't get to posting my ideas earlier... Anyway, here's some I can think of now.

A: Unified module repository versioning

B: Naive directory versioning

C: Directory versioning and multiple images

Same as option B, but

D: The no breaking changes strategy


That's all I can think of for now. I'm inclided to just go all in with option C, or go the lazy route with D. Please comment your thoughts below.

fiftydinar commented 1 month ago

@xynydev

C sound the best imo.

Everything else has some cons in some way.

xynydev commented 1 month ago

Aight, I wont make a branch or PR for it now, but I'll outline the implementation details I have in mind more clearly.

Github Action with two jobs:

GitHub Action with one job:

CLI would use the individual containers by default, and allow specifying the version manually. Unsure what to do with source:.

gmpinder commented 1 month ago

I'm liking this idea so far. If we can keep the classic ghcr.io/blue-build/modules:latest for backwards compatibility, then I could definitely add functionality to pull the module image for each module type we have. We would just have to have a way to support creating new modules without worrying about updating the CLI for each new one.

I could add some logic to check for the presence of a certain module image like by using skopeo and then do a bind mount on that RUN instruction for that particular module. Else we will assume that the module is a user-created one. We can continue to use source as-is for 3rd-party modules that the user would want to use. As for determining the version to use on a per module basis, we could just add a version property or go with the @ syntax. We could specify that the @ syntax only works for the builtin modules if we really want to

gmpinder commented 1 month ago

Here's the module stage we have currently:

# Copy modules
# The default modules are inside blue-build/modules
# Custom modules overwrite defaults
FROM scratch AS stage-modules
COPY --from=ghcr.io/blue-build/modules:latest /modules /modules
{%- if self::modules_exists() %}
COPY ./modules /modules
{% endif %}

And here's a portion of the module run that I could edit to handle pulling the particular module image

        {%- if let Some(source) = module.source %}
  --mount=type=bind,from={{ source }},src=/modules,dst=/tmp/modules,rw \
        {%- else %}
  --mount=type=bind,from=stage-modules,src=/modules,dst=/tmp/modules,rw \
        {%- endif %}
xynydev commented 1 month ago

Just realized that if we publish modules with ghcr.io/blue-build/modules/<moduletype> we can still use the source:. Newer versions wouldn't pull the ghcr.io/blue-build/modules contaiber at all. I guess it could be specified that source: local is needed for local modules, but do that in some sort of soft way where users have a warning period during whch we check whether a module exists in modules/ locally and throw a deprecation warning if it does.