diff --git a/.asf.yaml b/.asf.yaml index ab980e0c3fb2..8a735cea56f7 100644 --- a/.asf.yaml +++ b/.asf.yaml @@ -64,7 +64,6 @@ github: - cypress-matrix (1, chrome) - cypress-matrix (2, chrome) - cypress-matrix (3, chrome) - - docker-build - frontend-build - pre-commit (3.9) - python-lint (3.9) @@ -72,6 +71,13 @@ github: - test-postgres (3.9) - test-postgres (3.10) - test-sqlite (3.9) + # Build workflow jobs - docker.yml + - 3.9-slim-bookworm lean image + - 3.10-slim-bookworm lean image + - dev image + - dockerize image + - ephemeral env image + - websocket image required_pull_request_reviews: dismiss_stale_reviews: false diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml deleted file mode 100644 index 7cfba73299b4..000000000000 --- a/.github/workflows/docker-release.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Docker - -on: - release: - types: [published] -jobs: - config: - runs-on: "ubuntu-latest" - outputs: - has-secrets: ${{ steps.check.outputs.has-secrets }} - steps: - - name: "Check for secrets" - id: check - shell: bash - run: | - if [ -n "${{ (secrets.DOCKERHUB_USER != '' && secrets.DOCKERHUB_TOKEN != '') || '' }}" ]; then - echo "has-secrets=1" >> "$GITHUB_OUTPUT" - fi - - docker-release: - needs: config - if: needs.config.outputs.has-secrets - name: docker-release - runs-on: ubuntu-latest - steps: - - name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )" - uses: actions/checkout@v3 - with: - persist-credentials: false - submodules: recursive - ref: ${{ github.ref }} - - name: Set up QEMU - uses: docker/setup-qemu-action@v1 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - shell: bash - env: - DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }} - DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} - run: | - GITHUB_RELEASE_TAG_NAME="${{ github.event.release.tag_name }}" - ./scripts/docker_build_push.sh "$GITHUB_RELEASE_TAG_NAME" diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 6160d3cc1f59..0d0bc45851c4 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,12 +1,15 @@ -name: Docker +name: Build on: + release: + types: [ published ] push: branches: - 'master' pull_request: types: [synchronize, opened, reopened, ready_for_review] + jobs: config: runs-on: "ubuntu-latest" @@ -21,33 +24,249 @@ jobs: echo "has-secrets=1" >> "$GITHUB_OUTPUT" echo "has secrets!" else - echo "has-secrets=0" >> "$GITHUB_OUTPUT" echo "no secrets!" fi - docker-build: + + build-lean-image: + name: ${{ matrix.image.version }} lean image needs: config - if: needs.config.outputs.has-secrets - name: docker-build runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + image: + - {version: "3.9-slim-bookworm", suffix: ""} + - {version: "3.10-slim-bookworm", suffix: "-py310"} steps: - - name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )" - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ github.repository }} + flavor: | + latest=false + suffix=${{ matrix.image.suffix }} + tags: | + type=sha,prefix=,format=long + type=ref,event=pr + type=raw,value=master,enable={{is_default_branch}} + type=raw,value=latest,enable={{is_default_branch}} + type=pep440,pattern={{version}} + labels: | + target=lean + build_actor=${{ github.actor }} + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64 + load: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + target: lean + build-args: | + PY_VER=${{ matrix.image.version }} + - name: Login to Docker Hub + if: needs.config.outputs.has-secrets + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Push + if: needs.config.outputs.has-secrets + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + target: lean + build-args: | + PY_VER=${{ matrix.image.version }} + + + build-dev-image: + name: dev image + needs: config + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ github.repository }} + flavor: | + latest=false + suffix=-dev + tags: | + type=sha,prefix=,format=long + type=ref,event=pr + type=raw,value=master,enable={{is_default_branch}} + type=raw,value=latest,enable={{is_default_branch}} + type=pep440,pattern={{version}} + labels: | + target=dev + build_actor=${{ github.actor }} + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64 + load: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + target: dev + - name: Login to Docker Hub + if: needs.config.outputs.has-secrets + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Push + if: needs.config.outputs.has-secrets + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + target: dev + + + build-websocket-image: + name: websocket image + needs: config + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 with: persist-credentials: false - name: Set up QEMU - uses: docker/setup-qemu-action@v1 + uses: docker/setup-qemu-action@v3 + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ github.repository }} + flavor: | + latest=false + suffix=-websocket + tags: | + type=sha,prefix=,format=long + type=ref,event=pr + type=raw,value=master,enable={{is_default_branch}} + type=raw,value=latest,enable={{is_default_branch}} + type=pep440,pattern={{version}} + labels: | + build_actor=${{ github.actor }} - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - shell: bash - env: - DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }} - DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} - run: | - ./scripts/docker_build_push.sh + uses: docker/setup-buildx-action@v3 + - name: Build + uses: docker/build-push-action@v5 + with: + context: ./superset-websocket + platforms: linux/amd64 + load: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + - name: Login to Docker Hub + if: needs.config.outputs.has-secrets + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Push + if: needs.config.outputs.has-secrets + uses: docker/build-push-action@v5 + with: + context: ./superset-websocket + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + + build-dockerize-image: + name: dockerize image + needs: config + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ github.repository }} + flavor: | + latest=false + tags: | + type=raw,value=dockerize,enable={{is_default_branch}} + labels: | + build_actor=${{ github.actor }} + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build + uses: docker/build-push-action@v5 + with: + context: . + file: dockerize.Dockerfile + platforms: linux/amd64 + load: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + - name: Login to Docker Hub + if: needs.config.outputs.has-secrets + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Push + if: needs.config.outputs.has-secrets + uses: docker/build-push-action@v5 + with: + context: . + file: dockerize.Dockerfile + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + # build Dockerfile 'ci' target, save to archive and upload as artifact + build-ephemeral-image: + name: ephemeral env image + needs: config + if: github.event_name == 'pull_request' + runs-on: ubuntu-latest + steps: + - name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )" + uses: actions/checkout@v3 + with: + persist-credentials: false + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - name: Build ephemeral env image - if: github.event_name == 'pull_request' run: | mkdir -p ./build echo ${{ github.sha }} > ./build/SHA @@ -61,9 +280,7 @@ jobs: --label "build_actor=${GITHUB_ACTOR}" \ . docker save ${{ github.sha }} | gzip > ./build/${{ github.sha }}.tar.gz - - name: Upload build artifacts - if: github.event_name == 'pull_request' uses: actions/upload-artifact@v3 with: name: build diff --git a/scripts/docker_build_push.sh b/scripts/docker_build_push.sh deleted file mode 100755 index 8ae82faaeb5e..000000000000 --- a/scripts/docker_build_push.sh +++ /dev/null @@ -1,189 +0,0 @@ -#!/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. -# -set -eo pipefail - -GITHUB_RELEASE_TAG_NAME="$1" - -SHA=$(git rev-parse HEAD) -REPO_NAME="apache/superset" - -if [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then - REFSPEC=$(echo "${GITHUB_HEAD_REF}" | sed 's/[^a-zA-Z0-9]/-/g' | head -c 40) - PR_NUM=$(echo "${GITHUB_REF}" | sed 's:refs/pull/::' | sed 's:/merge::') - LATEST_TAG="pr-${PR_NUM}" -elif [[ "${GITHUB_EVENT_NAME}" == "release" ]]; then - REFSPEC=$(echo "${GITHUB_REF}" | sed 's:refs/tags/::' | head -c 40) - LATEST_TAG="${REFSPEC}" -else - REFSPEC=$(echo "${GITHUB_REF}" | sed 's:refs/heads/::' | sed 's/[^a-zA-Z0-9]/-/g' | head -c 40) - LATEST_TAG="${REFSPEC}" -fi - - -if [[ "${REFSPEC}" == "master" ]]; then - LATEST_TAG="master" -fi - -# get the latest release tag -if [ -n "${GITHUB_RELEASE_TAG_NAME}" ]; then - output=$(source ./scripts/tag_latest_release.sh "${GITHUB_RELEASE_TAG_NAME}" --dry-run) || true - SKIP_TAG=$(echo "${output}" | grep "SKIP_TAG" | cut -d'=' -f2) - if [[ "${SKIP_TAG}" == "SKIP_TAG::false" ]]; then - LATEST_TAG="latest" - fi -fi - -if [[ "${TEST_ENV}" == "true" ]]; then - # don't run the build in test environment - echo "LATEST_TAG is ${LATEST_TAG}" - exit 0 -fi - - -cat<