This is an automated email from the ASF dual-hosted git repository.
rmetzger pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink-docker.git
The following commit(s) were added to refs/heads/master by this push:
new f47f4a2 [FLINK-20632] Add script to publish docker images to Docker
Hub (apache/flink)
f47f4a2 is described below
commit f47f4a2e257279c4c28667e3ceff12bc5eb70afb
Author: Robert Metzger <[email protected]>
AuthorDate: Tue Jan 5 14:42:38 2021 +0100
[FLINK-20632] Add script to publish docker images to Docker Hub
(apache/flink)
---
README.md | 11 ++++-
generate-stackbrew-library.sh => common.sh | 56 +++++++------------------
generate-stackbrew-library.sh | 67 ++++++++----------------------
publish-to-dockerhub.sh | 61 +++++++++++++++++++++++++++
4 files changed, 104 insertions(+), 91 deletions(-)
diff --git a/README.md b/README.md
index 228ec23..08ff20c 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@ Apache Flink Docker Images
==========================
This repo contains Dockerfiles for building Docker images for Apache Flink,
and are used to build
-the "official" [`flink`](https://hub.docker.com/_/flink) images hosted on
Docker Hub.
+the "official" [`flink`](https://hub.docker.com/_/flink) images hosted on
Docker Hub (reviewed and build by Docker), as well as the images published on
[`apache/flink` DockerHub](https://hub.docker.com/r/apache/flink) (maintained
by Flink committers).
These Dockerfiles are maintained by the Apache Flink community, but the Docker
community is
responsible for building and hosting the images on Docker Hub.
@@ -83,7 +83,14 @@ Updating the Dockerfiles involves the following steps:
https://github.com/apache/flink-docker/commit/5920fd775ca1a8d03ee959d79bceeb5d6e8f35a1)]</sup>
* Create a pull request against the `master` branch containing this commit.
-Once the pull request has been merged, a new manifest should be generated and
a pull request opened
+Once the pull request has been merged, we can release the new docker images:
+
+For **publishing to DockerHub: apache/flink** , you need to perform the
following steps:
+
+1. Make sure that you are authenticated with your Docker ID, and that your
Docker ID has access to `apache/flink`. If not, request access by INFRA (see
[also](https://issues.apache.org/jira/browse/INFRA-21276): `docker login -u
<username>`.
+2. Generate and upload the new images: `./publish-to-dockerhub.sh`.
+
+For **publishing as an official image**, a new manifest should be generated
and a pull request opened
on the Docker Library
[`official-images`](https://github.com/docker-library/official-images) repo.
1. Run `./generate-stackbrew-library.sh` to output the new manifest (see note
[below](
diff --git a/generate-stackbrew-library.sh b/common.sh
old mode 100755
new mode 100644
similarity index 56%
copy from generate-stackbrew-library.sh
copy to common.sh
index d370529..6c9d695
--- a/generate-stackbrew-library.sh
+++ b/common.sh
@@ -1,15 +1,22 @@
#!/usr/bin/env bash
-# This script generates a manifest compatibile with the expectations set forth
-# by docker-library/official-images.
-#
-# It is not compatible with the version of Bash currently shipped with OS X due
-# to the use of features introduced in Bash 4.
-
-set -eu
-self="$(basename "$BASH_SOURCE")"
-cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
+#
+# 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.
+#
# get the most recent commit which modified any of "$@"
@@ -60,34 +67,3 @@ extractValue() {
# get latest flink version
latest_version=`ls -1a | grep -E "[0-9]+.[0-9]+" | sort -V -r | head -n 1`
-
-cat <<-EOH
-# this file is generated via
https://github.com/apache/flink-docker/blob/$(fileCommit "$self")/$self
-
-Maintainers: Patrick Lucas <[email protected]> (@patricklucas),
- Ismaël Mejía <[email protected]> (@iemejia)
-GitRepo: https://github.com/apache/flink-docker.git
-EOH
-
-
-for dockerfile in $(find . -name "Dockerfile"); do
- dir=$(dirname $dockerfile)
-
- commit="$(dirCommit "$dir")"
- metadata="$dir/release.metadata"
- architectures=$(extractValue "Architectures" $metadata)
- tags=$(extractValue "Tags" $metadata)
- tags=$(pruneTags "$tags" $latest_version)
-
- # newline
- echo
-
- # The tabs here are necessary for the heredoc to work right
- cat <<-EOE
- Tags: $tags
- Architectures: $architectures
- GitCommit: $commit
- Directory: $dir
- EOE
-
-done
diff --git a/generate-stackbrew-library.sh b/generate-stackbrew-library.sh
index d370529..238a9f0 100755
--- a/generate-stackbrew-library.sh
+++ b/generate-stackbrew-library.sh
@@ -1,5 +1,22 @@
#!/usr/bin/env bash
+#
+# 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.
+#
+
# This script generates a manifest compatibile with the expectations set forth
# by docker-library/official-images.
#
@@ -11,55 +28,7 @@ set -eu
self="$(basename "$BASH_SOURCE")"
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
-
-# get the most recent commit which modified any of "$@"
-fileCommit() {
- git log -1 --format='format:%H' HEAD -- "$@"
-}
-
-# get the most recent commit which modified "$1/Dockerfile" or any file COPY'd
from "$1/Dockerfile"
-dirCommit() {
- local dir="$1"; shift
- (
- cd "$dir"
- fileCommit \
- Dockerfile \
- $(git show HEAD:./Dockerfile | awk '
- toupper($1) == "COPY" {
- for (i = 2; i < NF; i++) {
- print $i
- }
- }
- ')
- )
-}
-
-# Inputs:
-# - tags: comma-seprated list of image tags
-# - latestVersion: latest version
-# Output: comma-separated list of tags with "latest" removed if not latest
version
-pruneTags() {
- local tags=$1
- local latestVersion=$2
- if [[ $tags =~ $latestVersion ]]; then
- # tags contains latest version. keep "latest" tag
- echo $tags
- else
- # remove "latest", any "scala_" or "javaXX" tag, unless it is the
latest version
- # the "scala" / "java" tags have a similar semantic as the "latest"
tag in docker registries.
- echo $tags | sed -E 's|,
(scala\|latest\|java[0-9]{1,2})[-_.[:alnum:]]*||g'
- fi
-}
-
-extractValue() {
- local key="$1"
- local file="$2"
- local line=$(cat $file | grep "$key:")
- echo $line | sed "s/${key}: //g"
-}
-
-# get latest flink version
-latest_version=`ls -1a | grep -E "[0-9]+.[0-9]+" | sort -V -r | head -n 1`
+source common.sh
cat <<-EOH
# this file is generated via
https://github.com/apache/flink-docker/blob/$(fileCommit "$self")/$self
diff --git a/publish-to-dockerhub.sh b/publish-to-dockerhub.sh
new file mode 100755
index 0000000..6a73fed
--- /dev/null
+++ b/publish-to-dockerhub.sh
@@ -0,0 +1,61 @@
+#!/usr/bin/env bash
+
+#
+# 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.
+#
+
+# This script publishes the Flink docker images to any Docker registry. By
default it's configured to the apache/flink DockerHub account.
+
+self="$(basename "$BASH_SOURCE")"
+cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
+
+source common.sh
+
+TARGET_REGISTRY=${TARGET_REGISTRY:-"apache/flink"}
+
+echo "Publishing to target registry: $TARGET_REGISTRY"
+
+for dockerfile in $(find . -name "Dockerfile"); do
+ dir=$(dirname $dockerfile)
+
+ metadata="$dir/release.metadata"
+ tags=$(extractValue "Tags" $metadata)
+ tags=$(pruneTags "$tags" $latest_version)
+
+ echo "Building image in $dir"
+
+ DOCKER_BUILD_CMD="docker build"
+ DOCKER_PUSH_CMDS=()
+ IFS=',' read -ra TAGS_ARRAY <<< "$tags"
+ for raw_tag in "${TAGS_ARRAY[@]}"; do
+ # trim whitespace
+ tag=`echo $raw_tag | xargs`
+ DOCKER_BUILD_CMD+=" -t $TARGET_REGISTRY:$tag"
+ DOCKER_PUSH_CMDS+=( "docker push $TARGET_REGISTRY:$tag")
+ done
+ DOCKER_BUILD_CMD+=" $dir"
+ echo -e "\tBuilding docker image using command"
+ echo -e "\t\t$DOCKER_BUILD_CMD"
+ eval $DOCKER_BUILD_CMD
+ echo -e "\tPushing tags"
+ for push_cmd in "${DOCKER_PUSH_CMDS[@]}"; do
+ echo -e "\t\tPushing using $push_cmd"
+ eval $push_cmd
+ done
+
+ #newline
+ echo
+done