Skip to content

francisoud/jhipster-vagrant

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jhipster-vagrant

Vagrant configuration to setup a http://jhipster.github.io/ projet using ubuntu/trusty64 box.

Based on instructions at: http://jhipster.github.io/installation.html

Content

jhipster-standalone/ contains a vagrant conf with jhispter directly usable in ubuntu

jhipster-docker/ contains a vagrant conf with https://github.com/jhipster/jhipster-docker embedded in it

Setup

Copy the Vagrantfile somewhere

vagrant up
// ... long setup...
vagrant ssh

You are the first person to start the project

In the vagrant box

vagrant@vagrant-ubuntu-trusty-64:/vagrant$ yo jhipster
// follow instrucutions
exit

On your host machine: git add, commit, push

You are retrieving a jhipster / vagrant project create by someone else

git clone (repo with the Vagrantfile in it and the jhipster folders)
vagrant up

Under the hood

Basically it just scripting that does this:

Docker installation (for advanced users)

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://registry.hub.docker.com/u/jdubois/jhipster-docker/

This image will allow you to run JHipster inside Docker.

Prerequisites Linux

Linux supports out-of-box. You just need to follow the tutorial on the Docker website.

Prerequisites MAC or Windows

Docker uses Linux-specific kernel features so it doesn't run direcly on MAC or Windows. Different solutions are available for MAC and Windows users.

  1. Boot2docker - This is an official docker application to use speed up Docker on non-linux platform.
  2. Virtualbox - A Virtual Machine with Docker must be installed
  3. Vagrant - Use Virtualbox as provider and docker as Plugin

Boot2docker tutorial on MAC

  1. Install Boot2docker

  2. Initialize boot2docker - a boot2docker ISO image (tiny VM) will be downloaded and installed in the ~/.boot2docker folder.

    boot2docker init

  3. 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 "containergruntserver,tcp,,9000,,9000"
    VBoxManage modifyvm "boot2docker-vm" --natpf1 "containergruntreload,tcp,,35729,,35729"

  4. Start boot2docker

    boot2docker up

Usage on Linux

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:

  • The Docker "/jhipster" folder is shared to the local "~/jhipster" folder
  • Forward all ports exposed by docker (8080 for Tomcat, 9000 for the "grunt serve" task, 35729 for the live reload with grunt-contrib-watch 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 9000:9000 -p 35729:35729 -p 4022:22 -t jdubois/jhipster-docker

Usage on MAC

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:

  • Forward all ports exposed by docker (8080 for Tomcat, 9000 for the "grunt serve" task, 35729 for the live reload with grunt-contrib-watch 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 9000:9000 -p 35729:35729 -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.

  1. 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:9000->9000/tcp, 0.0.0.0:35729->35729/tcp naughty_bartik

  2. Add the samba support.

    docker run --rm -v /usr/local/bin/docker:/docker -v /var/run/docker.sock:/docker.sock svendowideit/samba naughty_bartik

  3. 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' radiobox and connect

  4. 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

SSH configuration

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

Your first project

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.

...
? (13/13) Would you like to use the Compass CSS Authoring Framework?: No

/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 spring-boot:run

Congratulations! You've launched your JHipster app inside Docker!

On your host machine, you should be able to :

  • Access the running application at http://localhost:8080
  • Get all the generated files inside your shared folder

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.

About

Vagrant configuration to setup a jhipster projet

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages