Skip to content

Commit

Permalink
Merge commit '958f7da4904598c85aabadf104c687e321eacb33'
Browse files Browse the repository at this point in the history
  • Loading branch information
tamalsaha committed Apr 20, 2017
2 parents 3409789 + 958f7da commit 1572395
Show file tree
Hide file tree
Showing 6 changed files with 287 additions and 23 deletions.
114 changes: 114 additions & 0 deletions hack/libbuild/common/cowrypay_image.sh
Original file line number Diff line number Diff line change
@@ -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
}
114 changes: 114 additions & 0 deletions hack/libbuild/common/k8sdb_image.sh
Original file line number Diff line number Diff line change
@@ -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
}
44 changes: 26 additions & 18 deletions hack/libbuild/common/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}

Expand All @@ -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
Expand Down
17 changes: 15 additions & 2 deletions hack/libbuild/common/private_image.sh
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -32,7 +45,7 @@ source_repo() {
docker_pull
;;
gcr)
docker_gcr
gcr_pull
;;
check)
docker_check
Expand Down Expand Up @@ -79,7 +92,7 @@ binary_repo() {
docker_pull
;;
gcr)
docker_gcr
gcr_pull
;;
check)
docker_check
Expand Down
17 changes: 15 additions & 2 deletions hack/libbuild/common/public_image.sh
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -29,7 +42,7 @@ source_repo() {
docker_pull
;;
gcr)
docker_gcr
gcr_pull
;;
release)
docker_release
Expand Down Expand Up @@ -79,7 +92,7 @@ binary_repo() {
docker_pull
;;
gcr)
docker_gcr
gcr_pull
;;
release)
docker_release
Expand Down
Loading

0 comments on commit 1572395

Please sign in to comment.