Reputation: 13
I've followed Matt Raible's post https://developer.okta.com/blog/2017/06/20/develop-microservices-with-jhipster … and I am facing out to an error when running docker-compose in local machine.
The error shown to me was:
➜ ~ cd work/jhipster/microservices/docker
➜ docker docker-compose up
Building store-mongodb-node Step 1/2 : FROM mongo:3.4.8 ---> 917819fa18fd Step 2/2 : ADD mongodb/scripts/init_replicaset.js init_replicaset.js ERROR: Service 'store-mongodb-node' failed to build: ADD failed: stat /var/lib/docker/tmp/docker-builder345385260/mongodb/scripts/init_replicaset.js: no such file or directory
I created the store microservice with mongodb.
I ran ./mvnw -Pprod dockerfile:build in store, blog project. (because docker:build plugin not exist)
JHipster version: v4.8.0
Docker version: Docker version 17.06.2-ce, build cec0b72
Docker-compose version: docker-compose version 1.15.0, build e12f3b9
Anyone have a clue why docker is not able to find mongodb/scripts/init_replicaset.js?
version: '2' services: blog-app: image: blog environment: - SPRING_PROFILES_ACTIVE=prod,swagger - [....] store-mongodb-node: build: context: ../store/src/main/docker dockerfile: mongodb/MongoDB.Dockerfile command: mongod --replSet rs1 --noprealloc --smallfiles [...]
FROM openjdk:8-jre-alpine ENV SPRING_OUTPUT_ANSI_ENABLED=ALWAYS \ JHIPSTER_SLEEP=0 \ JAVA_OPTS="" ADD @[email protected] /app.war EXPOSE 8081 CMD echo "The application will start in ${JHIPSTER_SLEEP}s..." && \ sleep ${JHIPSTER_SLEEP} && \ java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar /app.war
FROM mongo:3.4.8 ADD mongodb/scripts/init_replicaset.js init_replicaset.js
var status = rs.status();
if(status.errmsg === 'no replset config has been received') {
rs.initiate();
}
for (var i = 1; i <= param; i++) {
if(i!==1)
rs.add(folder+"_store-mongodb-node_" + i + ":27017");
}
cfg = rs.conf();
cfg.members[0].host = folder+"_store-mongodb-node_1:27017";
rs.reconfig(cfg);
Thank you anyway.
Upvotes: 1
Views: 1423
Reputation: 372
I found the solution. The culprit is .dockerignore file. You can find it in src/main/docker
folder of each application.
Solution: remove **/*
from content of .dockerignore
**/*
!*.jar
!*.war
Jhipster 4.11.1 still has this issue. I will submit PR to remind the official of it.
Upvotes: 6