Skip to content

[Build] Add Makefile targets for building and saving images#182

Open
yansun1996 wants to merge 1 commit intoROCm:masterfrom
yansun1996:build_makefile
Open

[Build] Add Makefile targets for building and saving images#182
yansun1996 wants to merge 1 commit intoROCm:masterfrom
yansun1996:build_makefile

Conversation

@yansun1996
Copy link
Member

Motivation

Technical Details

Test Plan

Create a Makefile for generating and saving docker images, for integration with other tools.

Test Result

$ make
Building Alpine-based device plugin image...
docker build -t docker.io/rocm/k8s-device-plugin:latest -f Dockerfile .
[+] Building 36.0s (20/20) FINISHED                                                                  docker:default
 => [internal] load build definition from Dockerfile                                                           0.0s
 => => transferring dockerfile: 1.75kB                                                                         0.0s
 => [internal] load metadata for docker.io/library/golang:1.23.6-alpine3.21                                    1.0s
 => [internal] load metadata for docker.io/library/alpine:3.21.3                                               1.0s
 => [auth] library/alpine:pull token for registry-1.docker.io                                                  0.0s
 => [auth] library/golang:pull token for registry-1.docker.io                                                  0.0s
 => [internal] load .dockerignore                                                                              0.0s
 => => transferring context: 2B                                                                                0.0s
 => [stage-0 1/7] FROM docker.io/library/golang:1.23.6-alpine3.21@sha256:f8113c4b13e2a8b3a168dceaee88ac27743c  8.0s
 => => resolve docker.io/library/golang:1.23.6-alpine3.21@sha256:f8113c4b13e2a8b3a168dceaee88ac27743cc84e959f  0.0s
 => => sha256:740cce913e231e493947cce3ac6fb58f5581550d10c6f4addb5edbc08a760dc6 1.92kB / 1.92kB                 0.0s
 => => sha256:28e288afec2f2d79dfe0256ad26e4acc6e1998fac939f45142eb65a88a5dfc24 2.08kB / 2.08kB                 0.0s
 => => sha256:f18232174bc91741fdf3da96d85011092101a032a93a388b79e99e69c2d5c870 3.64MB / 3.64MB                 0.2s
 => => sha256:2dab78eab6f2d725c7de864cc217a5c504a2dbd61a5e426545eca979fc42df3c 294.89kB / 294.89kB             0.2s
 => => sha256:dd968b00abc2f44f5d74b014d2b833a05dd020b5f534f19dca853c409df33466 74.05MB / 74.05MB               2.1s
 => => sha256:f8113c4b13e2a8b3a168dceaee88ac27743cc84e959f43b9dbd2291e9c3f57a0 10.29kB / 10.29kB               0.0s
 => => extracting sha256:f18232174bc91741fdf3da96d85011092101a032a93a388b79e99e69c2d5c870                      0.2s
 => => sha256:05bcb020fb9889a3721af34f0eaa3f0fee3b319cc797aa66b03b5632603cb66a 125B / 125B                     0.3s
 => => sha256:4f4fb700ef54461cfa02571ae0db9a0dc1e0cdb5577484a6d75e68dc38e8acc1 32B / 32B                       0.3s
 => => extracting sha256:2dab78eab6f2d725c7de864cc217a5c504a2dbd61a5e426545eca979fc42df3c                      0.1s
 => => extracting sha256:dd968b00abc2f44f5d74b014d2b833a05dd020b5f534f19dca853c409df33466                      5.5s
 => => extracting sha256:05bcb020fb9889a3721af34f0eaa3f0fee3b319cc797aa66b03b5632603cb66a                      0.0s
 => => extracting sha256:4f4fb700ef54461cfa02571ae0db9a0dc1e0cdb5577484a6d75e68dc38e8acc1                      0.0s
 => [internal] load build context                                                                              2.6s
 => => transferring context: 68.38MB                                                                           2.5s
 => [stage-1 1/5] FROM docker.io/library/alpine:3.21.3@sha256:a8560b36e8b8210634f77d9f7f9efd7ffa463e380b75e2e  0.5s
 => => resolve docker.io/library/alpine:3.21.3@sha256:a8560b36e8b8210634f77d9f7f9efd7ffa463e380b75e2e74aff451  0.0s
 => => sha256:a8560b36e8b8210634f77d9f7f9efd7ffa463e380b75e2e74aff4511df3ef88c 9.22kB / 9.22kB                 0.0s
 => => sha256:1c4eef651f65e2f7daee7ee785882ac164b02b78fb74503052a26dc061c90474 1.02kB / 1.02kB                 0.0s
 => => sha256:aded1e1a5b3705116fa0a92ba074a5e0b0031647d9c315983ccba2ee5428ec8b 581B / 581B                     0.0s
 => => sha256:f18232174bc91741fdf3da96d85011092101a032a93a388b79e99e69c2d5c870 3.64MB / 3.64MB                 0.2s
 => => extracting sha256:f18232174bc91741fdf3da96d85011092101a032a93a388b79e99e69c2d5c870                     34.8s
 => [stage-1 2/5] RUN apk --no-cache add ca-certificates libdrm                                                2.1s
 => [stage-1 3/5] RUN apk --no-cache add hwloc --repository=http://dl-cdn.alpinelinux.org/alpine/edge/communi  2.0s
 => [stage-1 4/5] WORKDIR /root/                                                                               0.0s
 => [stage-0 2/7] RUN apk --no-cache add git pkgconfig build-base libdrm-dev                                   5.2s
 => [stage-0 3/7] RUN apk --no-cache add hwloc-dev --repository=http://dl-cdn.alpinelinux.org/alpine/edge/com  1.7s
 => [stage-0 4/7] RUN mkdir -p /go/src/github.com/ROCm/k8s-device-plugin                                       0.3s
 => [stage-0 5/7] ADD . /go/src/github.com/ROCm/k8s-device-plugin                                              2.7s
 => [stage-0 6/7] WORKDIR /go/src/github.com/ROCm/k8s-device-plugin/cmd/k8s-device-plugin                      0.0s
 => [stage-0 7/7] RUN go install     -ldflags="-X main.gitDescribe=$(git -C /go/src/github.com/ROCm/k8s-devi  16.7s
 => [stage-1 5/5] COPY --from=0 /go/bin/k8s-device-plugin .                                                    0.1s
 => exporting to image                                                                                         0.2s
 => => exporting layers                                                                                        0.2s
 => => writing image sha256:0dadcdbbc415f0c00cfb25cb2c2bbc49df54b4670d8989f6d92bdac639101481                   0.0s
 => => naming to docker.io/rocm/k8s-device-plugin:latest                                                       0.0s
Built: docker.io/rocm/k8s-device-plugin:latest
Building Alpine-based node labeller image...
docker build -t docker.io/rocm/k8s-device-plugin:labeller-latest -f labeller.Dockerfile .
[+] Building 59.5s (23/23) FINISHED                                                                  docker:default
 => [internal] load build definition from labeller.Dockerfile                                                  0.0s
 => => transferring dockerfile: 2.33kB                                                                         0.0s
 => [internal] load metadata for docker.io/library/golang:1.23.6-alpine3.21                                    0.3s
 => [internal] load metadata for docker.io/library/alpine:3.21.3                                               0.3s
 => [internal] load .dockerignore                                                                              0.0s
 => => transferring context: 2B                                                                                0.0s
 => [stage-1 1/5] FROM docker.io/library/alpine:3.21.3@sha256:a8560b36e8b8210634f77d9f7f9efd7ffa463e380b75e2e  0.0s
 => [internal] load build context                                                                              0.8s
 => => transferring context: 1.57MB                                                                            0.8s
 => CACHED [stage-0  1/12] FROM docker.io/library/golang:1.23.6-alpine3.21@sha256:f8113c4b13e2a8b3a168dceaee8  0.0s
 => CACHED [stage-1 2/5] RUN apk --no-cache add ca-certificates libdrm                                         0.0s
 => [stage-1 3/5] WORKDIR /root/                                                                               0.0s
 => [stage-0  2/12] RUN apk --no-cache add git pkgconfig build-base libdrm-dev wget                            4.9s
 => [stage-0  3/12] RUN mkdir -p /go/src/github.com/ROCm/k8s-device-plugin                                     0.2s
 => [stage-0  4/12] ADD . /go/src/github.com/ROCm/k8s-device-plugin                                            2.5s
 => [stage-0  5/12] WORKDIR /go/src/github.com/ROCm/k8s-device-plugin/cmd/k8s-node-labeller                    0.0s
 => [stage-0  6/12] RUN go install     -ldflags="-X main.gitDescribe=$(git -C /go/src/github.com/ROCm/k8s-de  47.7s
 => [stage-0  7/12] RUN wget https://gitlab.freedesktop.org/mesa/libdrm/-/raw/main/data/amdgpu.ids             0.9s
 => [stage-0  8/12] RUN echo "74B9,   00, AMD Instinct MI325X VF" >> /go/src/github.com/ROCm/k8s-device-plugi  0.3s
 => [stage-0  9/12] RUN echo "738E,   01, AMD Instinct MI100" >> /go/src/github.com/ROCm/k8s-device-plugin/cm  0.4s
 => [stage-0 10/12] RUN echo "73A2,   C0, AMD Radeon Pro W6900X" >> /go/src/github.com/ROCm/k8s-device-plugin  0.3s
 => [stage-0 11/12] RUN echo "73AB,   C0, AMD Radeon Pro W6800X" >> /go/src/github.com/ROCm/k8s-device-plugin  0.4s
 => [stage-0 12/12] RUN echo "74BC,   00, AMD Instinct MI308X HF VF" >> /go/src/github.com/ROCm/k8s-device-pl  0.3s
 => [stage-1 4/5] COPY --from=0 /go/bin/k8s-node-labeller .                                                    0.3s
 => [stage-1 5/5] COPY --from=0 /go/src/github.com/ROCm/k8s-device-plugin/cmd/k8s-node-labeller/amdgpu.ids /u  0.0s
 => exporting to image                                                                                         0.7s
 => => exporting layers                                                                                        0.7s
 => => writing image sha256:7ffadaf366cc3774d9cfc7a66597d01a3ef4ebc056ff98b0a16e27c5a98126b9                   0.0s
 => => naming to docker.io/rocm/k8s-device-plugin:labeller-latest                                              0.0s
Built: docker.io/rocm/k8s-device-plugin:labeller-latest
Building UBI-based device plugin image...
docker build -t docker.io/rocm/k8s-device-plugin:rhubi-latest -f ubi-dp.Dockerfile .
[+] Building 68.6s (18/18) FINISHED                                                                  docker:default
 => [internal] load build definition from ubi-dp.Dockerfile                                                    0.0s
 => => transferring dockerfile: 3.10kB                                                                         0.0s
 => WARN: FromAsCasing: 'as' and 'FROM' keywords' casing do not match (line 14)                                0.0s
 => [internal] load metadata for registry.access.redhat.com/ubi9/ubi-init:9.4                                  1.4s
 => [internal] load metadata for registry.access.redhat.com/ubi9/ubi:latest                                    0.8s
 => [internal] load .dockerignore                                                                              0.0s
 => => transferring context: 2B                                                                                0.0s
 => [builder 1/7] FROM registry.access.redhat.com/ubi9/ubi:latest@sha256:1fc04e873cb3f3c8d1211729a794716e5082  6.6s
 => => resolve registry.access.redhat.com/ubi9/ubi:latest@sha256:1fc04e873cb3f3c8d1211729a794716e50826f650ea8  0.0s
 => => sha256:1fc04e873cb3f3c8d1211729a794716e50826f650ea88b97a4ff57f601db77a8 970B / 970B                     0.0s
 => => sha256:c1303171b9e85a85c3276353eebac89fbf9c7d2b9f3894edd31e3366faf0f996 429B / 429B                     0.0s
 => => sha256:ccfdab0b6e2e9a3297ffe6f91673181376ea8183509205fbf5510ad59e0ffc93 6.33kB / 6.33kB                 0.0s
 => => sha256:c5286ff0eace3db8d88f82a806c28a2b2e5b5641d89337b04a8b1a4d8491665c 79.97MB / 79.97MB               1.8s
 => => extracting sha256:c5286ff0eace3db8d88f82a806c28a2b2e5b5641d89337b04a8b1a4d8491665c                      4.5s
 => [stage-1 1/5] FROM registry.access.redhat.com/ubi9/ubi-init:9.4@sha256:13616a49d9de2875040ff8926a3dd984c7  7.0s
 => => resolve registry.access.redhat.com/ubi9/ubi-init:9.4@sha256:13616a49d9de2875040ff8926a3dd984c7dd97edad  0.0s
 => => sha256:a20d5f0bec2bce34d8adb0eb98f3536f214c292b20c6cf1a3a46c802662d912b 79.69MB / 79.69MB               1.9s
 => => sha256:35efb407334e188837ac56ca283aa2e0a6cde125ec9df1aad7f2d2cc87265faa 4.90MB / 4.90MB                 1.7s
 => => sha256:13616a49d9de2875040ff8926a3dd984c7dd97edad5abb0ceef2bb9b667c0109 1.47kB / 1.47kB                 0.0s
 => => sha256:1718c83f648161cec6a36bdb8b88a4b7423997282f98b911414b544d9ace94dc 594B / 594B                     0.0s
 => => sha256:353896665c21f0e382d7e23433207797f87e15b6b1957d58dc81bbb9838f8e04 11.65kB / 11.65kB               0.0s
 => => extracting sha256:a20d5f0bec2bce34d8adb0eb98f3536f214c292b20c6cf1a3a46c802662d912b                      4.7s
 => => extracting sha256:35efb407334e188837ac56ca283aa2e0a6cde125ec9df1aad7f2d2cc87265faa                      0.2s
 => [internal] load build context                                                                              0.9s
 => => transferring context: 1.56MB                                                                            0.8s
 => [builder 2/7] RUN dnf install -y 'dnf-command(config-manager)' &&     dnf config-manager --add-repo=http  35.9s
 => [stage-1 2/5] RUN mkdir -p /licenses &&     dnf install -y ca-certificates libdrm &&     rpm --import ht  21.3s
 => [stage-1 3/5] ADD ./LICENSE /licenses/LICENSE                                                              0.0s
 => [stage-1 4/5] WORKDIR /root/                                                                               0.0s
 => [builder 3/7] RUN wget https://golang.org/dl/go1.23.3.linux-amd64.tar.gz &&     tar -C /usr/local -xzf go  5.2s
 => [builder 4/7] RUN mkdir -p /go/src/github.com/ROCm/k8s-device-plugin                                       0.2s
 => [builder 5/7] ADD . /go/src/github.com/ROCm/k8s-device-plugin                                              2.5s
 => [builder 6/7] WORKDIR /go/src/github.com/ROCm/k8s-device-plugin/cmd/k8s-device-plugin                      0.0s
 => [builder 7/7] RUN go install     -ldflags="-X main.gitDescribe=$(git -C /go/src/github.com/ROCm/k8s-devi  16.1s
 => [stage-1 5/5] COPY --from=builder /go/bin/k8s-device-plugin .                                              0.1s
 => exporting to image                                                                                         0.5s
 => => exporting layers                                                                                        0.5s
 => => writing image sha256:35572dfb37c83a30f4725bb74d773c864060ea86f601b11a6ed03275ae27a4e4                   0.0s
 => => naming to docker.io/rocm/k8s-device-plugin:rhubi-latest                                                 0.0s

 1 warning found (use docker --debug to expand):
 - FromAsCasing: 'as' and 'FROM' keywords' casing do not match (line 14)
Built: docker.io/rocm/k8s-device-plugin:rhubi-latest
Building UBI-based node labeller image...
docker build -t docker.io/rocm/k8s-device-plugin:labeller-rhubi-latest -f ubi-labeller.Dockerfile .
[+] Building 90.2s (25/25) FINISHED                                                                  docker:default
 => [internal] load build definition from ubi-labeller.Dockerfile                                              0.0s
 => => transferring dockerfile: 3.44kB                                                                         0.0s
 => WARN: FromAsCasing: 'as' and 'FROM' keywords' casing do not match (line 14)                                0.0s
 => [internal] load metadata for registry.access.redhat.com/ubi9/ubi-minimal:9.4                               1.1s
 => [internal] load metadata for registry.access.redhat.com/ubi9/ubi:latest                                    0.4s
 => [internal] load .dockerignore                                                                              0.0s
 => => transferring context: 2B                                                                                0.0s
 => [stage-1 1/6] FROM registry.access.redhat.com/ubi9/ubi-minimal:9.4@sha256:c0e70387664f30cd9cf2795b547e4a9  3.2s
 => => resolve registry.access.redhat.com/ubi9/ubi-minimal:9.4@sha256:c0e70387664f30cd9cf2795b547e4a9a51002c4  0.0s
 => => sha256:f5d2c6a1e0c86e4234ea601552dbabb4ced0e013a1efcbfb439f1f6a7a9275b0 429B / 429B                     0.0s
 => => sha256:dc90caed48cf69bcd1d67dfa6fa1177e91ddcd370f9d2a570d37ea377b23e5b4 6.24kB / 6.24kB                 0.0s
 => => sha256:4d5d1cbd7ece41ce278c26338e01e2b82e1861b820ca052da9f3e0b16815358f 39.10MB / 39.10MB               1.3s
 => => sha256:c0e70387664f30cd9cf2795b547e4a9a51002c44a4a86aa9335ab030134bf392 1.47kB / 1.47kB                 0.0s
 => => extracting sha256:4d5d1cbd7ece41ce278c26338e01e2b82e1861b820ca052da9f3e0b16815358f                      1.5s
 => CACHED [builder  1/13] FROM registry.access.redhat.com/ubi9/ubi:latest@sha256:1fc04e873cb3f3c8d1211729a79  0.0s
 => [internal] load build context                                                                              0.9s
 => => transferring context: 1.56MB                                                                            0.8s
 => [builder  2/13] RUN dnf install -y 'dnf-command(config-manager)' &&     dnf config-manager --add-repo=ht  31.4s
 => [stage-1 2/6] RUN mkdir -p /licenses &&     microdnf install -y ca-certificates libdrm &&     microdnf cl  5.5s
 => [stage-1 3/6] ADD ./LICENSE /licenses/LICENSE                                                              0.0s
 => [stage-1 4/6] WORKDIR /root/                                                                               0.0s
 => [builder  3/13] RUN wget https://golang.org/dl/go1.23.3.linux-amd64.tar.gz &&     tar -C /usr/local -xzf   4.8s
 => [builder  4/13] RUN mkdir -p /go/src/github.com/ROCm/k8s-device-plugin                                     0.2s
 => [builder  5/13] ADD . /go/src/github.com/ROCm/k8s-device-plugin                                            2.7s
 => [builder  6/13] WORKDIR /go/src/github.com/ROCm/k8s-device-plugin/cmd/k8s-node-labeller                    0.0s
 => [builder  7/13] RUN go install     -ldflags="-X main.gitDescribe=$(git -C /go/src/github.com/ROCm/k8s-de  45.8s
 => [builder  8/13] RUN wget https://gitlab.freedesktop.org/mesa/libdrm/-/raw/main/data/amdgpu.ids             1.1s
 => [builder  9/13] RUN echo "74B9,   00, AMD Instinct MI325X VF" >> /go/src/github.com/ROCm/k8s-device-plugi  0.4s
 => [builder 10/13] RUN echo "738E,   01, AMD Instinct MI100" >> /go/src/github.com/ROCm/k8s-device-plugin/cm  0.3s
 => [builder 11/13] RUN echo "73A2,   C0, AMD Radeon Pro W6900X" >> /go/src/github.com/ROCm/k8s-device-plugin  0.4s
 => [builder 12/13] RUN echo "73AB,   C0, AMD Radeon Pro W6800X" >> /go/src/github.com/ROCm/k8s-device-plugin  0.3s
 => [builder 13/13] RUN echo "74BC,   00, AMD Instinct MI308X HF VF" >> /go/src/github.com/ROCm/k8s-device-pl  0.3s
 => [stage-1 5/6] COPY --from=builder /go/bin/k8s-node-labeller .                                              0.4s
 => [stage-1 6/6] COPY --from=builder /go/src/github.com/ROCm/k8s-device-plugin/cmd/k8s-node-labeller/amdgpu.  0.0s
 => exporting to image                                                                                         0.6s
 => => exporting layers                                                                                        0.6s
 => => writing image sha256:8a42fe01c817dc032a9513ae26d4ad9157fbc6d65a72b4603849e29514d62be8                   0.0s
 => => naming to docker.io/rocm/k8s-device-plugin:labeller-rhubi-latest                                        0.0s

 1 warning found (use docker --debug to expand):
 - FromAsCasing: 'as' and 'FROM' keywords' casing do not match (line 14)
Built: docker.io/rocm/k8s-device-plugin:labeller-rhubi-latest
All images built successfully
Saving docker.io/rocm/k8s-device-plugin:latest to tar.gz...
docker save docker.io/rocm/k8s-device-plugin:latest | gzip > ./dist/tarballs/k8s-device-plugin-latest.tar.gz
Saved to: ./dist/tarballs/k8s-device-plugin-latest.tar.gz
Saving docker.io/rocm/k8s-device-plugin:labeller-latest to tar.gz...
docker save docker.io/rocm/k8s-device-plugin:labeller-latest | gzip > ./dist/tarballs/k8s-node-labeller-labeller-latest.tar.gz
Saved to: ./dist/tarballs/k8s-node-labeller-labeller-latest.tar.gz
Saving docker.io/rocm/k8s-device-plugin:rhubi-latest to tar.gz...
docker save docker.io/rocm/k8s-device-plugin:rhubi-latest | gzip > ./dist/tarballs/k8s-device-plugin-rhubi-latest.tar.gz
Saved to: ./dist/tarballs/k8s-device-plugin-rhubi-latest.tar.gz
Saving docker.io/rocm/k8s-device-plugin:labeller-rhubi-latest to tar.gz...
docker save docker.io/rocm/k8s-device-plugin:labeller-rhubi-latest | gzip > ./dist/tarballs/k8s-node-labeller-labeller-rhubi-latest.tar.gz
Saved to: ./dist/tarballs/k8s-node-labeller-labeller-rhubi-latest.tar.gz
All images saved to ./dist/tarballs/

Submission Checklist

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a root Makefile to standardize building and exporting the project’s Docker images (Alpine + UBI variants) for integration with external tooling and offline distribution.

Changes:

  • Introduces Make targets to build four images (device-plugin + labeller; Alpine + UBI).
  • Adds Make targets to docker save and gzip each image into ./dist/tarballs/.
  • Adds clean and help targets for artifact and image cleanup plus target discovery.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: yansun1996 <Yan.Sun3@amd.com>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants