diff --git a/Dockerfile b/Dockerfile index 64bf9e4b3..df69963a8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ -FROM golang:1.18.3 AS deps +FROM --platform=$BUILDPLATFORM golang:1.18.3 AS deps -ARG KCTRL_VER=development +ARG TARGETOS TARGETARCH KCTRL_VER=development WORKDIR /workspace # dependencies @@ -8,13 +8,13 @@ COPY ./hack/dependencies.* ./hack/ COPY go.* ./ COPY vendor vendor RUN mkdir out -RUN go run ./hack/dependencies.go install -d out +RUN go run ./hack/dependencies.go install -d out --arch ${TARGETARCH} --os ${TARGETOS} # kapp-controller COPY . . # helpful ldflags reference: https://www.digitalocean.com/community/tutorials/using-ldflags-to-set-version-information-for-go-applications -RUN CGO_ENABLED=0 GOOS=linux go build -mod=vendor -ldflags="-X 'main.Version=$KCTRL_VER'" -trimpath -o out/kapp-controller ./cmd/controller/... -RUN CGO_ENABLED=0 GOOS=linux go build -mod=vendor -ldflags="-X 'main.Version=$KCTRL_VER'" -trimpath -o out/kapp-controller-sidecarexec ./cmd/sidecarexec/main.go +RUN CGO_ENABLED=0 GOOS=linux GOOS=${TARGETOS} GOSARCH=${TARGETARCH} go build -mod=vendor -ldflags="-X 'main.Version=$KCTRL_VER'" -trimpath -o out/kapp-controller ./cmd/controller +RUN CGO_ENABLED=0 GOOS=linux GOOS=${TARGETOS} GOSARCH=${TARGETARCH} go build -mod=vendor -ldflags="-X 'main.Version=$KCTRL_VER'" -trimpath -o out/kapp-controller-sidecarexec ./cmd/sidecarexec # --- run image --- FROM photon:4.0 diff --git a/config-release/values.yml b/config-release/values.yml index 23689d193..593d0ef40 100644 --- a/config-release/values.yml +++ b/config-release/values.yml @@ -3,3 +3,4 @@ push_images: true image_cache: false image_repo: ghcr.io/vmware-tanzu/carvel-kapp-controller +platform: "linux/amd64,linux/arm64" diff --git a/config/build.yml b/config/build.yml index 15a9c623c..374f3a143 100644 --- a/config/build.yml +++ b/config/build.yml @@ -5,14 +5,17 @@ kind: Sources sources: - image: kapp-controller path: . - #@ if/end not data.values.image_cache: docker: - build: - #! Always rebuild image + buildx: pull: true - noCache: true + noCache: #@ not data.values.image_cache #! pass kapp_controller_version into Dockerfile. - rawOptions: #@ ["--build-arg", "KCTRL_VER="+data.values.kapp_controller_version] + rawOptions: + - #@ "--build-arg=KCTRL_VER="+data.values.kapp_controller_version + #@ if/end data.values.push_secret != "": + - #@ "--registry-secret="+data.values.push_secret + #@ if/end data.values.platform != "": + - #@ "--platform="+data.values.platform #@ if/end data.values.push_images: --- diff --git a/config/values.yml b/config/values.yml index 2bfec2a4f..5433444c8 100644 --- a/config/values.yml +++ b/config/values.yml @@ -12,6 +12,8 @@ dangerous_enable_pprof: false push_images: false image_cache: true image_repo: docker.io/k14stest/kapp-controller-test +push_secret: "" +platform: "" api_port: 10350 kapp_controller_version: "develop" diff --git a/hack/build-release.sh b/hack/build-release.sh index 686693553..0dea0fecb 100755 --- a/hack/build-release.sh +++ b/hack/build-release.sh @@ -7,7 +7,7 @@ mkdir -p tmp/ # makes the get_kappctrl_ver function available (scrapes version from git tag) source $(dirname "$0")/version-util.sh -ytt -f config/ -f config-release -v kapp_controller_version="$(get_kappctrl_ver)" | kbld -f- > ./tmp/release.yml +ytt -f config/ -f config-release -v kapp_controller_version="$(get_kappctrl_ver)" --data-values-env=KCTRL | kbld -f- > ./tmp/release.yml shasum -a 256 ./tmp/release*.yml | tee ./tmp/checksums.txt