diff --git a/.github/workflows/release-image.yml b/.github/workflows/release-image.yml new file mode 100644 index 00000000..98ad3e6d --- /dev/null +++ b/.github/workflows/release-image.yml @@ -0,0 +1,43 @@ +name: RELEASE-IMAGE + +on: + workflow_dispatch: + inputs: + image_tag: + description: 'The tag name of image' + required: true + default: '' + release: + types: + - published + +env: + RELEASE_VERSION: ${{ github.ref_name }} + + +jobs: + image-tag: + runs-on: ubuntu-latest + outputs: + tag-name: ${{ steps.get_tag_name.outputs.tag_name }} + steps: + - name: Get Tag Name + id: get_tag_name + run: | + TAG_NAME=${{ inputs.image_tag }} + if [ -z "$TAG_NAME" ]; then + TAG_NAME=${{ env.RELEASE_VERSION }} + fi + echo tag_name=$TAG_NAME >> $GITHUB_OUTPUT + + release-image: + needs: image-tag + uses: apecloud/apecloud-cd/.github/workflows/release-image.yml@v0.1.11 + with: + MAKE_OPS: "docker-buildx" + IMG: "apecloud/go-ycsb" + VERSION: "${{ needs.image-tag.outputs.tag-name }}" + GO_VERSION: "1.20" + SYNC_ENABLE: false + APECD_REF: "v0.1.11" + secrets: inherit \ No newline at end of file diff --git a/Makefile b/Makefile index 17089fcc..9a83d180 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,19 @@ +# Image URL to use all building/pushing image targets +IMG ?= go-ycsb +VERSION ?= latest + FDB_CHECK := $(shell command -v fdbcli 2> /dev/null) ROCKSDB_CHECK := $(shell echo "int main() { return 0; }" | gcc -lrocksdb -x c++ -o /dev/null - 2>/dev/null; echo $$?) SQLITE_CHECK := $(shell echo "int main() { return 0; }" | gcc -lsqlite3 -x c++ -o /dev/null - 2>/dev/null; echo $$?) TAGS = +# 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 + ifdef FDB_CHECK TAGS += foundationdb endif @@ -42,3 +52,30 @@ endif check: golint -set_exit_status db/... cmd/... pkg/... +# If you wish built 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: ## Build docker image with the manager. + $(CONTAINER_TOOL) build -t ${IMG} . + +.PHONY: docker-push +docker-push: ## Push docker image with the manager. + $(CONTAINER_TOOL) push ${IMG} + +# PLATFORMS defines the target platforms for the manager image be build to provide support to multiple +# architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to: +# - able to use docker buildx . More info: https://docs.docker.com/build/buildx/ +# - have enable BuildKit, More info: https://docs.docker.com/develop/develop-images/build_enhancements/ +# - be able to push the image for your registry (i.e. if you do not inform a valid value via IMG=> then the export will fail) +# To properly provided solutions that supports more than one platform you should use this option. +PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le +.PHONY: docker-buildx +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 ${IMG}:${VERSION} -f Dockerfile.cross . + - $(CONTAINER_TOOL) buildx rm project-v3-builder + rm Dockerfile.cross \ No newline at end of file