2

I have docker-compose with the following projects:
RabbitMQ management, producer and consumer,
producer and consumer (java springboot apps) share a maven dependency to common model api (3rd mini project containing POJOs used by producer and consumer). When I build everything locally with mvn and each dockerfile contains only copying jar and running the app everything works fine.

I tried to use multi-stage dockerfile but there is an error stating my producer can't find dependency for model-api on maven-central (from where it downloads all other dependencies).

I have tried using RUN mvn dependency:go-offline so it uses my local .m2/repo but no success, same error and still downloads dependencies from central.
How can I make it work?

Nebra
  • 106
  • 3
  • Are All your dependencies in maven central? if It is true you coult move your code into maven-image docker and run `mvn clean install` for package jar and run built jar ( all your dependencies will be downloaded inside image ), so There are some strategies to use one image do build and other do run application. When are you getting error? – Dilermando Lima Nov 29 '21 at 21:57
  • no, problem is in my 3rd project with simple java classes that is used as dependency for producer and consumer. Other dependencies that are downloaded from the internet (maven central) work fine either way. – Nebra Nov 30 '21 at 16:22
  • What strategy are you using to share dependency ammong them? importing .jar manually? using parents on pom.xml? multi-module project? import path file in maven pom.xml using or some private repository? – Dilermando Lima Nov 30 '21 at 16:42
  • it's multi-module project. without parent pom. simple directory as root containing 3 separate projects (producer, consumer, api). the only shared dependency I care about at the moment is model-api, the rest of spring libs are downloaded from the local repo (in case of manually building project) or downloaded from maven central (in case of multi-stage dockerfile). Problem is how to share model-api and how to make it visible in any way for those projects in multi-stage dockerfile builds, – Nebra Dec 01 '21 at 17:56

0 Answers0