Skip to content

Container images: Support "template" images and use it for cuda-tests #11702

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

copybara-service[bot]
Copy link

@copybara-service copybara-service bot commented May 8, 2025

Container images: Support "template" images and use it for cuda-tests

The gpu/cuda-tests and gpu/cuda-tests-12-8 are duplicates of each other,
other than the CUDA version they use. As more CUDA versions are added, this
isn't a scalable pattern.

This change adds support in the Makefile (more specifically
tools/images.mk) for "image templates" and "image template instances".
If an image directory ends in .tmpl, it will be ignored from the set of images
that the Makefile recognizes. Instead, this directory can be used to
instantiate other images.

For example, given the following filesystem structure:

images/
├─ my-little-image.tmpl/
│  └─ Dockerfile
├─ my-little-image.foo.bar → my-little-image.tmpl (symlink)
└─ my-little-image.baz.qux → my-little-image.tmpl (symlink)

Then this will effectively create two images, my-little-image.foo.bar and
my-little-image.baz.qux. It will not create a my-little-image.tmpl image.

The behavior of the template instance images is determined by the
TEMPLATE_VERSION build argument passed to my-little-image.tmpl/Dockerfile.
This argument takes on the value of everything after the first . character of
the last component of the template instance image name. For example, the image
my-little-image.foo.bar will be built with docker build --build-arg=TEMPLATE_VERSION=foo.bar, whereas the my-little-image.baz.quux
will be built with docker build --build-arg=TEMPLATE_VERSION=baz.qux. The
my-little-image.tmpl/Dockerfile image definition file can use this variable to
make the necessary tweaks to distinguish these two images.

#codehealth

@copybara-service copybara-service bot added the exported Issue was exported automatically label May 8, 2025
@copybara-service copybara-service bot force-pushed the test/cl756101224 branch 3 times, most recently from c4fd98d to eca19c9 Compare May 8, 2025 19:53
The `gpu/cuda-tests` and `gpu/cuda-tests-12-8` are duplicates of each other,
other than the CUDA version they use. As more CUDA versions are added, this
isn't a scalable pattern.

This change adds support in the `Makefile` (more specifically
`tools/images.mk`) for "image templates" and "image template instances".
If an image directory ends in `.tmpl`, it will be ignored from the set of images
that the `Makefile` recognizes. Instead, this directory can be used to
instantiate other images.

For example, given the following filesystem structure:

```
images/
├─ my-little-image.tmpl/
│  └─ Dockerfile
├─ my-little-image.foo.bar → my-little-image.tmpl (symlink)
└─ my-little-image.baz.qux → my-little-image.tmpl (symlink)
```

Then this will effectively create two images, `my-little-image.foo.bar` and
`my-little-image.baz.qux`. It will not create a `my-little-image.tmpl` image.

The behavior of the template instance images is determined by the
`TEMPLATE_VERSION` build argument passed to `my-little-image.tmpl/Dockerfile`.
This argument takes on the value of everything after the first `.` character of
the last component of the template instance image name. For example, the image
`my-little-image.foo.bar` will be built with `docker build
--build-arg=TEMPLATE_VERSION=foo.bar`, whereas the `my-little-image.baz.quux`
will be built with `docker build --build-arg=TEMPLATE_VERSION=baz.qux`. The
`my-little-image.tmpl/Dockerfile` image definition file can use this variable to
make the necessary tweaks to distinguish these two images.

#codehealth

PiperOrigin-RevId: 756101224
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exported Issue was exported automatically
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant