We provide 3 ways of working with JHipster:
npm
, which is the node package manager we are using in the next commands.
npm install -g yo
npm install -g bower
npm install -g grunt-cli
or Gulp.js with npm install -g gulp
.
npm install -g generator-jhipster
To find more information, tips and help, please have a look at the Yeoman "getting starting" guide and at the NPM documentation before submitting a bug.
The JHipster development box project gives you a virtual machine with all the necessary tools to develop your JHipster project.
Besides JHipster, this virtual machine includes many development tools like the Spring Tool Suite, the Atom text editor and MySQL Workbench.
Please go to the JHipster development box page for installation and configuration information.
JHipster has a specific jhipster-docker project, which provides a Docker container.
This project makes a Docker "Trusted build" that is available on:
https://hub.docker.com/r/jdubois/jhipster-docker/
This image will allow you to run JHipster inside Docker.
This depends on your operating system.
Kitematic is an easy-to-use graphical interface provided with the Docker Toolbox, which will makes this installation a lot easier.
If you are using boot2docker, it's good idea to migrate to Docker Toolbox, you can follow steps on how to migrate at FAQ section on https://www.docker.com/docker-toolbox
Pull the JHipster Docker image:
docker pull jdubois/jhipster-docker
Create a "jhipster" folder in your home directory:
mkdir ~/jhipster
Run The docker image, with the following options:
docker run --name jhipster -w /home/jhipster/app -v ~/jhipster:/home/jhipster/app:rw -v ~/.m2:/home/jhipster/.m2:rw -p 8080:8080 -p 3000:3000 -p 3001:3001 -d -t jdubois/jhipster-docker
If you have already started the container once before, you do not need to run the above command, you can simply start/stop the existing container.
To check that your container is running, use the command docker ps
:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4ae16c0539a3 jdubois/jhipster-docker "tail -f /home/jhipst" 4 seconds ago Up 3 seconds 0.0.0.0:3000-3001->3000-3001/tcp, 0.0.0.0:8080->8080/tcp jhipster
docker stop jhipster
docker start jhipster
In case you update the Docker image (rebuild or pull from the Docker hub), it's better to remove the existing container, and run the container all over again. To do so, first stop the container, remove it and then run it again:
docker stop jhipster
docker rm jhipster
docker pull jdubois/jhipster-docker
docker run --name jhipster -w /home/jhipster/app -v ~/jhipster:/home/jhipster/app:rw -v ~/.m2:/home/jhipster/.m2:rw -p 8080:8080 -p 3000:3000 -p 3001:3001 -d -t jdubois/jhipster-docker
On Linux, you might need to run the docker command as root user if your user is not part of docker group. It's a good idea to add your user to docker group so that you can run docker commands as non-root user. Follow the steps on http://askubuntu.com/a/477554 to do so.
The easiest way to log into container is executing following command :
docker exec -it --user=jhipster <container_name> bash
if you copy-pasted command to run container from above, notice the name being specified as jhipster
docker exec -it --user=jhipster jhipster bash
You will login as "jhipster" user, if in case you need to change as sudo user, password for the user is same as
username (i.e. jhipster)
You can then go to the /home/jhipster/app directory in your container, and start building your app inside Docker:
cd /home/jhipster/app
yo jhipster
If the following exception occurs:
...
? (15/15) Would you like to enable translation support with Angular Translate? (Y/n)
/usr/lib/node_modules/generator-jhipster/node_modules/yeoman-generator/node_modules/mkdirp/index.js:89
throw err0;
^
Error: EACCES, permission denied '/home/jhipster/app/src'
at Object.fs.mkdirSync (fs.js:653:18)
at sync (/usr/lib/node_modules/generator-jhipster/node_modules/yeoman-generator/node_modules/mkdirp/index.js:70:13)
You need to fix the jhipster folder to give the "jhipster" user ownership of the directory:
sudo chown -R jhipster /home/jhipster/app
Once your application is created, you can run all the normal grunt/bower/maven commands, for example:
mvn
Congratulations! You've launched your JHipster app inside Docker!
On your host machine, you should be able to :
http://DOCKER_HOST_IP:8080
Please note: based on your OS your DOCKER_HOST_IP
will differ. On linux, it will be simply your localhost. For Mac/Windows, you will have to obtain the IP using following command: docker-machine ip default
As the generated files are in your shared folder, they will not be deleted if you stop your Docker container. However, if you don't want Docker to keep downloading all the Maven and NPM dependencies every time you start the container, you should commit its state.