You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/05/06 10:46:23 UTC

[GitHub] [flink-docker] zentol commented on a diff in pull request #116: Publish snapshot images

zentol commented on code in PR #116:
URL: https://github.com/apache/flink-docker/pull/116#discussion_r866678641


##########
.github/workflows/snapshot.yml:
##########
@@ -0,0 +1,68 @@
+# 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.
+
+name: "Publish SNAPSHOTs"
+
+on:
+  # schedule:
+  #   - cron: '0 0 * * *' # Deploy every day
+  push:
+    branches:
+      - snapshot-dev-master
+
+env:
+  REGISTRY: ghcr.io
+  VERSION: 1.16-SNAPSHOT
+
+jobs:
+  ci:
+    uses: ./.github/workflows/ci.yml
+  snapshot:
+    needs: ci
+    runs-on: ubuntu-latest
+    permissions:
+      contents: read
+      packages: write
+    strategy:
+      matrix:
+        config:
+          - java_version: 8
+          - java_version: 11

Review Comment:
   ```suggestion
           java_version:
             - 8
             - 11
   ```
   We can remove one level of nesting.



##########
utils.sh:
##########
@@ -0,0 +1,59 @@
+#!/bin/bash -e
+
+IMAGE_REPO=$1
+echo "Image repository: $IMAGE_REPO"
+
+function image_tag() {
+    local dockerfile
+    dockerfile="$1"
+
+    local variant minor_version
+    variant="$(basename "$(dirname "$dockerfile")")"
+
+    echo "${variant}"
+}
+
+function image_name() {
+    local image_tag
+    image_tag="$1"
+
+    echo "${IMAGE_REPO}:${image_tag}"
+}
+
+function build_image() {
+    local dockerfile
+    dockerfile="$1"
+
+    local image_tag image_name dockerfile_dir
+    image_tag="$(image_tag "$dockerfile")"
+    image_name="$(image_name "$image_tag")"
+    dockerfile_dir="$(dirname "$dockerfile")"
+
+    echo >&2 "===> Building ${image_tag} image..."
+    docker build -t "$image_name" "$dockerfile_dir"
+}
+
+function publish_snapshots() {

Review Comment:
   This whole file seems over-engineered.
   
   Don't we really only need a `docker build <directory> -t apache/flink-docker:<tag>` call that we could in-line into the workflow?



##########
.github/workflows/snapshot.yml:
##########
@@ -0,0 +1,68 @@
+# 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.
+
+name: "Publish SNAPSHOTs"
+
+on:
+  # schedule:
+  #   - cron: '0 0 * * *' # Deploy every day
+  push:
+    branches:
+      - snapshot-dev-master
+
+env:
+  REGISTRY: ghcr.io
+  VERSION: 1.16-SNAPSHOT
+
+jobs:
+  ci:
+    uses: ./.github/workflows/ci.yml
+  snapshot:
+    needs: ci
+    runs-on: ubuntu-latest
+    permissions:
+      contents: read
+      packages: write
+    strategy:
+      matrix:
+        config:
+          - java_version: 8
+          - java_version: 11
+    steps:
+      - name: Set env
+        run: |
+          repo=${{ github.repository }}                        # apache/flink-docker
+          echo "IMAGE_REPO=$(echo ${repo##*/})" >> $GITHUB_ENV # apache
+          echo "OWNER=$(echo ${repo%%/*})" >> $GITHUB_ENV      # flink-docker

Review Comment:
   this should be overkill; we can hard-code all of these



##########
.github/workflows/snapshot.yml:
##########
@@ -0,0 +1,68 @@
+# 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.
+
+name: "Publish SNAPSHOTs"
+
+on:
+  # schedule:
+  #   - cron: '0 0 * * *' # Deploy every day
+  push:
+    branches:
+      - snapshot-dev-master
+
+env:
+  REGISTRY: ghcr.io
+  VERSION: 1.16-SNAPSHOT
+
+jobs:
+  ci:
+    uses: ./.github/workflows/ci.yml
+  snapshot:
+    needs: ci
+    runs-on: ubuntu-latest
+    permissions:
+      contents: read
+      packages: write
+    strategy:
+      matrix:
+        config:
+          - java_version: 8
+          - java_version: 11
+    steps:
+      - name: Set env
+        run: |
+          repo=${{ github.repository }}                        # apache/flink-docker
+          echo "IMAGE_REPO=$(echo ${repo##*/})" >> $GITHUB_ENV # apache
+          echo "OWNER=$(echo ${repo%%/*})" >> $GITHUB_ENV      # flink-docker
+      - uses: actions/checkout@v3
+      - name: Variables
+        run: | 
+          echo "OWNER: $OWNER"
+          echo "IMAGE_REPO: $IMAGE_REPO"
+      - name: Prepare Dockerfiles
+        run: |
+          ./add-custom.sh -u "https://s3.amazonaws.com/flink-nightly/flink-${VERSION}-bin-scala_2.12.tgz" -j ${{ matrix.config.java_version }} -n ${VERSION}-scala_2.12-java${{ matrix.config.java_version }}

Review Comment:
   This can't work on the master branch because the scripts are on the dev branches. If you want to do this then you need to checkout the respective dev-branch.



##########
.github/workflows/snapshot.yml:
##########
@@ -0,0 +1,68 @@
+# 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.
+
+name: "Publish SNAPSHOTs"
+
+on:
+  # schedule:
+  #   - cron: '0 0 * * *' # Deploy every day
+  push:
+    branches:
+      - snapshot-dev-master
+
+env:
+  REGISTRY: ghcr.io
+  VERSION: 1.16-SNAPSHOT
+
+jobs:
+  ci:
+    uses: ./.github/workflows/ci.yml
+  snapshot:
+    needs: ci
+    runs-on: ubuntu-latest
+    permissions:
+      contents: read
+      packages: write
+    strategy:
+      matrix:
+        config:
+          - java_version: 8
+          - java_version: 11
+    steps:
+      - name: Set env
+        run: |
+          repo=${{ github.repository }}                        # apache/flink-docker
+          echo "IMAGE_REPO=$(echo ${repo##*/})" >> $GITHUB_ENV # apache
+          echo "OWNER=$(echo ${repo%%/*})" >> $GITHUB_ENV      # flink-docker
+      - uses: actions/checkout@v3
+      - name: Variables
+        run: | 
+          echo "OWNER: $OWNER"
+          echo "IMAGE_REPO: $IMAGE_REPO"
+      - name: Prepare Dockerfiles
+        run: |
+          ./add-custom.sh -u "https://s3.amazonaws.com/flink-nightly/flink-${VERSION}-bin-scala_2.12.tgz" -j ${{ matrix.config.java_version }} -n ${VERSION}-scala_2.12-java${{ matrix.config.java_version }}
+      - name: Build image
+        run: |
+          source utils.sh ${IMAGE_REPO}
+          publish_snapshot ${VERSION} ${{ matrix.config.java_version }}
+      - name: Docker login
+        run: |
+          docker login ${REGISTRY} -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }}
+      - name: "Publish snapshots"
+        run: |
+          docker tag ${IMAGE_REPO}:${VERSION}-scala_2.12-java${{ matrix.config.java_version }}-debian ${REGISTRY}/${OWNER}/${IMAGE_REPO}:${VERSION}-scala_2.12-java${{ matrix.config.java_version }}-debian

Review Comment:
   we could skip this step if we used the correct tag right away when building the image



##########
.github/workflows/snapshot.yml:
##########
@@ -0,0 +1,68 @@
+# 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.
+
+name: "Publish SNAPSHOTs"
+
+on:
+  # schedule:

Review Comment:
   The snapshot workflow should also have the workflow_dispatcher trigger so we can manually trigger another deployment.



##########
.github/workflows/snapshot.yml:
##########
@@ -0,0 +1,68 @@
+# 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.
+
+name: "Publish SNAPSHOTs"
+
+on:
+  # schedule:
+  #   - cron: '0 0 * * *' # Deploy every day
+  push:
+    branches:
+      - snapshot-dev-master
+
+env:
+  REGISTRY: ghcr.io
+  VERSION: 1.16-SNAPSHOT
+
+jobs:
+  ci:
+    uses: ./.github/workflows/ci.yml

Review Comment:
   This doesn't get us a lot, and in practice wouldn't work. The ci workflow is defined in the dev-branches (so that CI is run), while the cron workflow needs to be on the master branch (because GHA says so).
   
   It's also questionable because the workflows aren't synced in any way w.r.t. versions for example.
   (i.e., the snapshot workflow may also do something for 1.15, but the ci one doesn't.



##########
.github/workflows/snapshot.yml:
##########
@@ -0,0 +1,68 @@
+# 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.
+
+name: "Publish SNAPSHOTs"
+
+on:
+  # schedule:
+  #   - cron: '0 0 * * *' # Deploy every day
+  push:
+    branches:
+      - snapshot-dev-master
+
+env:
+  REGISTRY: ghcr.io
+  VERSION: 1.16-SNAPSHOT
+
+jobs:
+  ci:

Review Comment:
   should have a condition to only run in the apache repo; we don't want to add a scheduled job into every fork.



##########
.github/workflows/snapshot.yml:
##########
@@ -0,0 +1,68 @@
+# 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.
+
+name: "Publish SNAPSHOTs"
+
+on:
+  # schedule:
+  #   - cron: '0 0 * * *' # Deploy every day
+  push:
+    branches:
+      - snapshot-dev-master
+
+env:
+  REGISTRY: ghcr.io
+  VERSION: 1.16-SNAPSHOT
+
+jobs:
+  ci:
+    uses: ./.github/workflows/ci.yml
+  snapshot:
+    needs: ci
+    runs-on: ubuntu-latest
+    permissions:
+      contents: read
+      packages: write
+    strategy:
+      matrix:
+        config:
+          - java_version: 8
+          - java_version: 11
+    steps:
+      - name: Set env
+        run: |
+          repo=${{ github.repository }}                        # apache/flink-docker
+          echo "IMAGE_REPO=$(echo ${repo##*/})" >> $GITHUB_ENV # apache
+          echo "OWNER=$(echo ${repo%%/*})" >> $GITHUB_ENV      # flink-docker
+      - uses: actions/checkout@v3
+      - name: Variables
+        run: | 
+          echo "OWNER: $OWNER"
+          echo "IMAGE_REPO: $IMAGE_REPO"
+      - name: Prepare Dockerfiles
+        run: |
+          ./add-custom.sh -u "https://s3.amazonaws.com/flink-nightly/flink-${VERSION}-bin-scala_2.12.tgz" -j ${{ matrix.config.java_version }} -n ${VERSION}-scala_2.12-java${{ matrix.config.java_version }}
+      - name: Build image
+        run: |
+          source utils.sh ${IMAGE_REPO}
+          publish_snapshot ${VERSION} ${{ matrix.config.java_version }}

Review Comment:
   naming-wise it's not clear why this is called "publish_snapshot", when all it does it build the image.



##########
.github/workflows/snapshot.yml:
##########
@@ -0,0 +1,68 @@
+# 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.
+
+name: "Publish SNAPSHOTs"
+
+on:
+  # schedule:
+  #   - cron: '0 0 * * *' # Deploy every day
+  push:
+    branches:
+      - snapshot-dev-master
+
+env:
+  REGISTRY: ghcr.io
+  VERSION: 1.16-SNAPSHOT

Review Comment:
   This will not work in the long term; we need the version to be a matrix so we can publish snapshot docker images for all versions.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org