@@ -7,11 +7,13 @@ Usage: $0 [OPTIONS] [LABEL]
77Push a newly-built image with the given LABEL to gcr.io and DockerHub.
88
99Options:
10- -g, --gpu Push the image with GPU support.
10+ -g, --gpu Push the image with GPU support.
11+ -s, --source-image IMAGE Tag for the source image.
1112EOF
1213}
1314
14- SOURCE_IMAGE=' kaggle/python-build'
15+ SOURCE_IMAGE_TAG=' kaggle/python-build:latest'
16+ SOURCE_IMAGE_TAG_OVERRIDE=' '
1517TARGET_IMAGE=' gcr.io/kaggle-images/python'
1618
1719while : ; do
@@ -21,9 +23,18 @@ while :; do
2123 exit
2224 ;;
2325 -g|--gpu)
24- SOURCE_IMAGE =' kaggle/python-gpu-build'
26+ SOURCE_IMAGE_TAG =' kaggle/python-gpu-build:latest '
2527 TARGET_IMAGE=' gcr.io/kaggle-private-byod/python'
2628 ;;
29+ -s|--source-image)
30+ if [[ -z $2 ]]; then
31+ usage
32+ printf ' ERROR: No IMAGE specified after the %s flag.\n' " $1 " >&2
33+ exit
34+ fi
35+ SOURCE_IMAGE_TAG_OVERRIDE=$2
36+ shift # skip the flag value
37+ ;;
2738 -?* )
2839 usage
2940 printf ' ERROR: Unknown option: %s\n' " $1 " >&2
3849
3950LABEL=${1:- testing}
4051
41- readonly SOURCE_IMAGE
52+ if [[ -n " $SOURCE_IMAGE_TAG_OVERRIDE " ]]; then
53+ SOURCE_IMAGE_TAG=" $SOURCE_IMAGE_TAG_OVERRIDE "
54+ fi
55+
56+ readonly SOURCE_IMAGE_TAG
4257readonly TARGET_IMAGE
4358readonly LABEL
4459
4560set -x
46- docker tag " ${SOURCE_IMAGE} :latest " " ${TARGET_IMAGE} :${LABEL} "
61+ docker tag " ${SOURCE_IMAGE_TAG} " " ${TARGET_IMAGE} :${LABEL} "
4762gcloud docker -- push " ${TARGET_IMAGE} :${LABEL} "
48-
49- # Only CPU images are made public at this time.
50- if [[ " $LABEL " == " latest" && SOURCE_IMAGE = " kaggle/python-build" ]]; then
51- docker tag " ${SOURCE_IMAGE} :latest" " kaggle/python:${LABEL} "
52- docker push " kaggle/python:${LABEL} "
53- fi
0 commit comments