Skip to content
This repository has been archived by the owner on Feb 14, 2023. It is now read-only.

Commit

Permalink
Simple docker push again
Browse files Browse the repository at this point in the history
  • Loading branch information
a-roberts committed Feb 1, 2018
1 parent 1307fae commit 2231d27
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 37 deletions.
51 changes: 29 additions & 22 deletions BuildAndPushDockerhub.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 7 additions & 15 deletions PublishChart.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 2231d27

Please sign in to comment.