Skip to content

Commit

Permalink
docker build and push scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
rusakovichma committed May 12, 2022
1 parent 95de790 commit 317d604
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
18 changes: 18 additions & 0 deletions build-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash -e

VERSION=$(mvn -q \
-Dexec.executable="echo" \
-Dexec.args='${project.version}' \
--non-recursive \
org.codehaus.mojo:exec-maven-plugin:1.3.1:exec)

FILE=./target/tic-taac-$VERSION-release.zip
if [ -f "$FILE" ]; then
docker build . --build-arg VERSION=$VERSION -t rusakovichma/tic-taac:$VERSION
if [[ ! $VERSION = *"SNAPSHOT"* ]]; then
docker tag rusakovichma/tic-taac:$VERSION rusakovichma/tic-taac:latest
fi
else
echo "$FILE does not exist - run 'mvn package' first"
exit 1
fi
25 changes: 25 additions & 0 deletions push-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash -e

VERSION=$(mvn -q \
-Dexec.executable="echo" \
-Dexec.args='${project.version}' \
--non-recursive \
org.codehaus.mojo:exec-maven-plugin:1.3.1:exec)

if [[ $VERSION = *"SNAPSHOT"* ]]; then
echo "Do not publish a snapshot version of tic-taac"
exit 1
fi
docker inspect --type=image rusakovichma/tic-taac:$VERSION > /dev/null 2>&1
if [[ "$?" -ne 0 ]] ; then
echo "docker image rusakovichma/tic-taac:$VERSION does not exist - run build_docker.sh first"
exit 1
fi
docker inspect --type=image rusakovichma/tic-taac:latest > /dev/null 2>&1
if [[ "$?" -ne 0 ]] ; then
echo "docker image rusakovichma/tic-taac:latest does not exist - run build_docker.sh first"
exit 1
fi

docker push rusakovichma/tic-taac:$VERSION
docker push rusakovichma/tic-taac:latest

0 comments on commit 317d604

Please sign in to comment.