From b92ae100ecbea7876aa8b57559ca67c892f8c84d Mon Sep 17 00:00:00 2001 From: Ivan Burmistrov <90776737+isburmistrov@users.noreply.github.com> Date: Thu, 31 Oct 2024 12:29:54 +0000 Subject: [PATCH] [ShareChat] Make targets for pushing the image to GCR + the corresponding README (#2) Added Makefile and instruction / protocol in the README. --- Makefile | 52 ++++++++++++++++++++++++++++++++++++++++++++++ README.md | 12 +++++++++++ Sharechat-Utils.mk | 29 ++++++++++++++++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 Makefile create mode 100644 Sharechat-Utils.mk diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000..41d69e55b2 --- /dev/null +++ b/Makefile @@ -0,0 +1,52 @@ +############################################################################### +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +############################################################################### + + +SHELL := /bin/bash +.SHELLFLAGS := -Eeuoc pipefail +.ONESHELL: + +include Sharechat-Utils.mk + +build-docker-latest: \ + require-var.GITHUB_USER require-var.GITHUB_TOKEN + docker build \ + --tag "flink-kubernetes-operator:latest" \ + --file ./Dockerfile \ + . + +gcloud-auth-configure-docker: + gcloud auth configure-docker --quiet + +generate-docker-tag: + # We compute docker tag as following: we take git tag if it matches the pattern release-sharechat-* + # if suh tag exists, we remove release- prefix and use the rest as the docker tag. If such tag + # doesn't exist, we take last git commit hash instead. + rm -rf tmp-docker-tag.log + (git describe --tag --exact-match --match "release-sharechat-*" 2> /dev/null || git rev-parse HEAD) \ + | sed 's/^release-//' >> tmp-docker-tag.log + +push-docker-gcr.%: build-docker-latest gcloud-auth-configure-docker generate-docker-tag \ + require-var.DOCKER_REPO_% + dockerTag=$$(cat tmp-docker-tag.log) + dockerImage=${DOCKER_REPO_$(*)}/flink-kubernetes-operator:$${dockerTag} + docker tag flink-kubernetes-operator:latest $${dockerImage} + docker push $${dockerImage} + echo "Pushed Flink Kubernetes Operator image $$dockerImage" + +push-docker-gcr-all: push-docker-gcr.MOJ push-docker-gcr.SC diff --git a/README.md b/README.md index 353aeb33be..71c55fae43 100644 --- a/README.md +++ b/README.md @@ -47,3 +47,15 @@ You can learn more about how to contribute in the [Apache Flink website](https:/ ## License The code in this repository is licensed under the [Apache Software License 2](LICENSE). + +## ShareChat's fork + +We maintain our own fork of [Flink Kubernetes Operator](https://github.com/apache/flink-kubernetes-operator) according to the following rules: +- ShareChat's main branch is main-sharechat +- When proposing changes, we create branch from main-sharechat and make pull request with the base = main-sharechat +- All pull request must have [ShareChat] prefix in the title so it gets passed to the corresponding commit in the main-sharechat branch +- When new release of upstream Flink Kubernetes Operator is released, we create branch with the name release-sharechat-xxx starting from the corresponding release-xxx of the upstream operator +- Once branch is created, we cherry-pick all the commits marked as [ShareChat] from main-sharechat +- After that, we tag the last commit in the release branch by release-sharechat-xxx tag + +After that, to push the image to GCR, [this](https://teamcity.staging.sharechat.com/buildConfiguration/AiOrgProjects_FlinkKubernetesOperator_PushFlinkKubernetesOperatorImage?mode=builds) TeamCity build config should be used. \ No newline at end of file diff --git a/Sharechat-Utils.mk b/Sharechat-Utils.mk new file mode 100644 index 0000000000..6986d94238 --- /dev/null +++ b/Sharechat-Utils.mk @@ -0,0 +1,29 @@ +############################################################################### +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +############################################################################### + + +define check_var + if [ -z "$($(1))" ]; then \ + echo "Environment variable $(1) is not set"; \ + exit 1; \ + fi +endef + +require-var.%: + @ $(call check_var,$(*)) +