Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Parallelize the CI image builds #25564

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .asf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,20 @@ 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)
- test-mysql (3.9)
- 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
Expand Down
41 changes: 0 additions & 41 deletions .github/workflows/docker-release.yml

This file was deleted.

253 changes: 235 additions & 18 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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
Copy link
Contributor Author

@sebastianliebscher sebastianliebscher Oct 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not work as expected. The check if: needs.config.outputs.has-secrets returns true in both cases.

Either check for if: needs.config.outputs.has-secrets == 1 or don't set has-secrets when there are no secrets. I went with the latter.


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: |
.github/workflows/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
Expand All @@ -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
Expand Down
Loading