File bin/modules/docker.sh

Last commit: Mon Dec 9 23:31:46 2024 +0100	Jan Dankert	More user output for docker module.
1 #!/bin/bash 2 3 function build() { 4 5 6 TAG=$1 7 8 if [ -z "$TAG" ]; then 9 echo "No tag defined..." 10 return 11 fi 12 13 if [ ! -f ${WORK_DIR}/Dockerfile ]; then 14 echo "No Dockerfile for tag $TAG, continueing ..." 15 return 16 fi 17 tagname="$REPO_NAME:$1" 18 echo 19 echo "--- Building Docker image $tagname ---" 20 docker build $WORK_DIR --tag $tagname 21 22 if [ $? -ne 0 ]; then 23 echo 24 echo "Docker build FAILED" 25 return 4 26 fi 27 28 if [ -n "$dockerhub_owner" ]; then 29 echo 30 echo ">>>>>>>>> Pushing $tagname to remote" 31 tagname_remote="$dockerhub_owner/$tagname" 32 docker image tag $tagname $tagname_remote 33 34 docker push $tagname_remote 35 36 if [ $? -ne 0 ]; then 37 echo "Error: Docker push FAILED" 38 return 4 39 fi 40 else 41 echo "Info: No dockerhub user configured, so not pushing to dockerhub" 42 fi 43 } 44 45 WORK_DIR="$(mktemp -d)" 46 47 echo "Cloning GIT to temporary directory $WORK_DIR ..." 48 git clone . $WORK_DIR 49 50 build latest 51 52 echo "Searching for GIT tags ..." 53 git -C $WORK_DIR tag 54 for tag in $(git -C $WORK_DIR tag); do 55 echo "... found tag $tag" 56 57 if [[ $(docker images -q $REPO_NAME:$tag | wc -c) -ne 0 ]]; then 58 echo "Info: Image $REPO_NAME:$tag found" 59 else 60 echo "Info: Image $REPO_NAME:$tag not found in local registry" 61 git -C $WORK_DIR checkout tags/$tag 62 build $tag 63 if [ $? -ne 0 ]; then 64 echo "Error: Image could not be build." 65 return 4; 66 fi 67 fi 68 done 69 70 echo "Deleting $WORK_DIR" 71 rm -rf $WORK_DIR
Download bin/modules/docker.sh
History Mon, 9 Dec 2024 23:31:46 +0100 Jan Dankert More user output for docker module. Sun, 8 Dec 2024 22:33:23 +0100 Jan Dankert Modules can be disabled by project configuration Wed, 27 Nov 2024 01:04:22 +0100 Jan Dankert Small fixes... Tue, 26 Nov 2024 23:26:36 +0100 Jan Dankert New: Creating a project website Sun, 12 May 2024 19:53:02 +0200 Jan Dankert first edition of DIT, the delivery expert.