diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f0ce896..0d8b1e8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,6 +18,7 @@ env: # a step 'if env.AWS_USR' != ""', so we copy these to succinctly test whether # credentials have been provided before trying to run steps that need them. DOCKER_USR: ${{ secrets.DOCKER_USR }} + XPKG_ACCESS_ID: ${{ secrets.XPKG_ACCESS_ID }} AWS_USR: ${{ secrets.AWS_USR }} jobs: @@ -308,7 +309,15 @@ jobs: with: username: ${{ secrets.DOCKER_USR }} password: ${{ secrets.DOCKER_PSW }} - + + - name: Login to Upbound + uses: docker/login-action@v1 + if: env.XPKG_ACCESS_ID != '' + with: + registry: xpkg.upbound.io + username: ${{ secrets.XPKG_ACCESS_ID }} + password: ${{ secrets.XPKG_TOKEN }} + - name: Publish Artifacts to S3 and Docker Hub run: make -j2 publish BRANCH_NAME=${GITHUB_REF##*/} if: env.AWS_USR != '' && env.DOCKER_USR != '' diff --git a/Makefile b/Makefile index 0be024b..4b9cd1d 100644 --- a/Makefile +++ b/Makefile @@ -47,14 +47,29 @@ GO111MODULE = on # ==================================================================================== # Setup Kubernetes tools +UP_VERSION = v0.13.0 +UP_CHANNEL = stable -include build/makelib/k8s_tools.mk # ==================================================================================== # Setup Images -DOCKER_REGISTRY ?= crossplane -IMAGES = provider-jet-equinix provider-jet-equinix-controller --include build/makelib/image.mk +IMAGES = provider-equinix +-include build/makelib/imagelight.mk + +# ==================================================================================== +# Setup XPKG + +XPKG_REG_ORGS ?= xpkg.upbound.io/crossplane index.docker.io/crossplane +# NOTE(hasheddan): skip promoting on xpkg.upbound.io as channel tags are +# inferred. +XPKG_REG_ORGS_NO_PROMOTE ?= xpkg.upbound.io/crossplane +XPKGS = provider-equinix +-include build/makelib/xpkg.mk + +# NOTE(hasheddan): we force image building to happen prior to xpkg build so that +# we ensure image is present in daemon. +xpkg.build.provider-equinix: do.build.images # ==================================================================================== # Fallthrough @@ -108,6 +123,11 @@ generate.init: $(TERRAFORM_PROVIDER_SCHEMA) go.cachedir: @go env GOCACHE +# NOTE(hasheddan): we must ensure up is installed in tool cache prior to build +# as including the k8s_tools machinery prior to the xpkg machinery sets UP to +# point to tool cache. +build.init: $(UP) + # Generate a coverage report for cobertura applying exclusions on # - generated file cobertura: diff --git a/cluster/images/provider-jet-equinix/Dockerfile b/cluster/images/provider-jet-equinix/Dockerfile index 332e751..8118eb6 100644 --- a/cluster/images/provider-jet-equinix/Dockerfile +++ b/cluster/images/provider-jet-equinix/Dockerfile @@ -1,3 +1,9 @@ -FROM BASEIMAGE +FROM gcr.io/distroless/static@sha256:1f580b0a1922c3e54ae15b0758b5747b260bd99d39d40c2edb3e7f6e2452298b -COPY package.yaml . +ARG TARGETOS +ARG TARGETARCH + +ADD bin/$TARGETOS\_$TARGETARCH/provider /usr/local/bin/crossplane-equinix-provider + +USER 65532 +ENTRYPOINT ["crossplane-equinix-provider"] diff --git a/cluster/images/provider-jet-equinix/Makefile b/cluster/images/provider-jet-equinix/Makefile index b347fd3..269cea4 100755 --- a/cluster/images/provider-jet-equinix/Makefile +++ b/cluster/images/provider-jet-equinix/Makefile @@ -1,30 +1,37 @@ # ==================================================================================== # Setup Project -PLATFORMS := linux_amd64 linux_arm64 include ../../../build/makelib/common.mk # ==================================================================================== # Options -DOCKER_REGISTRY ?= crossplane -IMAGE = $(BUILD_REGISTRY)/provider-jet-equinix-$(ARCH) -OSBASEIMAGE = scratch -include ../../../build/makelib/image.mk + +include ../../../build/makelib/imagelight.mk # ==================================================================================== # Targets img.build: + @$(INFO) docker build $(IMAGE) + @$(MAKE) BUILD_ARGS="--load" img.build.shared + @$(OK) docker build $(IMAGE) + +img.publish: + @$(INFO) Skipping image publish for $(IMAGE) + @echo Publish is deferred to xpkg machinery + @$(OK) Image publish skipped for $(IMAGE) + +img.build.shared: @$(INFO) docker build $(IMAGE) @cp Dockerfile $(IMAGE_TEMP_DIR) || $(FAIL) - @cp -R ../../../package $(IMAGE_TEMP_DIR) || $(FAIL) - @cd $(IMAGE_TEMP_DIR) && $(SED_CMD) 's|BASEIMAGE|$(OSBASEIMAGE)|g' Dockerfile || $(FAIL) - @cd $(IMAGE_TEMP_DIR) && $(SED_CMD) 's|VERSION|$(VERSION)|g' package/crossplane.yaml || $(FAIL) - @cd $(IMAGE_TEMP_DIR) && $(SED_CMD) 's|DOCKER_REGISTRY|$(DOCKER_REGISTRY)|g' package/crossplane.yaml || $(FAIL) - @cd $(IMAGE_TEMP_DIR) && find package -type f -name '*.yaml' -exec cat {} >> 'package.yaml' \; -exec printf '\n---\n' \; || $(FAIL) - @docker build $(BUILD_ARGS) \ - --build-arg ARCH=$(ARCH) \ - --build-arg TINI_VERSION=$(TINI_VERSION) \ + @cp -r $(OUTPUT_DIR)/bin/ $(IMAGE_TEMP_DIR)/bin || $(FAIL) + @docker buildx build $(BUILD_ARGS) \ + --platform $(IMAGE_PLATFORMS) \ -t $(IMAGE) \ $(IMAGE_TEMP_DIR) || $(FAIL) @$(OK) docker build $(IMAGE) + +img.promote: + @$(INFO) Skipping image promotion from $(FROM_IMAGE) to $(TO_IMAGE) + @echo Promote is deferred to xpkg machinery + @$(OK) Image promotion skipped for $(FROM_IMAGE) to $(TO_IMAGE) \ No newline at end of file