skip to Main Content

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!

2

Answers


  1. Chosen as BEST 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


  2. look at docker build usage

    You can specify a repository and tag at which to save the new image if the build succeeds:

    $ docker build -t shykes/myapp:1.0.2
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search