itzg / easy-add

A utility for easily adding a file from a downloaded archive during Docker builds
MIT License
26 stars 5 forks source link

Renovate integration #34

Open strausmann opened 1 month ago

strausmann commented 1 month ago

Have you ever thought about integrating Renovate?

This would allow you to update the dependencies automatically. I use this in many of my GitLab projects. Among others also for my Bedrock Connect Docker image, which uses some of your projects.

https://docs.renovatebot.com/

itzg commented 1 month ago

I already use dependabot.

How does this help with versions of dependencies buried within RUN statements in Dockerfile's?

itzg commented 1 month ago

Wanted to link to this very helpful example you included in other convo

https://github.com/itzg/mc-monitor/pull/90#issuecomment-2218001665

strausmann commented 1 month ago

This is my source:

https://github.com/hassio-addons/addon-base/blob/main/.github/renovate.json

strausmann commented 1 month ago

https://www.innoq.com/en/articles/2024/05/renovate/

strausmann commented 1 month ago

Here is a link to my Renovate Config Repo. I have revised the config for Dockerfile dependencies again and found better ways to do it. For this purpose, I have made the config from the one project, now global for my projects.

The interaction is now the Global Config project and the Dockerfile files in my Bedrock Connect project

Global Renovate Config: https://git.strausmann.de/renovate/renovate-config/-/blob/main/default.json?ref_type=heads

Project Renovate Config: https://git.strausmann.de/minecraft/bedrock-connect/-/blob/main/renovate.json?ref_type=heads

Project Dockerfile: https://git.strausmann.de/minecraft/bedrock-connect/-/blob/main/image/Dockerfile?ref_type=heads

Please note that the line before an ARG or ENV in a Dockerfile must be

# renovate: datasource=github-releases depName=itzg/easy-add versioning=loose

This tells the renovate that the following ENV or ARG variable should be updated if this variable ends with _VERSION. You can specify different sources as Datasource, depName is the path owner/project name and versioning=loose says that it tries to use semver, otherwise it sorts the tags and takes the first value from the sorting.

In your ENTRYPOINT_DEMOTER project, extractVersion had to be added because you use a "v" before the version here.

# renovate: datasource=github-releases depName=itzg/entrypoint-demoter versioning=loose extractVersion=(^v(?<version>.*)$)

I'm not entirely happy with this solution, because it's always an additional layer. However, this now happens automatically for my project.

With this PackageRule I have also combined all your modules in my project into a MergeRequest and defined it as a fix for deps, which triggers a new release at night when Semantic-Releases sees the commit.

https://git.strausmann.de/renovate/renovate-config/-/blob/5f3d9ff7986618c6f8b98375fe02f83233a0e7ae/default.json#L28-L34

With the following CustomManagers rule set, the Renovate comment is recognized in the Dockerfile.

https://git.strausmann.de/renovate/renovate-config/-/blob/5f3d9ff7986618c6f8b98375fe02f83233a0e7ae/default.json#L37-L44

itzg commented 1 month ago

In your ENTRYPOINT_DEMOTER project, extractVersion had to be added because you use a "v" before the version here.

I'll look into changing that. That was a Go-ism that I never really liked in the first place. As you see I have switched or didn't adopt that convention on most of the projects now.