Skip to content

Commit 9a47f9b

Browse files
authored
Merge pull request #18125 from MinaProtocol/dkijania/unhardcode_gcr
[Europe GCR 1/3] un-hardcode gcr.io repo from various scripts
2 parents 7ca73d2 + 75fd9c9 commit 9a47f9b

File tree

13 files changed

+83
-24
lines changed

13 files changed

+83
-24
lines changed

buildkite/scripts/release/manager.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -510,11 +510,9 @@ function promote_and_verify_docker() {
510510
local __artifact_full_target_version=$__target_version-$__codename${__suffix}
511511

512512
if [[ $__publish_to_docker_io == 1 ]]; then
513-
local __publish_arg="-p"
514-
local __repo=$DOCKER_IO_REPO
513+
local __push_repo=$DOCKER_IO_REPO
515514
else
516-
local __publish_arg=""
517-
local __repo=$GCR_REPO
515+
local __push_repo=$GCR_REPO
518516
fi
519517

520518
echo " 🐋 Publishing $__artifact docker for '$__network' network and '$__codename' codename with '$__target_version' version and '$__arch' "
@@ -527,7 +525,8 @@ function promote_and_verify_docker() {
527525
-v $__artifact_full_source_version \
528526
-t $__artifact_full_target_version \
529527
-a $__arch \
530-
$__publish_arg
528+
--pull-registry "$GCR_REPO" \
529+
--push-registry "$__push_repo" \
531530

532531
echo ""
533532

@@ -1013,6 +1012,7 @@ function promote(){
10131012
local __debian_repo=$DEBIAN_REPO
10141013
local __debian_sign_key=""
10151014
local __arch="$DEFAULT_ARCHITECTURES"
1015+
local __profile=$DEFAULT_PROFILE
10161016

10171017

10181018
while [ ${#} -gt 0 ]; do
@@ -1085,6 +1085,10 @@ function promote(){
10851085
__arch=${2:?$error_message}
10861086
shift 2;
10871087
;;
1088+
--profile )
1089+
__profile=${2:?$error_message}
1090+
shift 2;
1091+
;;
10881092
* )
10891093
echo -e "${RED} !! Unknown option: $1${CLEAR}\n";
10901094
echo "";

buildkite/scripts/run-test-executive-local.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,13 @@ fi
2525
cleanup
2626

2727
TEST_NAME="$1"
28+
DOCKER_REPO="$2"
29+
MINA_DOCKER_NAME="mina-daemon"
30+
MINA_ARCHIVE_DOCKER_NAME="mina-archive"
2831

29-
MINA_IMAGE="gcr.io/o1labs-192920/mina-daemon:$MINA_DOCKER_TAG-berkeley"
30-
ARCHIVE_IMAGE="gcr.io/o1labs-192920/mina-archive:$MINA_DOCKER_TAG-berkeley"
32+
33+
MINA_IMAGE="$DOCKER_REPO/$MINA_DOCKER_NAME:$MINA_DOCKER_TAG-berkeley"
34+
ARCHIVE_IMAGE="$DOCKER_REPO/$MINA_ARCHIVE_DOCKER_NAME:$MINA_DOCKER_TAG-berkeley"
3135

3236
if [[ "${TEST_NAME:0:15}" == "block-prod-prio" ]] && [[ "$RUN_OPT_TESTS" == "" ]]; then
3337
echo "Skipping $TEST_NAME"

buildkite/src/Command/DockerImage.dhall

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ let DockerLogin = ../Command/DockerLogin/Type.dhall
2020

2121
let DebianRepo = ../Constants/DebianRepo.dhall
2222

23+
let DockerRepo = ../Constants/DockerRepo.dhall
24+
2325
let DebianVersions = ../Constants/DebianVersions.dhall
2426

2527
let Network = ../Constants/Network.dhall
@@ -51,6 +53,7 @@ let ReleaseSpec =
5153
, build_flags : BuildFlags.Type
5254
, step_key_suffix : Text
5355
, docker_publish : DockerPublish.Type
56+
, docker_repo : DockerRepo.Type
5457
, verify : Bool
5558
, if_ : Optional B/If
5659
}
@@ -72,6 +75,7 @@ let ReleaseSpec =
7275
, docker_publish = DockerPublish.Type.Essential
7376
, no_cache = False
7477
, no_debian = False
78+
, docker_repo = DockerRepo.Type.Internal
7579
, step_key_suffix = "-docker-image"
7680
, verify = False
7781
, deb_suffix = None Text
@@ -166,6 +170,7 @@ let generateStep =
166170
++ debSuffix
167171
++ " --repo ${spec.repo}"
168172
++ " --platform ${Arch.platform spec.arch}"
173+
++ " --docker-registry ${DockerRepo.show spec.docker_repo}"
169174

170175
let releaseDockerCmd =
171176
if DockerPublish.shouldPublish
@@ -184,6 +189,8 @@ let generateStep =
184189
++ " --deb-build-flags ${BuildFlags.lowerName
185190
spec.build_flags}"
186191
++ " --platform ${Arch.platform spec.arch}"
192+
++ " --docker-registry ${DockerRepo.show
193+
spec.docker_repo}"
187194

188195
else " echo In order to ensure storage optimization, skipping publishing docker as this is not essential one or publishing is disabled . Docker publish setting is set to ${DockerPublish.show
189196
spec.docker_publish}."

buildkite/src/Command/Packages/Publish.dhall

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ let DebianVersions = ../../Constants/DebianVersions.dhall
2626

2727
let DebianRepo = ../../Constants/DebianRepo.dhall
2828

29+
let DockerRepo = ../../Constants/DockerRepo.dhall
30+
2931
let ContainerImages = ../../Constants/ContainerImages.dhall
3032

3133
let Command = ../Base.dhall
@@ -72,6 +74,7 @@ let Spec =
7274
, depends_on : List Command.TaggedKey.Type
7375
, branch : Text
7476
, architectures : List Architecture.Type
77+
, docker_repo : DockerRepo.Type
7578
, if_ : Optional Text
7679
}
7780
, default =
@@ -89,6 +92,7 @@ let Spec =
8992
, verify = True
9093
, branch = ""
9194
, architectures = [ Architecture.Type.Amd64, Architecture.Type.Arm64 ]
95+
, docker_repo = DockerRepo.Type.Internal
9296
, if_ = None Text
9397
}
9498
}
@@ -251,6 +255,8 @@ let publish
251255
++ "--target-version ${r.value} "
252256
++ "--codenames ${codenames} "
253257
++ "--only-dockers "
258+
++ "--docker-repo ${DockerRepo.show
259+
spec.docker_repo} "
254260
++ "--force-upload-debians "
255261
)
256262
]

buildkite/src/Command/Rosetta/Connectivity.dhall

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ let Dockers = ../../Constants/DockerVersions.dhall
2424

2525
let Profiles = ../../Constants/Profiles.dhall
2626

27+
let DockerRepo = ../../Constants/DockerRepo.dhall
28+
2729
let B/SoftFail = B.definitions/commandStep/properties/soft_fail/Type
2830

2931
let B/If = B.definitions/commandStep/properties/if/Type
@@ -37,6 +39,7 @@ let Spec =
3739
, timeout : Natural
3840
, profile : Profiles.Type
3941
, scope : List PipelineScope.Type
42+
, repo : DockerRepo.Type
4043
, if_ : B/If
4144
}
4245
, default =
@@ -47,6 +50,7 @@ let Spec =
4750
, timeout = 1000
4851
, profile = Profiles.Type.Devnet
4952
, scope = PipelineScope.Full
53+
, repo = DockerRepo.Type.Internal
5054
, if_ =
5155
"build.pull_request.base_branch != \"develop\" && build.branch != \"develop\""
5256
}
@@ -64,7 +68,8 @@ let command
6468
, "source ./buildkite/scripts/export-git-env-vars.sh"
6569
, "scripts/tests/rosetta-connectivity.sh --network ${Network.lowerName
6670
spec.network} --tag \\\${MINA_DOCKER_TAG} --timeout ${Natural/show
67-
spec.timeout} --run-compatibility-test develop --run-load-test "
71+
spec.timeout} --repo ${DockerRepo.show
72+
spec.repo} --run-compatibility-test develop --run-load-test "
6873
]
6974
]
7075
, label =

buildkite/src/Command/TestExecutive.dhall

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ let Size = ./Size.dhall
44

55
let Cmd = ../Lib/Cmds.dhall
66

7+
let DockerRepo = ../Constants/DockerRepo.dhall
8+
79
let SelectFiles = ../Lib/SelectFiles.dhall
810

911
in { executeLocal =
@@ -13,7 +15,8 @@ in { executeLocal =
1315
Command.Config::{
1416
, commands =
1517
[ Cmd.run
16-
"MINA_DEB_CODENAME=bullseye ; source ./buildkite/scripts/export-git-env-vars.sh && ./buildkite/scripts/run-test-executive-local.sh ${testName}"
18+
"MINA_DEB_CODENAME=bullseye ; source ./buildkite/scripts/export-git-env-vars.sh && ./buildkite/scripts/run-test-executive-local.sh ${testName} ${DockerRepo.show
19+
DockerRepo.Type.Internal}"
1720
]
1821
, artifact_paths =
1922
[ SelectFiles.exactly "." "${testName}.local.test.log" ]

dockerfiles/Dockerfile-mina-daemon-hardfork

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
ARG deb_version=latest
22
ARG deb_codename=bullseye
33
ARG network=mainnet
4-
ARG docker_repo="gcr.io/o1labs-192920"
4+
ARG docker_repo
55
ARG deb_release=unstable
66
ARG deb_legacy_version
77
ARG deb_repo="http://packages.o1test.net"

scripts/docker/build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ while [[ "$#" -gt 0 ]]; do case $1 in
4747
-c|--cache-from) INPUT_CACHE="$2"; shift;;
4848
-r|--repo) MINA_REPO="$2"; shift;;
4949
-p|--platform) INPUT_PLATFORM="$2"; shift;;
50+
--docker-registry) export DOCKER_REGISTRY="$2"; shift;;
5051
--no-cache) NO_CACHE="--no-cache"; ;;
5152
--deb-codename) INPUT_CODENAME="$2"; shift;;
5253
--deb-release) INPUT_RELEASE="$2"; shift;;

scripts/docker/helper.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,18 @@ function get_platform_suffix() {
8989
esac
9090
}
9191

92+
function check_docker_registry() {
93+
if [[ -z "${DOCKER_REGISTRY:-}" ]]; then
94+
echo "ERROR: DOCKER_REGISTRY environment variable is not set" >&2
95+
exit 1
96+
fi
97+
}
9298

9399
function export_docker_tag() {
94100
export_suffixes
95-
96-
export DOCKER_REGISTRY="gcr.io/o1labs-192920"
101+
102+
check_docker_registry
103+
export DOCKER_REGISTRY="${DOCKER_REGISTRY}"
97104

98105
PLATFORM_SUFFIX="$(get_platform_suffix)"
99106
export TAG="${DOCKER_REGISTRY}/${SERVICE}:${VERSION}${BUILD_FLAG_SUFFIX}${PLATFORM_SUFFIX}"

scripts/docker/promote.sh

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,14 @@ set -eo pipefail
44

55
CLEAR='\033[0m'
66
RED='\033[0;31m'
7-
PUBLISH=0
8-
GCR_REPO=gcr.io/o1labs-192920
97
QUIET=""
108
ARCH=amd64
119
while [[ "$#" -gt 0 ]]; do case $1 in
1210
-n|--name) NAME="$2"; shift;;
1311
-v|--version) VERSION="$2"; shift;;
1412
-t|--tag) TAG="$2"; shift;;
15-
-p|--publish) PUBLISH=1; ;;
13+
--pull-registry) PULL_REGISTRY="$2"; shift;;
14+
--push-registry) PUSH_REGISTRY="$2"; shift;;
1615
-q|--quiet) QUIET="-q"; ;;
1716
-a|--arch) ARCH="$2"; shift;;
1817
*) echo "Unknown parameter passed: $1"; exit 1;;
@@ -26,7 +25,8 @@ function usage() {
2625
echo " -n, --name The Docker name (mina-devnet, mina-archive etc.)"
2726
echo " -v, --version The Docker version"
2827
echo " -t, --tag The Additional tag"
29-
echo " -p, --publish The Publish to docker.io flag. If defined script will publish docker do docker.io. Otherwise it will still resides in gcr.io"
28+
echo " --pull-registry The Docker pull registry (e.g. gcr.io/o1labs-192920)"
29+
echo " --push-registry The Docker push registry (e.g. gcr.io/o1labs-192920)"
3030
echo " -q, --quiet The Quiet mode. If defined script will output limited logs"
3131
echo " -a, --arch The Architecture of docker (amd64, arm64)"
3232
echo ""
@@ -37,6 +37,7 @@ function usage() {
3737
if [[ -z "$NAME" ]]; then usage "Name is not set!"; fi;
3838
if [[ -z "$VERSION" ]]; then usage "Version is not set!"; fi;
3939
if [[ -z "$TAG" ]]; then usage "Tag is not set!"; fi;
40+
if [[ -z "$PULL_REGISTRY" ]]; then usage "Pull registry is not set!"; fi;
4041

4142
# Sanitize the tag to ensure it is compliant with Docker tag format
4243
TAG=$(echo "$TAG" | sed 's/[^a-zA-Z0-9_.-]/-/g')
@@ -47,19 +48,17 @@ case $ARCH in
4748
*) echo "❌ Unknown architecture passed: $ARCH"; exit 1 ;;
4849
esac
4950

50-
SOURCE_TAG="${GCR_REPO}/${NAME}:${VERSION}${DOCKER_ARCH_SUFFIX}"
51+
SOURCE_TAG="${PULL_REGISTRY}/${NAME}:${VERSION}${DOCKER_ARCH_SUFFIX}"
5152

5253
echo "📎 Adding new tag ($TAG) for docker ${SOURCE_TAG}"
5354
echo " 📥 pulling ${SOURCE_TAG}"
5455
docker pull $QUIET ${SOURCE_TAG}
5556

56-
if [[ $PUBLISH == 1 ]]; then
57-
TARGET_REPO=docker.io/minaprotocol
58-
else
59-
TARGET_REPO=$GCR_REPO
57+
if [[ -z "$PUSH_REGISTRY" ]]; then
58+
PUSH_REGISTRY=$PULL_REGISTRY
6059
fi
6160

62-
TARGET_TAG="${TARGET_REPO}/${NAME}:${TAG}${DOCKER_ARCH_SUFFIX}"
61+
TARGET_TAG="${PUSH_REGISTRY}/${NAME}:${TAG}${DOCKER_ARCH_SUFFIX}"
6362

6463
docker tag "${SOURCE_TAG}" "${TARGET_TAG}"
6564
echo " 📤 pushing ${TARGET_TAG}"

0 commit comments

Comments
 (0)