Break gateway build cycle with runtime base bootstrap
Some checks failed
Build and Deploy Gateway / build-and-deploy (push) Has been cancelled
Some checks failed
Build and Deploy Gateway / build-and-deploy (push) Has been cancelled
This commit is contained in:
@@ -23,6 +23,18 @@ echo "Image: ${GATEWAY_IMAGE}"
|
||||
echo "Base image: ${BASE_IMAGE}"
|
||||
echo "Runtime base source: ${RUNTIME_BASE_SOURCE_IMAGE}"
|
||||
|
||||
ensure_known_host() {
|
||||
local host="$1"
|
||||
if [ "${host}" = "local" ]; then return 0; fi
|
||||
local scan_host="${host#*@}"
|
||||
scan_host="${scan_host%%:*}"
|
||||
mkdir -p "${HOME}/.ssh"
|
||||
chmod 700 "${HOME}/.ssh"
|
||||
if ! ssh-keygen -F "${scan_host}" >/dev/null 2>&1; then
|
||||
ssh-keyscan -H "${scan_host}" >> "${HOME}/.ssh/known_hosts"
|
||||
fi
|
||||
}
|
||||
|
||||
echo "Syncing source to ${BUILD_HOST}:${BUILD_PATH}"
|
||||
if [ "${BUILD_HOST}" = "local" ]; then
|
||||
BUILD_PATH="$(pwd)"
|
||||
@@ -49,10 +61,12 @@ echo "Loading image into ${DEPLOY_HOST}"
|
||||
if [ "${BUILD_HOST}" = "local" ] && [ "${DEPLOY_HOST}" = "local" ]; then
|
||||
docker image inspect "${GATEWAY_IMAGE}" >/dev/null
|
||||
elif [ "${BUILD_HOST}" = "local" ]; then
|
||||
ensure_known_host "${DEPLOY_HOST}"
|
||||
docker save "${GATEWAY_IMAGE}" | ssh "${DEPLOY_HOST}" "docker load"
|
||||
elif [ "${DEPLOY_HOST}" = "local" ]; then
|
||||
ssh "${BUILD_HOST}" "docker save '${GATEWAY_IMAGE}'" | docker load
|
||||
else
|
||||
ensure_known_host "${DEPLOY_HOST}"
|
||||
ssh "${BUILD_HOST}" "docker save '${GATEWAY_IMAGE}'" | ssh "${DEPLOY_HOST}" "docker load"
|
||||
fi
|
||||
|
||||
@@ -61,6 +75,7 @@ if [ "${DEPLOY_HOST}" = "local" ]; then
|
||||
mkdir -p "${DEPLOY_PATH}"
|
||||
cp scripts/deploy-gateway.sh "${DEPLOY_PATH}/deploy-gateway.sh"
|
||||
else
|
||||
ensure_known_host "${DEPLOY_HOST}"
|
||||
ssh "${DEPLOY_HOST}" "mkdir -p '${DEPLOY_PATH}'"
|
||||
rsync -az scripts/deploy-gateway.sh "${DEPLOY_HOST}:${DEPLOY_PATH}/deploy-gateway.sh"
|
||||
fi
|
||||
@@ -71,6 +86,7 @@ if [ "${DEPLOY_HOST}" = "local" ]; then
|
||||
chmod +x ./deploy-gateway.sh
|
||||
DEPLOY_PATH="${DEPLOY_PATH}" GATEWAY_IMAGE="${GATEWAY_IMAGE}" PULL_IMAGE=false ./deploy-gateway.sh
|
||||
else
|
||||
ensure_known_host "${DEPLOY_HOST}"
|
||||
ssh "${DEPLOY_HOST}" \
|
||||
"cd '${DEPLOY_PATH}' && chmod +x ./deploy-gateway.sh && DEPLOY_PATH='${DEPLOY_PATH}' GATEWAY_IMAGE='${GATEWAY_IMAGE}' PULL_IMAGE=false ./deploy-gateway.sh"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user