This repo just has some docker coding that I did for practicing docker and to see its functioning and working.
- VirtualBox
- Vagrant
- Docker
After The above prereqs are met:
Verifying we can run docker:
docker run hello-world
Output:
- Build a docker environment for running build. Create a "Dockerfile" and place this content inside:
Output:
- Build the the docker image
sudo docker build -t ncsu/buildserver .
Output:
- See what images are current available on the machine.
sudo docker images
Output:
- Verify image works and can run a maven command.
sudo docker run -it ncsu/buildserver mvn --version
Output:
-
Let's look at all the containers we have created by running commands above.
sudo docker ps -a
Output:
- We're going to need a container, with a process still running in it, meaning we need the
-d
arg.
sudo docker run -it -d ncsu/buildserver
Output:
- This will show you last container id created.
sudo docker ps -l
Output:
- Let's take last container, and update it.
sudo docker exec -it 6195dba8e712 script /dev/null -c "echo 'Hello' > foo.txt"
- Make sure we can see change:
docker exec -it 6195dba8e712 ls
Output:
As we can see foo.txt is added
- Now, let's commit this to our image.
docker commit 6195dba8e712 ncsu/buildserver
Now, any new container created from this image will have the new chanage.
- In your host VM, create 'build.sh' and place the following inside:
git clone https://github.com/CSC-326/JSPDemo
cd JSPDemo
mvn compile -DskipTests -Dmaven.javadoc.skip=true
- Execute script
chmod +x build.sh
sudo docker run -v /home/<username>/:/vol ncsu/buildserver sh -c /vol/build.sh
Output:
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 5 source files to /JSPDemo/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 29.075s
[INFO] Finished at: Mon Nov 28 21:36:19 UTC 2016
[INFO] Final Memory: 15M/37M
[INFO] ------------------------------------------------------------------------
- We will create a simple server to trigger a build server.
Install node (on the VM).
curl https://raw.githubusercontent.com/creationix/nvm/v0.16.1/install.sh | sh
source ~/.profile
nvm install v0.11.13
nvm use 0.11.13
echo "nvm use 0.11.13" >> ~/.profile
- A simple http server in node.
cd BuildServer
node server.js
Output: