Skip to content

Commit

Permalink
Merge pull request #188 from DataWorkflowServices/release-v0.0.19
Browse files Browse the repository at this point in the history
Release v0.0.19
  • Loading branch information
roehrich-hpe committed Mar 21, 2024
2 parents 87d8d06 + db7c3d1 commit 2a48f6b
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 15 deletions.
11 changes: 9 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2020-2023 Hewlett Packard Enterprise Development LP
# Copyright 2020-2024 Hewlett Packard Enterprise Development LP
# Other additional copyright holders may be indicated within.
#
# The entirety of this work is licensed under the Apache License,
Expand All @@ -18,6 +18,9 @@
# Build the manager binary
FROM golang:1.19 as builder

ARG TARGETARCH
ARG TARGETOS

WORKDIR /workspace
# Copy the Go Modules manifests
COPY go.mod go.mod
Expand All @@ -33,7 +36,11 @@ COPY vendor/ vendor/
COPY github/cluster-api/util/conversion/ github/cluster-api/util/conversion/

# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager cmd/main.go
# the GOARCH has a default value to allow the binary be built according to the host where the command
# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO
# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore,
# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform.
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go

FROM builder as testing
WORKDIR /workspace
Expand Down
48 changes: 36 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.


# Default container tool to use.
# To use podman:
# $ DOCKER=podman make docker-build
DOCKER ?= docker

# VERSION defines the project version for the bundle.
# Update this value when you upgrade the version of your project.
# To re-generate a bundle for another specific version without changing the standard setup, you can:
Expand Down Expand Up @@ -81,6 +75,12 @@ else
GOBIN=$(shell go env GOBIN)
endif

# CONTAINER_TOOL defines the container tool to be used for building images.
# Be aware that the target commands are only tested with Docker which is
# scaffolded by default. However, you might want to replace it to use other
# tools. (i.e. podman)
CONTAINER_TOOL ?= docker

# Setting SHELL to bash allows bash commands to be executed by recipes.
# This is a requirement for 'setup-envtest.sh' in the test target.
# Options are set to exit when a recipe line exits non-zero or a piped command fails.
Expand Down Expand Up @@ -121,8 +121,8 @@ vet: ## Run go vet against code.

container-unit-test: VERSION ?= $(shell cat .version)
container-unit-test: .version ## Build docker image with the manager and execute unit tests.
${DOCKER} build -f Dockerfile --label $(IMAGE_TAG_BASE)-$@:$(VERSION)-$@ -t $(IMAGE_TAG_BASE)-$@:$(VERSION) --target testing .
${DOCKER} run --rm -t --name $@-nnf-sos $(IMAGE_TAG_BASE)-$@:$(VERSION)
${CONTAINER_TOOL} build -f Dockerfile --label $(IMAGE_TAG_BASE)-$@:$(VERSION)-$@ -t $(IMAGE_TAG_BASE)-$@:$(VERSION) --target testing .
${CONTAINER_TOOL} run --rm -t --name $@-nnf-sos $(IMAGE_TAG_BASE)-$@:$(VERSION)

TESTDIR ?= ./...
test: manifests generate fmt vet envtest ## Run tests.
Expand All @@ -135,13 +135,37 @@ build: manifests generate fmt vet ## Build manager binary.
run: manifests generate fmt vet ## Run a controller from your host.
go run cmd/main.go


# If you wish to build the manager image targeting other platforms you can use the --platform flag.
# (i.e. docker build --platform linux/arm64). However, you must enable docker buildKit for it.
# More info: https://docs.docker.com/develop/develop-images/build_enhancements/
.PHONY: docker-build
docker-build: VERSION ?= $(shell cat .version)
docker-build: .version manifests generate fmt vet ## Build docker image with the manager.
${DOCKER} build -t $(IMAGE_TAG_BASE):$(VERSION) .
${CONTAINER_TOOL} build -t $(IMAGE_TAG_BASE):$(VERSION) .

.PHONY: docker-push
docker-push: VERSION ?= $(shell cat .version)
docker-push: .version ## Push docker image with the manager.
${DOCKER} push $(IMAGE_TAG_BASE):$(VERSION)
${CONTAINER_TOOL} push $(IMAGE_TAG_BASE):$(VERSION)

# PLATFORMS defines the target platforms for the manager image be built to provide support to multiple
# architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to:
# - be able to use docker buildx. More info: https://docs.docker.com/build/buildx/
# - have enabled BuildKit. More info: https://docs.docker.com/develop/develop-images/build_enhancements/
# - be able to push the image to your registry (i.e. if you do not set a valid value via IMG=<myregistry/image:<tag>> then the export will fail)
# To adequately provide solutions that are compatible with multiple platforms, you should consider using this option.
PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
.PHONY: docker-buildx
docker-buildx: VERSION ?= $(shell cat .version)
docker-buildx: ## Build and push docker image for the manager for cross-platform support
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
- $(CONTAINER_TOOL) buildx create --name project-v3-builder
$(CONTAINER_TOOL) buildx use project-v3-builder
- $(CONTAINER_TOOL) buildx build --push --platform=$(PLATFORMS) --tag $(IMAGE_TAG_BASE):$(VERSION) -f Dockerfile.cross .
- $(CONTAINER_TOOL) buildx rm project-v3-builder
rm Dockerfile.cross

KIND_CLUSTER ?= "kind"
kind-push: VERSION ?= $(shell cat .version)
Expand Down Expand Up @@ -295,7 +319,7 @@ bundle: manifests kustomize ## Generate bundle manifests and metadata, then vali
bundle-build: VERSION ?= $(shell cat .version)
bundle-build: BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-bundle:v$(VERSION)
bundle-build: .version ## Build the bundle image.
${DOCKER} build -f bundle.Dockerfile -t $(BUNDLE_IMG) .
${CONTAINER_TOOL} build -f bundle.Dockerfile -t $(BUNDLE_IMG) .

.PHONY: bundle-push
bundle-push: VERSION ?= $(shell cat .version)
Expand Down Expand Up @@ -337,7 +361,7 @@ endif
# https://github.com/operator-framework/community-operators/blob/7f1438c/docs/packaging-operator.md#updating-your-existing-operator
.PHONY: catalog-build
catalog-build: opm ## Build a catalog image.
$(OPM) index add --container-tool ${DOCKER} --mode semver --tag $(CATALOG_IMG) --bundles $(BUNDLE_IMGS) $(FROM_INDEX_OPT)
$(OPM) index add --container-tool ${CONTAINER_TOOL} --mode semver --tag $(CATALOG_IMG) --bundles $(BUNDLE_IMGS) $(FROM_INDEX_OPT)

# Push the catalog image.
.PHONY: catalog-push
Expand Down
3 changes: 2 additions & 1 deletion deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ if [[ $CMD == 'undeploy' ]]; then
$KUSTOMIZE build config/prometheus | kubectl delete --ignore-not-found -f-
fi
# Do not touch the namespace resource when deleting this service.
$KUSTOMIZE build "$OVERLAY_DIR" | yq eval 'select(.kind != "Namespace")' | kubectl delete --ignore-not-found -f -
# Wishing for yq(1)...
$KUSTOMIZE build "$OVERLAY_DIR" | python3 -c 'import yaml, sys; all_docs = yaml.safe_load_all(sys.stdin); less_docs=[doc for doc in all_docs if doc["kind"] != "Namespace"]; print(yaml.dump_all(less_docs))' | kubectl delete --ignore-not-found -f -
fi

exit 0

0 comments on commit 2a48f6b

Please sign in to comment.