Sync folder in docker image from Jhipster

742 views Asked by At

I use Jhipster from docker under Window.

I follow the tuto but I can't synchronize my change in the docker image.

I want to have my own image from jhipster. I create new one

general03@L3F2GPK1F9W0 MINGW64 ~/jhipster/app/src/main/docker
$ docker build -t general03-jhipster .
Sending build context to Docker daemon 5.632 kB
Step 1 : FROM jhipster/jhipster
 ---> 0ae13f5d5a79
Step 2 : ADD . /app
 ---> Using cache
 ---> 1a8aaf63bf7e
Step 3 : ENV JHIPSTER_SLEEP 0
 ---> Using cache
 ---> 67a9ab5ce70a
Step 4 : ADD *.war /app.war
No source files were specified

In my Dockerfile I copied the original jhipster Dockerfile and replace first line and ADD . /app

FROM ubuntu:trusty

ADD . /app

ENV JHIPSTER_SLEEP 0

# add directly the war
ADD *.war /app.war

RUN sh -c 'touch /app.war'
VOLUME /tmp
EXPOSE 8080
CMD echo "The application will start in ${JHIPSTER_SLEEP}s..." && \
    sleep ${JHIPSTER_SLEEP} && \
    java -Djava.security.egd=file:/dev/./urandom -jar /app.war

And I see the image with docker images but without REPOSITORY and TAG ! So when I try to launch docker run 67a9ab5ce70a I have this error

C:\Program Files\Docker Toolbox\docker.exe: Error response from daemon: No command specified.docker run 67a9ab5ce70a

Somebody can help me to push my local modification to the docker images ?

1

There are 1 answers

8
David Steiman On

when you say

docker build -t general03-jhipster .

it means "build a docker image with the name general03-jhipster based on a docker file, located in ."

So you should generally run it with docker run general03-jhipster, but without arguments, this won't work until you provide port bindings

for the default JHipster configuration and dev profile

you should run

docker run --rm -p 8080:8080 general03-jhipster

If this fails, you propably starting in prod mode, so it needs some database binding. Passing this in command line can get up messy. Here you should take a look to JHipsters Docker compose support, to use docker compose to manage all your databases, elasticsearch instances etc..

edit: I didn't noticed the error first time here

Step 4 : ADD *.war /app.war
No source files were specified

So it's easy, you didn't generate a war file, so obvious the docker build fails.

Use

./mvnw package -Pprod docker:build

or

./gradlew build -Pprod bootRepackage buildDocker

to generate a proper docker build.

If you want to change some docker specific thinks (and using gradle), you can change this in "gradle/docker.gradle"