Skip to content
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

Add metadata to Docker images #540

Closed
wants to merge 1 commit into from
Closed
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
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ COPY . .
RUN make _build-manager BIN_PATH=build/_output/cmd

FROM quay.io/centos/centos:stream9

ARG BUILD_DATE
ARG VERSION
ARG VCS_REF
ARG VCS_BRANCH

LABEL version=$VERSION
LABEL vcs-type="git"
LABEL vcs-branch=$VCS_BRANCH
LABEL vcs-ref=$VCS_REF
LABEL build-date=$BUILD_DATE
LABEL io.k8s.display-name="sriov-network-operator" \
io.k8s.description="Operator for provisioning and configuring SR-IOV CNI plugin and device plugin"

COPY --from=builder /go/src/github.com/k8snetworkplumbingwg/sriov-network-operator/build/_output/cmd/manager /usr/bin/sriov-network-operator
COPY bindata /bindata
ENV OPERATOR_NAME=sriov-network-operator
Expand Down
16 changes: 14 additions & 2 deletions Dockerfile.sriov-network-config-daemon
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,22 @@ COPY . .
RUN make _build-sriov-network-config-daemon BIN_PATH=build/_output/cmd

FROM quay.io/centos/centos:stream9
ARG MSTFLINT=mstflint
RUN ARCH_DEP_PKGS=$(if [ "$(uname -m)" != "s390x" ]; then echo -n ${MSTFLINT} ; fi) && yum -y install hwdata $ARCH_DEP_PKGS && yum clean all

ARG BUILD_DATE
ARG VERSION
ARG VCS_REF
ARG VCS_BRANCH

LABEL version=$VERSION
LABEL vcs-type="git"
LABEL vcs-branch=$VCS_BRANCH
LABEL vcs-ref=$VCS_REF
LABEL build-date=$BUILD_DATE
LABEL io.k8s.display-name="sriov-network-config-daemon" \
io.k8s.description="This is a daemon that manage and config sriov network devices in Kubernetes cluster"

ARG MSTFLINT=mstflint
RUN ARCH_DEP_PKGS=$(if [ "$(uname -m)" != "s390x" ]; then echo -n ${MSTFLINT} ; fi) && yum -y install hwdata $ARCH_DEP_PKGS && yum clean all
COPY --from=builder /go/src/github.com/k8snetworkplumbingwg/sriov-network-operator/build/_output/cmd/sriov-network-config-daemon /usr/bin/
COPY bindata /bindata
CMD ["/usr/bin/sriov-network-config-daemon"]
12 changes: 12 additions & 0 deletions Dockerfile.webhook
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,19 @@ COPY . .
RUN make _build-webhook BIN_PATH=build/_output/cmd

FROM quay.io/centos/centos:stream9

ARG BUILD_DATE
ARG VERSION
ARG VCS_REF
ARG VCS_BRANCH

LABEL version=$VERSION
LABEL vcs-type="git"
LABEL vcs-branch=$VCS_BRANCH
LABEL vcs-ref=$VCS_REF
LABEL build-date=$BUILD_DATE
LABEL io.k8s.display-name="sriov-network-webhook" \
io.k8s.description="This is an admission controller webhook that mutates and validates customer resources of sriov network operator."

COPY --from=builder /go/src/github.com/k8snetworkplumbingwg/sriov-network-operator/build/_output/cmd/webhook /usr/bin/webhook
CMD ["/usr/bin/webhook"]
16 changes: 14 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@ export OPERATOR_EXEC?=oc
BUILD_GOPATH=$(TARGET_DIR):$(TARGET_DIR)/vendor:$(CURPATH)/cmd
IMAGE_BUILDER?=docker
IMAGE_BUILD_OPTS?=
IMAGE_METADATA=--build-arg BUILD_DATE="$(BUILD_TIMESTAMP)" --build-arg VERSION="$(BUILD_VERSION)" --build-arg VCS_REF="$(VCS_REF)" --build-arg VCS_BRANCH="$(VCS_BRANCH)"
Copy link
Collaborator

Choose a reason for hiding this comment

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

this works ? values of those vars are only set below.

Copy link
Member

Choose a reason for hiding this comment

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

In that sense, I suggest to update how images are built for end-to-end tests:

https://github.com/k8snetworkplumbingwg/sriov-network-operator/blob/master/hack/run-e2e-conformance-virtual-cluster.sh#L265

This way we can see it in CI

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1 lets do the same build as part of the CI

DOCKERFILE?=Dockerfile
DOCKERFILE_CONFIG_DAEMON?=Dockerfile.sriov-network-config-daemon
DOCKERFILE_WEBHOOK?=Dockerfile.webhook

BUILD_VERSION := $(strip $(shell [ -d .git ] && git describe --always --tags --dirty))
BUILD_TIMESTAMP := $(shell date -u +"%Y-%m-%dT%H:%M:%S%Z")
VCS_BRANCH := $(strip $(shell git rev-parse --abbrev-ref HEAD))
VCS_REF := $(strip $(shell [ -d .git ] && git rev-parse --short HEAD))

CRD_BASES=./config/crd/bases

Expand All @@ -22,6 +29,7 @@ TARGET=$(TARGET_DIR)/bin/$(APP_NAME)
IMAGE_REPO?=ghcr.io/k8snetworkplumbingwg
IMAGE_TAG?=$(IMAGE_REPO)/$(APP_NAME):latest
CONFIG_DAEMON_IMAGE_TAG?=$(IMAGE_REPO)/sriov-network-config-daemon:latest
WEBHOOK_IMAGE_TAG?=$(IMAGE_REPO)/sriov-network-operator-webhook:latest
MAIN_PKG=cmd/manager/main.go
export NAMESPACE?=openshift-sriov-network-operator
export WATCH_NAMESPACE?=openshift-sriov-network-operator
Expand Down Expand Up @@ -69,8 +77,12 @@ update-codegen:
hack/update-codegen.sh

image: ; $(info Building image...)
$(IMAGE_BUILDER) build -f $(DOCKERFILE) -t $(IMAGE_TAG) $(CURPATH) $(IMAGE_BUILD_OPTS)
$(IMAGE_BUILDER) build -f $(DOCKERFILE_CONFIG_DAEMON) -t $(CONFIG_DAEMON_IMAGE_TAG) $(CURPATH) $(IMAGE_BUILD_OPTS)
$(IMAGE_BUILDER) build $(IMAGE_METADATA) \
-f $(DOCKERFILE) -t $(IMAGE_TAG) $(CURPATH) $(IMAGE_BUILD_OPTS)
$(IMAGE_BUILDER) build $(IMAGE_METADATA) \
-f $(DOCKERFILE_CONFIG_DAEMON) -t $(CONFIG_DAEMON_IMAGE_TAG) $(CURPATH) $(IMAGE_BUILD_OPTS)
$(IMAGE_BUILDER) build $(IMAGE_METADATA) \
-f $(DOCKERFILE_WEBHOOK) -t $(WEBHOOK_IMAGE_TAG) $(CURPATH) $(IMAGE_BUILD_OPTS)
bn222 marked this conversation as resolved.
Show resolved Hide resolved

# Run tests
test: generate vet manifests envtest
Expand Down
Loading