From 2231d27f26369d91de92514231daacf87746d41c Mon Sep 17 00:00:00 2001 From: Adam Roberts Date: Thu, 1 Feb 2018 19:52:31 +0000 Subject: [PATCH] Simple docker push again --- BuildAndPushDockerhub.sh | 51 +++++++++++++++++++++++----------------- PublishChart.sh | 22 ++++++----------- 2 files changed, 36 insertions(+), 37 deletions(-) diff --git a/BuildAndPushDockerhub.sh b/BuildAndPushDockerhub.sh index 1ccbda2..f6ded41 100755 --- a/BuildAndPushDockerhub.sh +++ b/BuildAndPushDockerhub.sh @@ -4,47 +4,54 @@ # (C) Copyright IBM Corp. 2017. All Rights Reserved. # US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. -if ! [ $# -eq 5 ] ; then - echo "Requires five parameters: the image name you want, the tag you want, the Docker repository to push to, the username to push it as, and the Dockerfile location" - echo "E.g. ./BuildAndPushDockerhub.sh icp-nodejs-sample-amd64 1.0.0 ibmcom yourusername docker-6/Dockerfile" +if ! [ $# -eq 4 ] ; then + echo "Requires four parameters: the image name you want, the tag you want, the Dockerhub ID, the repository name, the Dockerfile to use." + echo "E.g. ./BuildAndPushDockerhub.sh icp-nodejs-sample-amd64 1.0.0 ibmcom docker-6/Dockerfile" exit; fi -echo "Warning, this will push to the desired location (e.g. on public Dockerhub!) after authenticating, pausing for five seconds, ensure this is really what you want to do first..." +docker rmi -f ibmcom/ibmnode +docker rmi -f node + +echo "WARNING: THIS WILL PUSH TO DOCKERHUB after authenticating, pausing for five seconds first." sleep 5 image_name=$1 -image_tag=$2 -docker_repository=$3 -docker_user=$4 -docker_file=$5 - -echo "Image name will be: ${image_name}" -echo "Image tag will be: ${image_tag}" -echo "Docker user: ${docker_user}" -echo "Docker repository: ${docker_repository}" -echo "File to use: ${docker_file}" - -docker login -u ${docker_user} +tag=$2 +docker_id_user=$3 +file_to_use=$4 + +echo "Image name is: ${image_name}" +echo "Tag is: ${tag}" +echo "Docker ID is ${docker_id_user}" +echo "File to use is: ${file_to_use}" + +if [[ ${docker_id_user} == "ibmcom" ]] ; then + echo "Using ibmrt ID" + docker login -u ibmrt +else + docker login -u ${docker_id_user} +fi if [ $? -ne 0 ]; then echo "Didn't login successfully, bailing"; exit; fi -echo "Building the Docker image" -docker build -t ${image_name}:${image_tag} . +echo "Docker building..." +docker build -f ${file_to_use} -t ${image_name}:${tag} . + if [ $? -ne 0 ]; then echo "Didn't build your application successfully, bailing"; exit; fi -echo "Tagging the Docker image" -docker tag ${image_name}:${image_tag} ${docker_user}/${docker_repository}/${image_name}:${image_tag} +echo "Docker tagging..." +docker tag ${image_name}:${tag} ${docker_id_user}/${image_name}:${tag} if [ $? -ne 0 ]; then echo "Didn't tag your image successfully, bailing"; exit; fi -echo "Pushing the Docker image" -docker push ${docker_user}/${docker_repository}/${image_name}:${image_tag} +echo "Docker pushing..." +docker push ${docker_id_user}/${image_name}:${tag} if [ $? -ne 0 ]; then echo "Didn't push your image successfully, bailing"; exit; fi diff --git a/PublishChart.sh b/PublishChart.sh index c945e60..71ff458 100755 --- a/PublishChart.sh +++ b/PublishChart.sh @@ -1,21 +1,13 @@ #!/bin/bash -if ! [ $# -eq 3 ] ; then - echo "Requires three parameters: the docker user, the docker repository, the architecture it's for. It'll automatically be tagged for 6 and then 8, using the right Dockerfiles for each build." - echo "E.g. ./PublishChart.sh ibmrt ibmcom amd64" +if ! [ $# -eq 1 ] ; then + echo "Requires one arg, the arch to build on." + echo "E.g. ./PublishChart.sh amd64|ppc64le|s390x" exit; fi -# e.g. ibmrt -docker_user=$1 +arch=$1 -# e.g. ibmcom -docker_repo=$2 - -# e.g. amd64, s390x, ppc64le -arch=$3 - -# e.g. ./BuildAndPushDockerhub.sh icp-nodejs-sample-amd64 1.0.0 ibmcom yourusername docker-6/Dockerfile" - -./BuildAndPushDockerhub.sh icp-nodejs-sample-$arch 6 $docker_repo $docker_user docker-6/Dockerfile -./BuildAndPushDockerhub.sh icp-nodejs-sample-$arch 8 $docker_repo $docker_user docker-8/Dockerfile +# if ibmcom, log in to ibmrt first +./BuildAndPushDockerhub.sh icp-nodejs-sample-$arch 6 ibmcom docker-6/Dockerfile +./BuildAndPushDockerhub.sh icp-nodejs-sample-$arch 8 ibmcom docker-8/Dockerfile