Last active
February 5, 2020 06:10
-
-
Save kameshsampath/f6e6c6deb85bd57cc44977d6773a8151 to your computer and use it in GitHub Desktop.
A script to use maven project coordinates in linux container image build
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# do your maven build here | |
# get the build artifact name | |
ARTIFACT_NAME=$(mvn org.apache.maven.plugins:maven-help-plugin:3.1.1:evaluate -Dexpression=project.build.finalName -q -DforceStdout) | |
ARTIFACT_VERSION=$(mvn org.apache.maven.plugins:maven-help-plugin:3.1.1:evaluate -Dexpression=project.version -q -DforceStdout) | |
IMAGE_NAME=${APP_NAME:-"dev.local/example/$ARTIFACT_NAME:$ARTIFACT_VERSION"} | |
docker build -t $IMAGE_NAME -f . | |
docker login | |
docker tag $IMAGE_NAME quay.io/example/$ARTIFACT_NAME:$ARTIFACT_VERSION | |
docker push quay.io/example/$ARTIFACT_NAME:$ARTIFACT_VERSION |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment