2020-11-13 14:32:18 -05:00
|
|
|
#!/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
|
|
|
|
|
|
|
|
SHA=$(git rev-parse HEAD)
|
2021-01-10 12:29:17 -05:00
|
|
|
REPO_NAME="apache/superset"
|
2020-11-13 14:32:18 -05:00
|
|
|
|
|
|
|
if [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then
|
2021-02-11 13:18:27 -05:00
|
|
|
REFSPEC=$(echo "${GITHUB_HEAD_REF}" | sed 's/[^a-zA-Z0-9]/-/g' | head -c 40)
|
2020-11-13 14:32:18 -05:00
|
|
|
PR_NUM=$(echo "${GITHUB_REF}" | sed 's:refs/pull/::' | sed 's:/merge::')
|
|
|
|
LATEST_TAG="pr-${PR_NUM}"
|
2020-11-27 04:38:38 -05:00
|
|
|
elif [[ "${GITHUB_EVENT_NAME}" == "release" ]]; then
|
2021-01-15 02:23:59 -05:00
|
|
|
REFSPEC=$(echo "${GITHUB_REF}" | sed 's:refs/tags/::' | head -c 40)
|
2020-11-27 04:38:38 -05:00
|
|
|
LATEST_TAG="${REFSPEC}"
|
2020-11-13 14:32:18 -05:00
|
|
|
else
|
2021-02-11 13:18:27 -05:00
|
|
|
REFSPEC=$(echo "${GITHUB_REF}" | sed 's:refs/heads/::' | sed 's/[^a-zA-Z0-9]/-/g' | head -c 40)
|
2020-11-13 14:32:18 -05:00
|
|
|
LATEST_TAG="${REFSPEC}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "${REFSPEC}" == "master" ]]; then
|
|
|
|
LATEST_TAG="latest"
|
|
|
|
fi
|
|
|
|
|
|
|
|
cat<<EOF
|
|
|
|
Rolling with tags:
|
|
|
|
- ${REPO_NAME}:${SHA}
|
|
|
|
- ${REPO_NAME}:${REFSPEC}
|
|
|
|
- ${REPO_NAME}:${LATEST_TAG}
|
|
|
|
EOF
|
|
|
|
|
2023-09-25 16:08:21 -04:00
|
|
|
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}" \
|
|
|
|
.
|
|
|
|
|
2020-11-13 14:32:18 -05:00
|
|
|
#
|
|
|
|
# Build the "lean" image
|
|
|
|
#
|
2023-09-25 16:08:21 -04:00
|
|
|
docker buildx build --target lean \
|
|
|
|
$DOCKER_ARGS \
|
|
|
|
--cache-from=type=local,src=/tmp/superset \
|
|
|
|
--cache-to=type=local,ignore-error=true,dest=/tmp/superset \
|
2020-11-13 14:32:18 -05:00
|
|
|
-t "${REPO_NAME}:${SHA}" \
|
|
|
|
-t "${REPO_NAME}:${REFSPEC}" \
|
|
|
|
-t "${REPO_NAME}:${LATEST_TAG}" \
|
2023-09-25 16:08:21 -04:00
|
|
|
--platform linux/amd64 \
|
2020-11-13 14:32:18 -05:00
|
|
|
--label "sha=${SHA}" \
|
|
|
|
--label "built_at=$(date)" \
|
|
|
|
--label "target=lean" \
|
|
|
|
--label "build_actor=${GITHUB_ACTOR}" \
|
|
|
|
.
|
|
|
|
|
2023-01-23 13:29:41 -05:00
|
|
|
#
|
2023-05-10 13:21:56 -04:00
|
|
|
# Build the "lean310" image
|
2023-01-23 13:29:41 -05:00
|
|
|
#
|
2023-09-25 16:08:21 -04:00
|
|
|
docker buildx build --target lean \
|
|
|
|
$DOCKER_ARGS \
|
|
|
|
--cache-from=type=local,src=/tmp/superset \
|
|
|
|
--cache-to=type=local,ignore-error=true,dest=/tmp/superset \
|
2023-05-10 13:21:56 -04:00
|
|
|
-t "${REPO_NAME}:${SHA}-py310" \
|
|
|
|
-t "${REPO_NAME}:${REFSPEC}-py310" \
|
|
|
|
-t "${REPO_NAME}:${LATEST_TAG}-py310" \
|
2023-09-25 16:08:21 -04:00
|
|
|
--platform linux/amd64 \
|
2023-06-23 13:23:51 -04:00
|
|
|
--build-arg PY_VER="3.10-slim-bookworm"\
|
2023-01-23 13:29:41 -05:00
|
|
|
--label "sha=${SHA}" \
|
|
|
|
--label "built_at=$(date)" \
|
2023-05-10 13:21:56 -04:00
|
|
|
--label "target=lean310" \
|
2023-01-23 13:29:41 -05:00
|
|
|
--label "build_actor=${GITHUB_ACTOR}" \
|
|
|
|
.
|
2023-09-25 16:08:21 -04:00
|
|
|
for BUILD_PLATFORM in $ARCHITECTURE_FOR_BUILD; do
|
2022-11-04 12:10:06 -04:00
|
|
|
#
|
|
|
|
# Build the "websocket" image
|
|
|
|
#
|
2023-09-25 16:08:21 -04:00
|
|
|
docker buildx build \
|
|
|
|
$DOCKER_ARGS \
|
|
|
|
--cache-from=type=registry,ref=apache/superset:master-websocket \
|
2022-12-01 11:11:04 -05:00
|
|
|
-t "${REPO_NAME}:${SHA}-websocket" \
|
|
|
|
-t "${REPO_NAME}:${REFSPEC}-websocket" \
|
|
|
|
-t "${REPO_NAME}:${LATEST_TAG}-websocket" \
|
2023-09-25 16:08:21 -04:00
|
|
|
--platform ${BUILD_PLATFORM} \
|
2022-11-04 12:10:06 -04:00
|
|
|
--label "sha=${SHA}" \
|
|
|
|
--label "built_at=$(date)" \
|
2023-01-23 13:29:41 -05:00
|
|
|
--label "target=websocket" \
|
2022-11-04 12:10:06 -04:00
|
|
|
--label "build_actor=${GITHUB_ACTOR}" \
|
|
|
|
superset-websocket
|
|
|
|
|
2023-06-29 15:03:59 -04:00
|
|
|
#
|
|
|
|
# Build the dockerize image
|
|
|
|
#
|
2023-09-25 16:08:21 -04:00
|
|
|
docker buildx build \
|
|
|
|
$DOCKER_ARGS \
|
|
|
|
--cache-from=type=registry,ref=apache/superset:dockerize \
|
2023-06-29 15:03:59 -04:00
|
|
|
-t "${REPO_NAME}:dockerize" \
|
2023-09-25 16:08:21 -04:00
|
|
|
--platform ${BUILD_PLATFORM} \
|
2023-06-29 15:03:59 -04:00
|
|
|
--label "sha=${SHA}" \
|
|
|
|
--label "built_at=$(date)" \
|
|
|
|
--label "build_actor=${GITHUB_ACTOR}" \
|
|
|
|
-f dockerize.Dockerfile \
|
|
|
|
.
|
2023-09-25 16:08:21 -04:00
|
|
|
done
|