diff --git a/Makefile b/Makefile index b57c965..4757ef1 100644 --- a/Makefile +++ b/Makefile @@ -46,9 +46,9 @@ GO111MODULE = on # ==================================================================================== # Setup Images -DOCKER_REGISTRY = crossplane +REGISTRY_ORGS = docker.io/crossplane IMAGES = provider-digitalocean provider-digitalocean-controller --include build/makelib/image.mk +-include build/makelib/imagelight.mk # ==================================================================================== # Targets @@ -80,20 +80,6 @@ crds.clean: generate: crds.clean -# Ensure a PR is ready for review. -reviewable: generate lint - @go mod tidy - -# Ensure branch is clean. -check-diff: reviewable - @$(INFO) checking that branch is clean - @if [ ! -z "$$(git status --porcelain)" ]; then \ - $(WARN) Git status failure see below output; \ - git status; \ - $(FAIL); \ - fi - @$(OK) branch is clean - manifests: @$(WARN) Deprecated. Please run make generate instead. diff --git a/build b/build index f4f3387..bd63a41 160000 --- a/build +++ b/build @@ -1 +1 @@ -Subproject commit f4f33871bfc7b137af804a137b8a8b641e3ff4ff +Subproject commit bd63a4167ae20a71788537217b022fced8f2f854 diff --git a/cluster/images/provider-digitalocean-controller/Dockerfile b/cluster/images/provider-digitalocean-controller/Dockerfile index b91d50f..0df592f 100644 --- a/cluster/images/provider-digitalocean-controller/Dockerfile +++ b/cluster/images/provider-digitalocean-controller/Dockerfile @@ -1,11 +1,10 @@ -FROM BASEIMAGE -RUN apk --no-cache add ca-certificates bash +FROM gcr.io/distroless/static@sha256:d2b0ec3141031720cf5eedef3493b8e129bc91935a43b50562fbe5429878d96b -ARG ARCH -ARG TINI_VERSION +ARG TARGETOS +ARG TARGETARCH -ADD provider /usr/local/bin/crossplane-digitalocean-provider +ADD bin/$TARGETOS\_$TARGETARCH/provider /usr/local/bin/crossplane-digitalocean-provider EXPOSE 8080 -USER 1001 +USER 65532 ENTRYPOINT ["crossplane-digitalocean-provider"] diff --git a/cluster/images/provider-digitalocean-controller/Makefile b/cluster/images/provider-digitalocean-controller/Makefile index 0ada41d..e7d6f43 100755 --- a/cluster/images/provider-digitalocean-controller/Makefile +++ b/cluster/images/provider-digitalocean-controller/Makefile @@ -1,25 +1,35 @@ # ==================================================================================== # Setup Project -PLATFORMS := linux_amd64 linux_arm64 include ../../../build/makelib/common.mk # ==================================================================================== # Options -IMAGE = $(BUILD_REGISTRY)/provider-digitalocean-controller-$(ARCH) -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) docker publish $(IMAGE) + @$(MAKE) BUILD_ARGS="--push" img.build.shared + @$(OK) docker publish $(IMAGE) + +img.build.shared: @cp Dockerfile $(IMAGE_TEMP_DIR) || $(FAIL) - @cp $(OUTPUT_DIR)/bin/$(OS)_$(ARCH)/provider $(IMAGE_TEMP_DIR) || $(FAIL) - @cd $(IMAGE_TEMP_DIR) && $(SED_CMD) 's|BASEIMAGE|$(OSBASEIMAGE)|g' Dockerfile || $(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) docker promote $(FROM_IMAGE) to $(TO_IMAGE) + @docker buildx imagetools create -t $(TO_IMAGE) $(FROM_IMAGE) + @$(OK) docker promote $(FROM_IMAGE) to $(TO_IMAGE) \ No newline at end of file diff --git a/cluster/images/provider-digitalocean/Dockerfile b/cluster/images/provider-digitalocean/Dockerfile index 332e751..32fbfc0 100644 --- a/cluster/images/provider-digitalocean/Dockerfile +++ b/cluster/images/provider-digitalocean/Dockerfile @@ -1,3 +1,3 @@ -FROM BASEIMAGE +FROM scratch COPY package.yaml . diff --git a/cluster/images/provider-digitalocean/Makefile b/cluster/images/provider-digitalocean/Makefile index a98aa45..d57ce69 100755 --- a/cluster/images/provider-digitalocean/Makefile +++ b/cluster/images/provider-digitalocean/Makefile @@ -1,28 +1,37 @@ # ==================================================================================== # Setup Project -PLATFORMS := linux_amd64 linux_arm64 include ../../../build/makelib/common.mk # ==================================================================================== # Options -IMAGE = $(BUILD_REGISTRY)/provider-digitalocean-$(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) docker publish $(IMAGE) + @$(MAKE) BUILD_ARGS="--push" img.build.shared + @$(OK) docker publish $(IMAGE) + +img.build.shared: @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) && 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) \ + @docker buildx build $(BUILD_ARGS) \ + --platform $(IMAGE_PLATFORMS) \ -t $(IMAGE) \ $(IMAGE_TEMP_DIR) || $(FAIL) - @$(OK) docker build $(IMAGE) + +img.promote: + @$(INFO) docker promote $(FROM_IMAGE) to $(TO_IMAGE) + @docker buildx imagetools create -t $(TO_IMAGE) $(FROM_IMAGE) + @$(OK) docker promote $(FROM_IMAGE) to $(TO_IMAGE) \ No newline at end of file diff --git a/cluster/local/integration_tests.sh b/cluster/local/integration_tests.sh index 663d3bd..7e4e61a 100755 --- a/cluster/local/integration_tests.sh +++ b/cluster/local/integration_tests.sh @@ -46,7 +46,7 @@ CONTROLLER_IMAGE="${BUILD_REGISTRY}/${PROJECT_NAME}-controller-${SAFEHOSTARCH}" version_tag="$(cat ${projectdir}/_output/version)" # tag as latest version to load into kind cluster -PACKAGE_CONTROLLER_IMAGE="${DOCKER_REGISTRY}/${PROJECT_NAME}-controller:${VERSION}" +PACKAGE_CONTROLLER_IMAGE="${PROJECT_NAME}/${PROJECT_NAME}-controller:${VERSION}" K8S_CLUSTER="${K8S_CLUSTER:-${BUILD_REGISTRY}-inttests}" CROSSPLANE_NAMESPACE="crossplane-system"