We provide 2 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.
JHipster has a specific jhipster-docker project, which provides a Docker container.
This project makes a Docker "Trusted build" that is available on:
https://registry.hub.docker.com/u/jdubois/jhipster-docker/
This image will allow you to run JHipster inside Docker.
Linux supports out-of-box. You just need to follow the tutorial on the Docker website.
Docker uses Linux-specific kernel features so it doesn't run directly on MAC or Windows. Different solutions are available for MAC and Windows users.
Install Boot2docker
Initialize boot2docker - a boot2docker ISO image (tiny VM) will be downloaded and installed in the ~/.boot2docker folder.
boot2docker init
Add a portmap to the VM to expose the port to your host
VBoxManage modifyvm "boot2docker-vm" --natpf1 "containerssh,tcp,,4022,,4022"
VBoxManage modifyvm "boot2docker-vm" --natpf1 "containertomcat,tcp,,8080,,8080"
VBoxManage modifyvm "boot2docker-vm" --natpf1 "containerbrowersync,tcp,,3000,,3000"
VBoxManage modifyvm "boot2docker-vm" --natpf1 "containerbrowersyncui,tcp,,3001,,3001"
Start boot2docker
boot2docker up
Pull the JHipster Docker image:
sudo docker pull jdubois/jhipster-docker
Create a "jhipster" folder in your home directory:
mkdir ~/jhipster
Run The docker image, with the following options:
grunt
task, 3001 for the BrowserSync UI, and 22 for SSHD). In the following example we forward the container 22 port to the host 4022 port, to prevent some port conflicts:
sudo docker run -v ~/jhipster:/jhipster -p 8080:8080 -p 3000:3000 -p 3001:3001 -p 4022:22 -t jdubois/jhipster-docker
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:
grunt
task, 3001 for the BrowserSync UI, and 22 for SSHD). In the following example we forward the container 22 port to the host 4022 port, to prevent some port conflicts
docker run -d -p 8080:8080 -p 3000:3000 -p 3001:3001 -p 4022:22 -t jdubois/jhipster-docker
Make a volume container
The Docker -v option should be used to share the Docker "/jhipster" folder to the local "~/jhipster" folder. However, this option doesn't work on MAC (issue 4023 on docker project). The workaround is to use the svendowideit/samba project. More information can be found on the https://github.com/boot2docker/boot2docker#folder-sharing section on the boot2docker website.
Retrieve the name of the container
Here is the resultat of the command `docker ps`. Get the name at the column NAMES.
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
418448ff3371 jdubois/jhipster-docker:latest "/bin/sh -c '/usr/sb 59 minutes ago Up 59 minutes 0.0.0.0:4022->22/tcp, 0.0.0.0:8080->8080/tcp, 0.0.0.0:3000->3000/tcp, 0.0.0.0:3001->3001/tcp naughty_bartik
Add the samba support.
docker run --rm -v /usr/local/bin/docker:/docker -v /var/run/docker.sock:/docker.sock svendowideit/samba naughty_bartik
Folder sharing
goto Go|Connect to Server in Finder
enter 'cifs://192.168.59.103
hit the 'Connect' button
select the volumes you want to mount
choose the 'Guest' radio button and connect
Once mounted, will appear as /Volumes/jhipster. Create a symlink to make the volume accessible in the local "~/jhipster" folder.
ln -s /Volumes/jhipster ~/jhipster
You can now connect to your docker container with SSH. You can connect as "root/jhipster" or as "jhipster/jhipster", and we recommand you use the "jhipster" user as some of the tool used are not meant to be run by the root user.
Start by adding your SSH public key to the Docker container:
cat ~/.ssh/id_rsa.pub | ssh -p 4022 jhipster@localhost 'mkdir ~/.ssh && cat >> ~/.ssh/authorized_keys'
You can now connect to the Docker container:
ssh -p 4022 jhipster@localhost
You can then go to the /jhipster directory in your container, and start building your app inside Docker:
cd /jhipster
yo jhipster
If the following exception occurs, you need to change the owner of the /jhipster directory. See next step.
...
? (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 '/jhipster/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)
at sync (/usr/lib/node_modules/generator-jhipster/node_modules/yeoman-generator/node_modules/mkdirp/index.js:76:24)
at Function.sync (/usr/lib/node_modules/generator-jhipster/node_modules/yeoman-generator/node_modules/mkdirp/index.js:76:24)
at JhipsterGenerator.app (/usr/lib/node_modules/generator-jhipster/app/index.js:419:10)
at /usr/lib/node_modules/generator-jhipster/node_modules/yeoman-generator/lib/base.js:387:14
at processImmediate [as _immediateCallback] (timers.js:345:15)
You need to fix the jhipster folder to give the "jhipster" user ownership of the directory:
ssh -p 4022 jhipster@localhost
sudo chown jhipster /jhipster
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 :
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.