Skip to content

Commit

Permalink
[ShareChat] Make targets for pushing the image to GCR + the correspon…
Browse files Browse the repository at this point in the history
…ding README (#2)

Added Makefile and instruction / protocol in the README.
  • Loading branch information
isburmistrov authored Oct 31, 2024
1 parent d72e3ce commit 4b0aae9
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 0 deletions.
52 changes: 52 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
29 changes: 29 additions & 0 deletions Sharechat-Utils.mk
Original file line number Diff line number Diff line change
@@ -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,$(*))

0 comments on commit 4b0aae9

Please sign in to comment.