Use a version identifier label in all image tags built by `ddev`
Is there an existing issue for this?
- [x] I have searched the existing issues
Is your feature request related to a problem?
- https://github.com/ddev/ddev/pull/7151#issuecomment-2987956626
Another thing I noticed: if the image doesn't have a specific ddev version in its tag, it won't be rebuilt later.
So if users update ddev and use something like ddev/ddev-solr, the already built Solr image won't be rebuilt with the new ddev.
And ddev delete images doesn't remove deleted add-on image.
Describe your solution
This could be solved by always setting the image: field with proper tag identifier in fixComposeYaml().
Tag Identifier could be some new variable in versionconstants.go or we can rely on the WebTag.
Describe alternatives
Add-ons can set the image: on their own and use $DDEV_VERSION:
services:
solr:
image: ddev-solr:${DDEV_VERSION}-built
build:
...
But I don't think that users on DDEV HEAD will be happy about it (because $DDEV_VERSION will change all the time).
Additional context
No response
I tested the image: change with our postgres database and found that changing the image: alone isn't enough. Docker reuses its cache, so it ends up using the same image SHA with a new tag.
- One option is to run
docker-compose build --no-cache <service-name>. If we check that some image tag for a service doesn't exist, then we can run build without cache for that service before doing the usualdocker-compose buildonddev start. - Another option is to modify the
Dockerfileby adding a dummyARGwith tag at the top. This forces Docker to rebuild the image. I can do this forpostgres, since we control theDockerfile, but not for other extra services.
~~I'll use the second option for postgres in #7151 as a temporary measure so ddev delete images works properly. Later, I'll remove the temporary ARG when implementing the first option.~~
Edit: I'll simply check for postgres:*-built in #7151 for now, because that PR is already doing a lot.
Different names for images can change the way we pull them in:
https://github.com/ddev/ddev/blob/28aa456ed76e0a1aa33359ae96401a06e92c5113/pkg/ddevapp/ddevapp.go#L1865-L1886
Which uses:
https://github.com/ddev/ddev/blob/28aa456ed76e0a1aa33359ae96401a06e92c5113/pkg/ddevapp/ddevapp.go#L1905-L1926
And the logic for pulls may be changed with:
- #7163
I was thinking about new labels to use them for all Docker resources created by DDEV.
com.ddev.version seems ideal, clear indicator which includes the version for reliable cleanup.
It also makes sense to add com.ddev.site-name everywhere in the app context.
We'll need to check for all the labels for compatibility (i.e. check for com.docker.compose.project), but this will lead to a cleaner setup moving forward.
In case of using labels, we don't need to edit image built tags.
i'd be in favor of some related labels, including git committish. I think we have an old issue about this, and docker has some good support.