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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ simple-tests: unit-tests # Compatibility target.
.PHONY: simple-tests

# Images needed for GPU smoke tests.
gpu-smoke-images: load-gpu_cuda-tests load-gpu_cuda-tests-12-8
gpu-smoke-images: load-gpu_cuda-tests.12.2.2 load-gpu_cuda-tests-12.8.1
.PHONY: gpu-smoke-images

gpu-smoke-tests: gpu-smoke-images $(RUNTIME_BIN)
Expand Down Expand Up @@ -338,7 +338,7 @@ cos-gpu-all-tests: gpu-images cos-gpu-smoke-tests $(RUNTIME_BIN)
@$(call sudo,test/gpu:sniffer_test,--runtime=$(RUNTIME) -test.v --cos-gpu $(ARGS))
.PHONY: cos-gpu-all-tests

cuda-tests: load-basic_alpine load-gpu_cuda-tests $(RUNTIME_BIN)
cuda-tests: load-basic_alpine load-gpu_cuda-tests.12.2.2 $(RUNTIME_BIN)
@$(call install_runtime,$(RUNTIME),--nvproxy=true --nvproxy-docker=true --nvproxy-allowed-driver-capabilities=all)
@$(call sudo,test/gpu:cuda_test,--runtime=$(RUNTIME) -test.v $(ARGS))
.PHONY: cuda-tests
Expand Down
62 changes: 62 additions & 0 deletions images/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,65 @@ achieved by specifying `ARCH` variable to make. For example:
```
$ make ARCH=aarch64 rebuild-default
```

## Templated images

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)
└─ this README.md file
```

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.

Note that build arguments do not carry over `FROM` lines in `Dockerfile` unless
specifically passed. For example, this will not work:

```dockerfile
# You should put this line at the top of the file to clearly indicate
# to users that don't use the `Makefile` build system that they are going
# to be building an image that doesn't make sense:
ARG TEMPLATE_VERSION=POPULATED_BY_BUILD_SYSTEM

FROM base-image:${TEMPLATE_VERSION}-alpine

# WRONG: TEMPLATE_VERSION will not be defined here!
# This will try cloning the empty string branch.
RUN git clone https://some-url --branch="${TEMPLATE_VERSION}"
```

This will work:

```dockerfile
ARG TEMPLATE_VERSION=POPULATED_BY_BUILD_SYSTEM

FROM base-image:${TEMPLATE_VERSION}-alpine

# CORRECT: This declares that TEMPLATE_VERSION should be inherited from the
# previous build stage; the lack of value assignment means that its value
# should be carried over as-is.
ARG TEMPLATE_VERSION

# TEMPLATE_VERSION will be defined here.
RUN git clone https://some-url --branch="${TEMPLATE_VERSION}"
```
49 changes: 0 additions & 49 deletions images/gpu/cuda-tests-12-8/Dockerfile

This file was deleted.

205 changes: 0 additions & 205 deletions images/gpu/cuda-tests-12-8/cuda_malloc.cu

This file was deleted.

56 changes: 0 additions & 56 deletions images/gpu/cuda-tests-12-8/run_cuda_test.py

This file was deleted.

Loading