Skip to content
Advertisement

how to set docker image name as a file name it creates while building

So i want to set the docker image name as a file it creates. the stages inside the dockerfile are: set new version for pom.xml, compile, package all using mvn. i want to set the docker image name as the artifact the build creates Example: my-app-1.0.1

FROM maven:3-jdk-8-alpine AS build
ADD . /my-app
WORKDIR /my-app
RUN mvn versions:set -DnewVersion="1.0.1"
RUN mvn compile
RUN mvn package


FROM openjdk:8-jdk-alpine
COPY --from=build /my-app/target/my-app-1.0.1.jar my-app-1.0.1.jar
ENTRYPOINT ["java" "-cp" "my-app-1.0.1.jar" "com.mycompany.app.App"]

Thanks!

Advertisement

Answer

So as Thorbjørn Ravn, Andersen and Max advised I changed my approach. i set it outside and put it right with the image build command. Thanks for the help everyone! command help

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement