Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Release/2.0.x pinned contracts registry image #11007

Closed
wants to merge 5 commits into from
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
50 changes: 39 additions & 11 deletions .cicd/docker-tag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ SANITIZED_BRANCH="$(sanitize "$BUILDKITE_BRANCH")"
echo "Branch '$BUILDKITE_BRANCH' sanitized as '$SANITIZED_BRANCH'."
SANITIZED_TAG="$(sanitize "$BUILDKITE_TAG")"
[[ -z "$SANITIZED_TAG" ]] || echo "Branch '$BUILDKITE_TAG' sanitized as '$SANITIZED_TAG'."
echo '$ echo ${#CONTRACT_REGISTRIES[*]} # array length'
echo ${#CONTRACT_REGISTRIES[*]}
echo '$ echo ${CONTRACT_REGISTRIES[*]} # array'
echo ${CONTRACT_REGISTRIES[*]}
echo '$ echo ${#CONTRACT_REGISTRIES[@]} # array length'
echo ${#CONTRACT_REGISTRIES[@]}
echo '$ echo ${CONTRACT_REGISTRIES[@]} # array'
echo ${CONTRACT_REGISTRIES[@]}
export IMAGE="${MIRROR_REGISTRY:-$DOCKERHUB_CI_REGISTRY}:$PREFIX-$BUILDKITE_COMMIT-$PLATFORM_TYPE"
# pull
echo '+++ :arrow_down: Pulling Container(s)'
Expand All @@ -19,37 +19,57 @@ echo "$ $DOCKER_PULL_COMMAND"
eval $DOCKER_PULL_COMMAND
# tag
echo '+++ :label: Tagging Container(s)'
for REGISTRY in ${CONTRACT_REGISTRIES[*]}; do
for REGISTRY in ${CONTRACT_REGISTRIES[@]}; do
if [[ ! -z "$REGISTRY" ]]; then
echo "Tagging for registry $REGISTRY."
DOCKER_TAG_COMMAND="docker tag '$IMAGE' '$REGISTRY:$PREFIX-$SANITIZED_BRANCH'"
if [[ "$PLATFORM_TYPE" == 'unpinned' ]] ; then
DOCKER_TAG_COMMAND="docker tag '$IMAGE' '$REGISTRY:$PREFIX-$SANITIZED_BRANCH'"
echo "$ $DOCKER_TAG_COMMAND"
eval $DOCKER_TAG_COMMAND
if [[ ! -z "$SANITIZED_TAG" && "$SANITIZED_BRANCH" != "$SANITIZED_TAG" ]]; then
DOCKER_TAG_COMMAND="docker tag '$IMAGE' '$REGISTRY:$PREFIX-$SANITIZED_TAG'"
echo "$ $DOCKER_TAG_COMMAND"
eval $DOCKER_TAG_COMMAND
fi
fi
DOCKER_TAG_COMMAND="docker tag '$IMAGE' '$REGISTRY:$PREFIX-$SANITIZED_BRANCH-$PLATFORM_TYPE'"
echo "$ $DOCKER_TAG_COMMAND"
eval $DOCKER_TAG_COMMAND
if [[ ! -z "$SANITIZED_TAG" && "$SANITIZED_BRANCH" != "$SANITIZED_TAG" ]]; then
DOCKER_TAG_COMMAND="docker tag '$IMAGE' '$REGISTRY:$PREFIX-$SANITIZED_TAG'"
DOCKER_TAG_COMMAND="docker tag '$IMAGE' '$REGISTRY:$PREFIX-$SANITIZED_TAG-$PLATFORM_TYPE'"
echo "$ $DOCKER_TAG_COMMAND"
eval $DOCKER_TAG_COMMAND
fi
fi
done
# push
echo '+++ :arrow_up: Pushing Container(s)'
for REGISTRY in ${CONTRACT_REGISTRIES[*]}; do
for REGISTRY in ${CONTRACT_REGISTRIES[@]}; do
if [[ ! -z "$REGISTRY" ]]; then
echo "Pushing to '$REGISTRY'."
DOCKER_PUSH_COMMAND="docker push '$REGISTRY:$PREFIX-$SANITIZED_BRANCH'"
if [[ "$PLATFORM_TYPE" == 'unpinned' ]] ; then
DOCKER_PUSH_COMMAND="docker push '$REGISTRY:$PREFIX-$SANITIZED_BRANCH'"
echo "$ $DOCKER_PUSH_COMMAND"
eval $DOCKER_PUSH_COMMAND
if [[ ! -z "$SANITIZED_TAG" && "$SANITIZED_BRANCH" != "$SANITIZED_TAG" ]]; then
DOCKER_PUSH_COMMAND="docker push '$REGISTRY:$PREFIX-$SANITIZED_TAG'"
echo "$ $DOCKER_PUSH_COMMAND"
eval $DOCKER_PUSH_COMMAND
fi
fi
DOCKER_PUSH_COMMAND="docker push '$REGISTRY:$PREFIX-$SANITIZED_BRANCH-$PLATFORM_TYPE'"
echo "$ $DOCKER_PUSH_COMMAND"
eval $DOCKER_PUSH_COMMAND
if [[ ! -z "$SANITIZED_TAG" && "$SANITIZED_BRANCH" != "$SANITIZED_TAG" ]]; then
DOCKER_PUSH_COMMAND="docker push '$REGISTRY:$PREFIX-$SANITIZED_TAG'"
DOCKER_PUSH_COMMAND="docker push '$REGISTRY:$PREFIX-$SANITIZED_TAG-$PLATFORM_TYPE'"
echo "$ $DOCKER_PUSH_COMMAND"
eval $DOCKER_PUSH_COMMAND
fi
fi
done
# cleanup
echo '--- :put_litter_in_its_place: Cleaning Up'
for REGISTRY in ${CONTRACT_REGISTRIES[*]}; do
for REGISTRY in ${CONTRACT_REGISTRIES[@]}; do
if [[ ! -z "$REGISTRY" ]]; then
echo "Cleaning up from $REGISTRY."
DOCKER_RMI_COMMAND="docker rmi '$REGISTRY:$PREFIX-$SANITIZED_BRANCH' || :"
Expand All @@ -63,8 +83,16 @@ for REGISTRY in ${CONTRACT_REGISTRIES[*]}; do
echo "$ $DOCKER_RMI_COMMAND"
eval $DOCKER_RMI_COMMAND
fi
DOCKER_RMI_COMMAND="docker rmi '$REGISTRY:$PREFIX-$SANITIZED_BRANCH-$PLATFORM_TYPE' || :"
echo "$ $DOCKER_RMI_COMMAND"
eval $DOCKER_RMI_COMMAND
DOCKER_RMI_COMMAND="docker rmi '$REGISTRY:$PREFIX-$BUILDKITE_COMMIT-$PLATFORM_TYPE' || :"
echo "$ $DOCKER_RMI_COMMAND"
eval $DOCKER_RMI_COMMAND
if [[ ! -z "$SANITIZED_TAG" && "$SANITIZED_BRANCH" != "$SANITIZED_TAG" ]]; then
DOCKER_RMI_COMMAND="docker rmi '$REGISTRY:$PREFIX-$SANITIZED_TAG-$PLATFORM_TYPE' || :"
echo "$ $DOCKER_RMI_COMMAND"
eval $DOCKER_RMI_COMMAND
fi
fi
done
9 changes: 4 additions & 5 deletions .cicd/generate-pipeline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ for FILE in $(ls "$CICD_DIR/platforms/$PLATFORM_TYPE"); do
( [[ $SKIP_LINUX == true ]] && [[ ! $FILE =~ 'macos' ]] ) && continue
# use pinned or unpinned, not both sets of platform files
if [[ $PINNED == false ]]; then
export SKIP_CONTRACT_BUILDER=${SKIP_CONTRACT_BUILDER:-true}
export SKIP_PACKAGE_BUILDER=${SKIP_PACKAGE_BUILDER:-true}
fi
export FILE_NAME="$(echo "$FILE" | awk '{split($0,a,/\.(d|s)/); print a[1] }')"
Expand Down Expand Up @@ -189,8 +188,8 @@ done
- label: ":docker: Docker - Build and Install"
command: "./.cicd/installation-build.sh"
env:
IMAGE_TAG: "ubuntu-18.04-unpinned"
PLATFORM_TYPE: "unpinned"
IMAGE_TAG: "ubuntu-18.04-$PLATFORM_TYPE"
PLATFORM_TYPE: $PLATFORM_TYPE
agents:
queue: "$BUILDKITE_BUILD_AGENT_QUEUE"
timeout: ${TIMEOUT:-180}
Expand Down Expand Up @@ -702,8 +701,8 @@ EOF
- label: ":docker: Docker - Label Container with Git Branch and Git Tag"
command: .cicd/docker-tag.sh
env:
IMAGE_TAG: "ubuntu-18.04-unpinned"
PLATFORM_TYPE: "unpinned"
IMAGE_TAG: "ubuntu-18.04-$PLATFORM_TYPE"
PLATFORM_TYPE: $PLATFORM_TYPE
agents:
queue: "$BUILDKITE_BUILD_AGENT_QUEUE"
timeout: ${TIMEOUT:-10}
Expand Down
6 changes: 5 additions & 1 deletion .cicd/installation-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ eval $BUILD_COMMAND
echo '+++ :arrow_up: Pushing Container'
for REGISTRY in "${CONTRACT_REGISTRIES[@]}"; do
if [[ ! -z "$REGISTRY" ]]; then
COMMITS=("$REGISTRY:base-ubuntu-18.04-$BUILDKITE_COMMIT" "$REGISTRY:base-ubuntu-18.04-$BUILDKITE_COMMIT-$PLATFORM_TYPE" "$REGISTRY:base-ubuntu-18.04-$SANITIZED_BRANCH-$BUILDKITE_COMMIT")
COMMITS=("$REGISTRY:base-ubuntu-18.04-$BUILDKITE_COMMIT-$PLATFORM_TYPE")
# Platform agnostic elements should be unpinned
if [[ "$PLATFORM_TYPE" == 'unpinned' ]] ; then
COMMITS=(${COMMITS[@]} "$REGISTRY:base-ubuntu-18.04-$BUILDKITE_COMMIT" "$REGISTRY:base-ubuntu-18.04-$SANITIZED_BRANCH-$BUILDKITE_COMMIT")
fi
for COMMIT in "${COMMITS[@]}"; do
COMMIT_COMMAND="docker commit 'ci-contracts-builder-$BUILDKITE_PIPELINE_SLUG-$BUILDKITE_BUILD_NUMBER' '$COMMIT'"
echo "$ $COMMIT_COMMAND"
Expand Down