diff --git a/common/cowrypay_image.sh b/common/cowrypay_image.sh new file mode 100644 index 00000000..26e5f344 --- /dev/null +++ b/common/cowrypay_image.sh @@ -0,0 +1,114 @@ +#!/bin/bash + +DOCKER_REGISTRY=${DOCKER_REGISTRY:-cowrypay} +source $(dirname "${BASH_SOURCE}")/lib.sh + +# override this one if you need to change push & pull +docker_push() { + hub_canary +} + +docker_pull() { + hub_pull +} + + +source_repo() { + RETVAL=0 + + if [ $# -eq 0 ]; then + cmd=${DEFAULT_COMMAND:-build} + $cmd + exit $RETVAL + fi + + case "$1" in + build) + build + ;; + build_binary) + build_binary + ;; + build_docker) + build_docker + ;; + clean) + clean + ;; + push) + docker_push + ;; + pull) + docker_pull + ;; + release) + docker_release + ;; + check) + docker_check + ;; + run) + docker_run + ;; + sh) + docker_sh + ;; + rm) + docker_rm + ;; + rmi) + docker_rmi + ;; + *) (10) + echo $"Usage: $0 {build|build_binary|build_docker|clean|push|pull|release|check|sh|rm|rmi}" + RETVAL=1 + esac + exit $RETVAL +} + +binary_repo() { + RETVAL=0 + + if [ $# -eq 0 ]; then + cmd=${DEFAULT_COMMAND:-build} + $cmd + exit $RETVAL + fi + + case "$1" in + build) + build + ;; + clean) + clean + ;; + push) + docker_push + ;; + pull) + docker_pull + ;; + release) + docker_release + ;; + check) + docker_check + ;; + run) + docker_run + ;; + sh) + docker_sh + ;; + rm) + docker_rm + ;; + rmi) + docker_rmi + ;; + *) (10) + echo $"Usage: $0 {build|clean|push|pull|release|check|sh|rm|rmi}" + RETVAL=1 + esac + exit $RETVAL +} diff --git a/common/k8sdb_image.sh b/common/k8sdb_image.sh new file mode 100644 index 00000000..0b1a6015 --- /dev/null +++ b/common/k8sdb_image.sh @@ -0,0 +1,114 @@ +#!/bin/bash + +DOCKER_REGISTRY=${DOCKER_REGISTRY:-k8sdb} +source $(dirname "${BASH_SOURCE}")/lib.sh + +# override this one if you need to change push & pull +docker_push() { + hub_canary +} + +docker_pull() { + hub_pull +} + + +source_repo() { + RETVAL=0 + + if [ $# -eq 0 ]; then + cmd=${DEFAULT_COMMAND:-build} + $cmd + exit $RETVAL + fi + + case "$1" in + build) + build + ;; + build_binary) + build_binary + ;; + build_docker) + build_docker + ;; + clean) + clean + ;; + push) + docker_push + ;; + pull) + docker_pull + ;; + release) + docker_release + ;; + check) + docker_check + ;; + run) + docker_run + ;; + sh) + docker_sh + ;; + rm) + docker_rm + ;; + rmi) + docker_rmi + ;; + *) (10) + echo $"Usage: $0 {build|build_binary|build_docker|clean|push|pull|release|check|sh|rm|rmi}" + RETVAL=1 + esac + exit $RETVAL +} + +binary_repo() { + RETVAL=0 + + if [ $# -eq 0 ]; then + cmd=${DEFAULT_COMMAND:-build} + $cmd + exit $RETVAL + fi + + case "$1" in + build) + build + ;; + clean) + clean + ;; + push) + docker_push + ;; + pull) + docker_pull + ;; + release) + docker_release + ;; + check) + docker_check + ;; + run) + docker_run + ;; + sh) + docker_sh + ;; + rm) + docker_rm + ;; + rmi) + docker_rmi + ;; + *) (10) + echo $"Usage: $0 {build|clean|push|pull|release|check|sh|rm|rmi}" + RETVAL=1 + esac + exit $RETVAL +} diff --git a/common/lib.sh b/common/lib.sh index 1750c26f..8b3c9083 100644 --- a/common/lib.sh +++ b/common/lib.sh @@ -102,49 +102,57 @@ EOL } build() { - local cmd="docker build -t appscode/$IMG:$TAG ." + local cmd="docker build -t $DOCKER_REGISTRY/$IMG:$TAG ." echo $cmd; $cmd } -docker_up() { - local cmd="docker tag appscode/$1 gcr.io/$GCR_PROJECT/$1" +attic_up() { + local cmd="docker tag $DOCKER_REGISTRY/$IMG:$TAG gcr.io/$GCR_PROJECT/$IMG:$TAG" echo $cmd; $cmd - cmd="gcloud docker -- push gcr.io/$GCR_PROJECT/$1" + cmd="gcloud docker -- push gcr.io/$GCR_PROJECT/$IMG:$TAG" echo $cmd; $cmd - local cmd="docker tag appscode/$1 docker.appscode.com/$1" + local cmd="docker tag $DOCKER_REGISTRY/$IMG:$TAG docker.appscode.com/$IMG:$TAG" echo $cmd; $cmd - cmd="docker push docker.appscode.com/$1" + cmd="docker push docker.appscode.com/$IMG:$TAG" echo $cmd; $cmd } -# override this one if you need to change push -docker_push() { - docker_up $IMG:$TAG +hub_up() { + local cmd="docker push $DOCKER_REGISTRY/$IMG:$TAG" + echo $cmd; $cmd } -docker_pull() { +hub_canary() { + hub_up + + local cmd="docker tag $DOCKER_REGISTRY/$IMG:$TAG $DOCKER_REGISTRY/$IMG:canary" + echo $cmd; $cmd + cmd="docker push $DOCKER_REGISTRY/$IMG:canary" + echo $cmd; $cmd +} + +attic_pull() { local cmd="docker pull docker.appscode.com/$IMG:$TAG" echo $cmd; $cmd - cmd="docker tag docker.appscode.com/$IMG:$TAG appscode/$IMG:$TAG" + cmd="docker tag docker.appscode.com/$IMG:$TAG $DOCKER_REGISTRY/$IMG:$TAG" echo $cmd; $cmd } -docker_gcr() { +gcr_pull() { local cmd="gcloud docker -- pull gcr.io/$GCR_PROJECT/$IMG:$TAG" echo $cmd; $cmd - cmd="docker tag gcr.io/$GCR_PROJECT/$IMG:$TAG appscode/$IMG:$TAG" + cmd="docker tag gcr.io/$GCR_PROJECT/$IMG:$TAG $DOCKER_REGISTRY/$IMG:$TAG" echo $cmd; $cmd } docker_release() { - local cmd="docker push appscode/$IMG:$TAG" - echo $cmd; $cmd + hub_up } docker_check() { name=$IMG-$(date +%s | sha256sum | base64 | head -c 8 ; echo) - local cmd="docker run -d -P -it --name=$name appscode/$IMG:$TAG" + local cmd="docker run -d -P -it --name=$name $DOCKER_REGISTRY/$IMG:$TAG" echo $cmd; $cmd cmd="docker exec -it $name ps aux" echo $cmd; $cmd @@ -168,7 +176,7 @@ docker_run() { docker_cmd="${DOCKER_CMD:-}" echo pv > .gitignore mkdir -p pv - local cmd="docker run -d -P -it $privileged $net $extra_opts --name=$name appscode/$img:$TAG $docker_cmd" + local cmd="docker run -d -P -it $privileged $net $extra_opts --name=$name $DOCKER_REGISTRY/$img:$TAG $docker_cmd" echo $cmd; $cmd } @@ -181,7 +189,7 @@ docker_sh() { privileged="${PRIVILEGED_CONTAINER:-}" net="${DOCKER_NETWORK:-}" extra_opts="${EXTRA_DOCKER_OPTS:-}" - local cmd="docker run -d -P -it $privileged $net $extra_opts --name=$name appscode/$img:$TAG" + local cmd="docker run -d -P -it $privileged $net $extra_opts --name=$name $DOCKER_REGISTRY/$img:$TAG" echo $cmd; $cmd cmd="docker exec -it $name bash" echo $cmd; $cmd diff --git a/common/private_image.sh b/common/private_image.sh index 610de7ce..1c8d967c 100644 --- a/common/private_image.sh +++ b/common/private_image.sh @@ -1,5 +1,18 @@ #!/bin/bash +DOCKER_REGISTRY=${DOCKER_REGISTRY:-appscode} +source $(dirname "${BASH_SOURCE}")/lib.sh + +# override this one if you need to change push & pull +docker_push() { + attic_up +} + +docker_pull() { + attic_pull +} + + source_repo() { RETVAL=0 @@ -32,7 +45,7 @@ source_repo() { docker_pull ;; gcr) - docker_gcr + gcr_pull ;; check) docker_check @@ -79,7 +92,7 @@ binary_repo() { docker_pull ;; gcr) - docker_gcr + gcr_pull ;; check) docker_check diff --git a/common/public_image.sh b/common/public_image.sh index 8c5a687e..85371e6a 100644 --- a/common/public_image.sh +++ b/common/public_image.sh @@ -1,5 +1,18 @@ #!/bin/bash +DOCKER_REGISTRY=${DOCKER_REGISTRY:-appscode} +source $(dirname "${BASH_SOURCE}")/lib.sh + +# override this one if you need to change push & pull +docker_push() { + attic_up +} + +docker_pull() { + attic_pull +} + + source_repo() { RETVAL=0 @@ -29,7 +42,7 @@ source_repo() { docker_pull ;; gcr) - docker_gcr + gcr_pull ;; release) docker_release @@ -79,7 +92,7 @@ binary_repo() { docker_pull ;; gcr) - docker_gcr + gcr_pull ;; release) docker_release diff --git a/libbuild.py b/libbuild.py index b77696a9..5ea275fb 100644 --- a/libbuild.py +++ b/libbuild.py @@ -196,12 +196,11 @@ def upload_to_cloud(folder, f, version): if not isinstance(buckets, dict): buckets = {buckets: ''} for bucket, region in buckets.items(): - dst = "{bucket}/binaries/{name}/{version}/{file}{ext}".format( + dst = "{bucket}/binaries/{name}/{version}/{file}".format( bucket=bucket, name=name, version=version, - file=f, - ext='.exe' if '-windows-' in f else '' + file=f ) if bucket.startswith('gs://'): upload_to_gcs(folder, f, dst, BIN_MATRIX[name].get('release', False)) @@ -237,8 +236,10 @@ def update_registry(version): lf = dist + '/latest.txt' write_file(lf, version) for name in os.listdir(dist): + if os.path.isfile(dist + '/' + name): + continue if name not in BIN_MATRIX: - return + continue call("gsutil cp {2} {0}/binaries/{1}/latest.txt".format(bucket, name, lf), cwd=REPO_ROOT) if BIN_MATRIX[name].get('release', False): call('gsutil acl ch -u AllUsers:R -r {0}/binaries/{1}/latest.txt'.format(bucket, name), cwd=REPO_ROOT)