Vini.g.fer
Vini.g.fer

Reputation: 11919

Install maven/java packages inside docker image without starting springboot

I have the following Dockerfile:

FROM maven:3.3.9
COPY . /code
WORKDIR /code
RUN ["mvn", "install"]
CMD mvn spring-boot:run

Which crashes on line 4 (mvn install), because all packages are installed, but at the end Spring starts and attempts to connect to the database container (it is not running, because for now I'm only building the images).

Is there a way I can just install maven packages, without getting spring up and running? I want to avoid downloading a lot of things every time I start my backend service.

Upvotes: 1

Views: 1296

Answers (2)

Prasanth
Prasanth

Reputation: 537

Do mvn install -DskipTests. It will skip everything and just download packages

Upvotes: 1

admlz635
admlz635

Reputation: 1014

CMD mvn spring-boot:run will cause application to start. Just replace it with a CMD sh -c or something that fits your need.

The main purpose of a CMD is to provide defaults for an executing container. These defaults can include an executable, or they can omit the executable, in which case you must specify an ENTRYPOINT instruction as well.

https://docs.docker.com/engine/reference/builder/

Upvotes: 0

Related Questions