Skip to content

Instantly share code, notes, and snippets.

@kameshsampath
Last active February 5, 2020 06:10
Show Gist options
  • Save kameshsampath/f6e6c6deb85bd57cc44977d6773a8151 to your computer and use it in GitHub Desktop.
Save kameshsampath/f6e6c6deb85bd57cc44977d6773a8151 to your computer and use it in GitHub Desktop.
A script to use maven project coordinates in linux container image build
#!/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