This folder contains instructions to setup an Instructor environment.
|
Important
|
Make sure to run these instructions a day prior to the lab. You need a good Internet connection as several files and Docker images need to be downloaded. Plan for at least 60 minutes. |
Instructor needs:
-
Docker Registry server
-
Boot2docker served by a local HTTP Server
-
Nexus Proxy
|
Note
|
All instructions are to be run from the instructor directory.
|
-
CPU
-
Mac: X64 (i5 or superior)
-
Linux / Windows: x64 (i5 and comparable)
-
-
Memory: At least 8 GB, 16 GB is preferred
-
Operating System
-
Mac OS X (10.8 or later), Windows 7 (SP1), Fedora (21 or later)
-
-
Oracle Virtualbox, include install folder to your PATH.
-
Check out https://github.com/javaee-samples/docker-java/ git repository.
-
Webbrowser
Docker Client allows to interact with Docker Host. Download and install by just copying and renaming it accordingly.
#Linux (Fedora only)
yum install docker-io
# MacOS / Linux (other distros)
curl -L https://get.docker.com/builds/`uname -s`/x86_64/docker-latest > /usr/local/bin/docker
chmod +x /usr/local/bin/docker
#Windows
Download:
https://get.docker.com/builds/Windows/x86_64/docker-latest.exe
https://get.docker.com/builds/Windows/i386/docker-latest.exe
And save to c:\Users\<username>\docker\docker.exeDocker Compose simplifies instructor’s setup. The docker-compose.yml contains all the instructions for the tool to setup and start the infrastructure.
Learn more about the tool on Docker Compose Website.
# Linux / MacOS
curl -L https://github.com/docker/compose/releases/download/1.3.0rc3/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-composeDocker Compose is not natively supported on Windows and thus requires a workaround as specfied at http://blog.eisele.net/2015/06/docker-compose-on-windows-with-python.html. You need to install Babun and Python to get further from here on.
Install the Docker machine client for your environment: latest releases
# MacOS
curl -L https://github.com/docker/machine/releases/download/v0.3.0-rc3/docker-machine_darwin-amd64 > /usr/local/bin/docker-machine
chmod +x /usr/local/bin/docker-machine
# Linux
curl -L https://github.com/docker/machine/releases/download/v0.3.0-rc3/docker-machine_linux-amd64 > /usr/local/bin/docker-machine
chmod +x /usr/local/bin/docker-machine
# Windows
Download:
https://github.com/docker/machine/releases/download/v0.3.0-rc3/docker-machine_windows-amd64.exe
And save to c:\Users\<username>\docker\docker-machine.exeFor Windows, make sure to add c:\Users\<username>\docker to your %PATH% variable. This was already done for Linux / MacOs when you downloaded docker-machine script to /usr/local/bin/docker-machine.
If you’re executing commands in the Babun bash from here on, make sure to keep in mind, that the Path variable is set in Linux/Unix style:
PATH=$PATH\:/d/Program\ Files\ \(x86\)/docker ; export PATH. You have to escape all special characters with a backslash.
There is no in-built support for DNS and so this needs to be configured. Currently this works only on Mac and Linux, and need to be fixed for Windows #61.
-
Edit
/etc/hosts(Mac OS / Linux)<INSTRUCTOR_IP> classroom.example.comImportant<INSTRUCTOR_IP> is the IP of your public interface eg. en0, eth0. -
Install a simple dns server such as
dnsmasqas:brew install dnsmasqto see the output as:
> brew install dnsmasq ==> Downloading http://www.thekelleys.org.uk/dnsmasq/dnsmasq-2.72.tar.gz ######################################################################## 100.0% ==> make install PREFIX=/usr/local/Cellar/dnsmasq/2.72 ==> Caveats To configure dnsmasq, copy the example configuration to /usr/local/etc/dnsmasq.conf and edit to taste. cp /usr/local/opt/dnsmasq/dnsmasq.conf.example /usr/local/etc/dnsmasq.conf To have launchd start dnsmasq at startup: sudo cp -fv /usr/local/opt/dnsmasq/*.plist /Library/LaunchDaemons sudo chown root /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist Then to load dnsmasq now: sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist ==> Summary 🍺 /usr/local/Cellar/dnsmasq/2.72: 7 files, 492K, built in 28 seconds You may need to restart Dnsmasq to get it to recognise this change: sudo launchctl stop homebrew.mxcl.dnsmasq sudo launchctl start homebrew.mxcl.dnsmasqThis can be done on Linux as:
sudo yum -y install dnsmasq -
Edit
/etc/resolv.conf(Mac OS / Linux)nameserver <INSTRUCTOR_IP> -
Make sure that dnsmasq starts automatically follow the instructions from brew or yum.
-
Creates instructor host which will run the complete infrastructure.
docker-machine create --driver=virtualbox --virtualbox-memory=4096 --engine-insecure-registry=classroom.example.com:5000 instructor-machine -
Configure Docker client to run the commands on this newly created machine as:
eval "$(docker-machine env instructor-machine)"ImportantIf you change your network, you may need to restart your docker machine:
docker-machine restart instructor-machine
Expose the Virtual Box ports to other computer in the LAN
VirtualBox will run docker container inside the newly create host called 'instructor-machine'. We need now to expose the ports used in this lab to the world.
#Open Registry Server port
VBoxManage controlvm "instructor-machine" natpf1 "tcp-port5000,tcp,,5000,,5000";
#Open Nexus Server port
VBoxManage controlvm "instructor-machine" natpf1 "tcp-port8081,tcp,,8081,,8081";
#Open HTTP Server port
VBoxManage controlvm "instructor-machine" natpf1 "tcp-port8082,tcp,,8082,,8082";
#Open gitlab ports
VBoxManage controlvm "instructor-machine" natpf1 "tcp-port10022,tcp,,10022,,10022";
VBoxManage controlvm "instructor-machine" natpf1 "tcp-port10080,tcp,,10080,,10080";This is available as a script in https://github.com/javaee-samples/docker-java/blob/master/instructor/virtualbox-ports.sh. A Windows version in https://github.com/javaee-samples/docker-java/blob/master/instructor/virtualbox-ports.bat
Create a container with Nexus dependencies.
We want to provide an option to run this lab without any Internet access. So, the instructor machine will contain everything that the attendees will need to run this lab.
docker run --name="nexusdata" -v $(pwd):/backup sonatype/nexus:oss bash -c "tar xvf /backup/nexusbackup.tar -C /"|
Note
|
Running Windows, make sure to copy the nexusbackup.tar to the following folder c:/Users/<username>/docker-hol and make sure to update the docker run command accordingly.
The folder permissions in Windows don’t allow for a location of your choice.
|
This will download the Nexus image on Docker host and populate it with the Nexus dependencies.
Download JBoss Developer Studio 9.0 - Nightly - 482MB - JAR File and place it inside dockerfiles/lab-httpd-server/downloads folder.
Use the following compose command to startup the complete environment at once.
|
Note
|
This command should take some time to execute as it will download the required Docker images. |
docker-compose up -dThe status of different servers can be verified as:
instructor> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7b847ca4554e registry:2.0 "registry cmd/regist 45 seconds ago Up 45 seconds 0.0.0.0:5000->5000/tcp instructor_dockerregistry_1
3704d3205eac sameersbn/gitlab:7.10.4 "/app/init app:start About a minute ago Up About a minute 443/tcp, 0.0.0.0:10022->22/tcp, 0.0.0.0:10080->80/tcp instructor_gitlab_1
66ac375ecd8d sameersbn/postgresql:9.4 "/start" 2 minutes ago Up 2 minutes 5432/tcp instructor_postgresqlgitlab_1
b4a36e701386 sonatype/nexus:oss "/bin/sh -c 'java 4 minutes ago Up 4 minutes 0.0.0.0:8081->8081/tcp instructor_nexus_1
5986b380732c sameersbn/redis:latest "/start" 4 minutes ago Up 4 minutes 6379/tcp instructor_redisgitlab_1
a041b58ceff1 instructor_httpserver:latest "/run-apache.sh" 5 minutes ago Up 5 minutes 0.0.0.0:8082->80/tcp instructor_httpserver_1Test if the servers are running:
-
Docker Registry [http://localhost:5000/v2/]
-
Nexus Console [http://localhost:8081/content/groups/public/]
-
Apache Webserver [http://localhost:8082/]
-
Gitlab server [http://localhost:10080/]
In order to allow a complete offline experience, we also host our own git repository for the demo application on the instructor machine.
|
Note
|
Gitlab must have completed his startup. It usually takes 3 minutes to do so. |
Execute:
docker exec instructor_gitlab_1 bash -c "cd /home/git/data/repositories/root; git clone --bare https://github.com/rafabene/ticket-monster.git; chown git:git -R /home/git/data/repositories; cd /home/git/gitlab; sudo -u git -H bundle exec rake -v gitlab:import:repos RAILS_ENV=production"This will show the output as:
Cloning into bare repository 'ticket-monster.git'...
Processing root/ticket-monster.git
* Created ticket-monster (root/ticket-monster.git)
Done!-
Clone TicketMonster from the existing gitlab container
git clone -b WildFly-docker-test http://root:dockeradmin@localhost:10080/root/ticket-monster.git
-
Build TicketMonster
mvn -s settings.xml -f ticket-monster/demo/pom.xml -Ppostgresql clean package
-
Copy TicketMonster war to the Docker ticketmonster-pgsql-widlfly image folder
cp ticket-monster/demo/target/ticket-monster.war dockerfiles/ticketmonster-pgsql-wildfly/
Build managed-widlfly'' and ticketmonster-pgsql-widlfly'' images
docker build -t "instructor/wildfly-management" dockerfiles/wildfly-management/
docker build -t "instructor/ticketmonster-pgsql-wildfly" dockerfiles/ticketmonster-pgsql-wildfly/This is available as a script in https://github.com/javaee-samples/docker-java/blob/master/instructor/buid-images.sh
Push the required images to the local registry by executing the script push-images-to-registry.sh.
If you need some extra information like:
-
Updating the attendees instructions served by the instructor httpd server
-
Backing up Nexus data container to a file
Please, check the extra instructions.



