Skip to content
This repository was archived by the owner on Dec 6, 2024. It is now read-only.

Commit 6dc6121

Browse files
committed
Update build configs to mirror controller
Update build configs for this sidecar image to reflect the latest configs that are now working for the controller image. Signed-off-by: Blaine Gardner <[email protected]>
1 parent 8d561f9 commit 6dc6121

File tree

3 files changed

+106
-49
lines changed

3 files changed

+106
-49
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,36 @@
1+
#
2+
# BUILDER
3+
#
4+
FROM docker.io/library/golang:1.21.1 AS builder
5+
6+
WORKDIR /buildroot
7+
8+
# Cache deps before building and copying source, so that we don't need to re-download
9+
# as much and so that source changes don't invalidate our downloaded layer.
10+
COPY go.mod go.mod
11+
COPY go.sum go.sum
12+
RUN go mod download
13+
14+
COPY cmd/ cmd/
15+
COPY pkg/ pkg/
16+
17+
ENV CGO_ENABLED=0
18+
19+
RUN go build -o artifacts/objectstorage-sidecar cmd/objectstorage-sidecar/*.go
20+
21+
22+
#
23+
# FINAL IMAGE
24+
#
125
FROM gcr.io/distroless/static:latest
2-
LABEL maintainers="Kubernetes COSI Authors"
3-
LABEL description="Object Storage Sidecar"
426

5-
COPY ./bin/objectstorage-sidecar objectstorage-sidecar
27+
LABEL maintainers="Kubernetes Authors"
28+
LABEL description="COSI Storage Sidecar"
29+
30+
LABEL org.opencontainers.image.title="COSI Storage Sidecar"
31+
LABEL org.opencontainers.image.description="Container Object Storage Interface (COSI) Storage Provisioner Sidecar"
32+
LABEL org.opencontainers.image.source="https://github.com/kubernetes-sigs/container-object-storage-interface-provisioner-sidecar"
33+
LABEL org.opencontainers.image.licenses="APACHE-2.0"
34+
35+
COPY --from=builder /buildroot/artifacts/objectstorage-sidecar .
636
ENTRYPOINT ["/objectstorage-sidecar"]
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,37 @@
1-
# Copyright 2020 The Kubernetes Authors.
2-
#
3-
# Licensed under the Apache License, Version 2.0 (the "License");
4-
# you may not use this file except in compliance with the License.
5-
# You may obtain a copy of the License at
6-
#
7-
# http://www.apache.org/licenses/LICENSE-2.0
8-
#
9-
# Unless required by applicable law or agreed to in writing, software
10-
# distributed under the License is distributed on an "AS IS" BASIS,
11-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
# See the License for the specific language governing permissions and
13-
# limitations under the License.
14-
15-
CMDS=objectstorage-sidecar
16-
17-
all: reltools build
18-
.PHONY: reltools
19-
reltools: release-tools/build.make
20-
release-tools/build.make:
21-
$(eval CURDIR := $(shell pwd))
22-
$(eval TMP := $(shell mktemp -d))
23-
$(shell cd ${TMP} && git clone https://github.com/kubernetes-sigs/container-object-storage-interface-spec)
24-
$(shell cp -r ${TMP}/container-object-storage-interface-spec/release-tools ${CURDIR}/)
25-
$(shell rm -rf ${TMP})
26-
ln -s release-tools/travis.yml travis.yml
27-
28-
29-
include release-tools/build.make
30-
31-
REGISTRY_NAME=gcr.io/k8s-staging-sig-storage/objectstorage-sidecar
32-
IMAGE_TAGS=$(GIT_TAG)
1+
.DEFAULT_GOAL := help
2+
SHELL = /usr/bin/env bash
3+
4+
# 'go env' vars aren't always available in make environments, so get defaults for needed ones
5+
GOARCH ?= $(shell go env GOARCH)
6+
7+
##
8+
## ==== ARGS ===== #
9+
10+
## Container build tool compatible with `docker` API
11+
DOCKER ?= docker
12+
13+
## Platform for 'build'
14+
PLATFORM ?= linux/$(GOARCH)
15+
16+
## Image tag for all builds
17+
IMAGE_TAG ?= cosi-controller:latest
18+
19+
##
20+
## === TARGETS === #
21+
22+
.PHONY: build
23+
## Build local image for development, defaulting linux/<hostarch>
24+
build:
25+
$(DOCKER) build --platform $(PLATFORM) --tag $(IMAGE_TAG) .
26+
27+
.PHONY: test
28+
## Test packages
29+
test:
30+
go vet ./...
31+
go test ./...
32+
33+
# print out lines beginning with double-comments, plus next line as basic help text
34+
.PHONY: help
35+
## Show this help text
36+
help:
37+
@sed -n -e "/^##/{N;s/^/\n/p;}" $(MAKEFILE_LIST)
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,39 @@
1-
# See https://cloud.google.com/cloud-build/docs/build-config
1+
# K8s infra build example: https://github.com/kubernetes/test-infra/blob/master/config/jobs/image-pushing/README.md
2+
# GCloud build docs: https://cloud.google.com/cloud-build/docs/build-config
3+
# Builds go to https://console.cloud.google.com/gcr/images/k8s-staging-sig-storage/GLOBAL
4+
# Build logs in https://testgrid.k8s.io/sig-storage-image-build
25
timeout: 3000s
36
options:
4-
substitution_option: ALLOW_LOOSE
7+
substitution_option: 'ALLOW_LOOSE'
8+
machineType: 'E2_HIGHCPU_8'
9+
substitutions:
10+
# K8s provides custom substitutions _GIT_TAG and _PULL_BASE_REF:
11+
# https://github.com/kubernetes/test-infra/blob/master/config/jobs/image-pushing/README.md#custom-substitutions
12+
_GIT_TAG: '12345' # e.g., vYYYYMMDD-hash, vYYYYMMDD-tag, or vYYYYMMDD-tag-n-ghash
13+
_PULL_BASE_REF: 'master' # e.g., master or release-0.2 for a PR merge, or v0.2 for a tag
14+
# COSI substitutions:
15+
_IMAGE: objectstorage-sidecar
16+
_PLATFORMS: linux/amd64,linux/arm64 # add more platforms here if desired
517
steps:
6-
- name: "gcr.io/k8s-staging-test-infra/gcb-docker-gcloud:v20221214-1b4dd4d69a"
7-
entrypoint: make
8-
args: ['build']
9-
env:
10-
- GIT_TAG=${_GIT_TAG}
11-
- PULL_BASE_REF=${_PULL_BASE_REF}
12-
- name: "gcr.io/k8s-staging-test-infra/gcb-docker-gcloud:v20221214-1b4dd4d69a"
13-
entrypoint: make
14-
args: ['push']
15-
env:
16-
- GIT_TAG=${_GIT_TAG}
17-
- PULL_BASE_REF=${_PULL_BASE_REF}
18+
# based on k8s infra build example and modified to use docker buildx
19+
# buildx refs: https://github.com/docker/buildx/blob/master/docs/reference/buildx.md
20+
- id: set-up-multi-arch-builder-as-default
21+
name: gcr.io/cloud-builders/docker
22+
args: ["buildx", "create", "--use", "--name", "multi-arch", "--platform=${_PLATFORMS}"]
23+
- id: bootstrap-multi-arch-builder
24+
name: gcr.io/cloud-builders/docker
25+
args: ["buildx", "inspect", "--bootstrap"]
26+
- id: do-multi-arch-build
27+
name: gcr.io/cloud-builders/docker
28+
args:
29+
- buildx
30+
- build
31+
- --push # --load doesn't work with multi-platform builds, so just push from docker build
32+
- --platform=${_PLATFORMS}
33+
- --tag=gcr.io/k8s-staging-sig-storage/${_IMAGE}:${_GIT_TAG}
34+
# using _PULL_BASE_REF as a tag will often just build and overwrite the same 'master' tag,
35+
# BUT! if the commit has a git tag, it will build that tag instead. this mechanism allows
36+
# creating the semver-tagged images that will be auto-promoted to release
37+
- --tag=gcr.io/k8s-staging-sig-storage/${_IMAGE}:${_PULL_BASE_REF}
38+
- --tag=gcr.io/k8s-staging-sig-storage/${_IMAGE}:latest
39+
- .

0 commit comments

Comments
 (0)