mirror of
https://github.com/apache/superset.git
synced 2026-04-11 04:15:33 +00:00
feat(docker): Use docker buildx and Add ARM builds for dockerize and websocket (#25377)
This commit is contained in:
4
.github/workflows/docker-release.yml
vendored
4
.github/workflows/docker-release.yml
vendored
@@ -29,6 +29,10 @@ jobs:
|
||||
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 }}
|
||||
|
||||
14
.github/workflows/docker.yml
vendored
14
.github/workflows/docker.yml
vendored
@@ -35,7 +35,10 @@ jobs:
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- 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 }}
|
||||
@@ -49,7 +52,14 @@ jobs:
|
||||
mkdir -p ./build
|
||||
echo ${{ github.sha }} > ./build/SHA
|
||||
echo ${{ github.event.pull_request.number }} > ./build/PR-NUM
|
||||
DOCKER_BUILDKIT=1 docker build --target ci -t ${{ github.sha }} -t "pr-${{ github.event.pull_request.number }}" .
|
||||
docker buildx build --target ci \
|
||||
--load \
|
||||
--cache-from=type=local,src=/tmp/superset \
|
||||
-t ${{ github.sha }} \
|
||||
-t "pr-${{ github.event.pull_request.number }}" \
|
||||
--platform linux/amd64 \
|
||||
--label "build_actor=${GITHUB_ACTOR}" \
|
||||
.
|
||||
docker save ${{ github.sha }} | gzip > ./build/${{ github.sha }}.tar.gz
|
||||
|
||||
- name: Upload build artifacts
|
||||
|
||||
81
.github/workflows/docker_build_push.sh
vendored
81
.github/workflows/docker_build_push.sh
vendored
@@ -43,13 +43,50 @@ cat<<EOF
|
||||
- ${REPO_NAME}:${LATEST_TAG}
|
||||
EOF
|
||||
|
||||
if [ -z "${DOCKERHUB_TOKEN}" ]; then
|
||||
# Skip if secrets aren't populated -- they're only visible for actions running in the repo (not on forks)
|
||||
echo "Skipping Docker push"
|
||||
# By default load it back
|
||||
DOCKER_ARGS="--load"
|
||||
ARCHITECTURE_FOR_BUILD="linux/amd64 linux/arm64"
|
||||
else
|
||||
# Login and push
|
||||
docker logout
|
||||
docker login --username "${DOCKERHUB_USER}" --password "${DOCKERHUB_TOKEN}"
|
||||
DOCKER_ARGS="--push"
|
||||
ARCHITECTURE_FOR_BUILD="linux/amd64,linux/arm64"
|
||||
fi
|
||||
set -x
|
||||
|
||||
#
|
||||
# Build the dev image
|
||||
#
|
||||
docker buildx build --target dev \
|
||||
$DOCKER_ARGS \
|
||||
--cache-from=type=registry,ref=apache/superset:master-dev \
|
||||
--cache-from=type=local,src=/tmp/superset \
|
||||
--cache-to=type=local,ignore-error=true,dest=/tmp/superset \
|
||||
-t "${REPO_NAME}:${SHA}-dev" \
|
||||
-t "${REPO_NAME}:${REFSPEC}-dev" \
|
||||
-t "${REPO_NAME}:${LATEST_TAG}-dev" \
|
||||
--platform linux/amd64 \
|
||||
--label "sha=${SHA}" \
|
||||
--label "built_at=$(date)" \
|
||||
--label "target=dev" \
|
||||
--label "build_actor=${GITHUB_ACTOR}" \
|
||||
.
|
||||
|
||||
#
|
||||
# Build the "lean" image
|
||||
#
|
||||
DOCKER_BUILDKIT=1 docker build --target lean \
|
||||
docker buildx build --target lean \
|
||||
$DOCKER_ARGS \
|
||||
--cache-from=type=local,src=/tmp/superset \
|
||||
--cache-to=type=local,ignore-error=true,dest=/tmp/superset \
|
||||
-t "${REPO_NAME}:${SHA}" \
|
||||
-t "${REPO_NAME}:${REFSPEC}" \
|
||||
-t "${REPO_NAME}:${LATEST_TAG}" \
|
||||
--platform linux/amd64 \
|
||||
--label "sha=${SHA}" \
|
||||
--label "built_at=$(date)" \
|
||||
--label "target=lean" \
|
||||
@@ -59,60 +96,48 @@ DOCKER_BUILDKIT=1 docker build --target lean \
|
||||
#
|
||||
# Build the "lean310" image
|
||||
#
|
||||
DOCKER_BUILDKIT=1 docker build --target lean \
|
||||
docker buildx build --target lean \
|
||||
$DOCKER_ARGS \
|
||||
--cache-from=type=local,src=/tmp/superset \
|
||||
--cache-to=type=local,ignore-error=true,dest=/tmp/superset \
|
||||
-t "${REPO_NAME}:${SHA}-py310" \
|
||||
-t "${REPO_NAME}:${REFSPEC}-py310" \
|
||||
-t "${REPO_NAME}:${LATEST_TAG}-py310" \
|
||||
--platform linux/amd64 \
|
||||
--build-arg PY_VER="3.10-slim-bookworm"\
|
||||
--label "sha=${SHA}" \
|
||||
--label "built_at=$(date)" \
|
||||
--label "target=lean310" \
|
||||
--label "build_actor=${GITHUB_ACTOR}" \
|
||||
.
|
||||
|
||||
for BUILD_PLATFORM in $ARCHITECTURE_FOR_BUILD; do
|
||||
#
|
||||
# Build the "websocket" image
|
||||
#
|
||||
DOCKER_BUILDKIT=1 docker build \
|
||||
docker buildx build \
|
||||
$DOCKER_ARGS \
|
||||
--cache-from=type=registry,ref=apache/superset:master-websocket \
|
||||
-t "${REPO_NAME}:${SHA}-websocket" \
|
||||
-t "${REPO_NAME}:${REFSPEC}-websocket" \
|
||||
-t "${REPO_NAME}:${LATEST_TAG}-websocket" \
|
||||
--platform ${BUILD_PLATFORM} \
|
||||
--label "sha=${SHA}" \
|
||||
--label "built_at=$(date)" \
|
||||
--label "target=websocket" \
|
||||
--label "build_actor=${GITHUB_ACTOR}" \
|
||||
superset-websocket
|
||||
|
||||
#
|
||||
# Build the dev image
|
||||
#
|
||||
DOCKER_BUILDKIT=1 docker build --target dev \
|
||||
-t "${REPO_NAME}:${SHA}-dev" \
|
||||
-t "${REPO_NAME}:${REFSPEC}-dev" \
|
||||
-t "${REPO_NAME}:${LATEST_TAG}-dev" \
|
||||
--label "sha=${SHA}" \
|
||||
--label "built_at=$(date)" \
|
||||
--label "target=dev" \
|
||||
--label "build_actor=${GITHUB_ACTOR}" \
|
||||
.
|
||||
|
||||
#
|
||||
# Build the dockerize image
|
||||
#
|
||||
DOCKER_BUILDKIT=1 docker build \
|
||||
docker buildx build \
|
||||
$DOCKER_ARGS \
|
||||
--cache-from=type=registry,ref=apache/superset:dockerize \
|
||||
-t "${REPO_NAME}:dockerize" \
|
||||
--platform ${BUILD_PLATFORM} \
|
||||
--label "sha=${SHA}" \
|
||||
--label "built_at=$(date)" \
|
||||
--label "build_actor=${GITHUB_ACTOR}" \
|
||||
-f dockerize.Dockerfile \
|
||||
.
|
||||
|
||||
if [ -z "${DOCKERHUB_TOKEN}" ]; then
|
||||
# Skip if secrets aren't populated -- they're only visible for actions running in the repo (not on forks)
|
||||
echo "Skipping Docker push"
|
||||
else
|
||||
# Login and push
|
||||
docker logout
|
||||
docker login --username "${DOCKERHUB_USER}" --password "${DOCKERHUB_TOKEN}"
|
||||
docker push --all-tags "${REPO_NAME}"
|
||||
fi
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user