Adding the Docker packaging script

This commit is contained in:
Kohsuke Kawaguchi 2014-05-01 11:16:21 -07:00
parent d2eddf21b4
commit 2eca02b6fc
5 changed files with 46 additions and 3 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@
*.iws
target
config.properties
bin/jetty-runner.jar

12
Dockerfile Normal file
View File

@ -0,0 +1,12 @@
FROM ubuntu:trusty
RUN apt-get install -y openjdk-6-jre unzip
RUN useradd --create-home accountapp
ADD bin /home/accountapp/bin
ADD target/accountapp.war /home/accountapp/bin/accountapp.war
EXPOSE 8080
USER accountapp
ENTRYPOINT /home/accountapp/bin/run.sh

22
Makefile Normal file
View File

@ -0,0 +1,22 @@
IMAGENAME=jenkinsciinfra/account-app
TAG=$(shell date '+%Y%m%d_%H%M%S')
target/accountapp.war :
mvn install
bin/jetty-runner.jar :
wget -O bin/jetty-runner.jar 'http://search.maven.org/remotecontent?filepath=org/mortbay/jetty/jetty-runner/8.1.15.v20140411/jetty-runner-8.1.15.v20140411.jar'
image : target/accountapp.war bin/jetty-runner.jar
docker build -t ${IMAGENAME} .
run :
docker run -P --rm -i -t -v ${PWD}:/etc/accountapp ${IMAGENAME}
tag :
docker tag ${IMAGENAME} ${IMAGENAME}:${TAG}
push :
docker push ${IMAGENAME}

3
bin/run.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
cd "$(dirname "$0")"
exec java -DCONFIG=/etc/accountapp/config.properties -jar jetty-runner.jar --port 8080 --path /account accountapp.war

View File

@ -1,5 +1,4 @@
Testing locally
===============
# Testing locally
First, set up a tunnel to Jenkins LDAP server. Run the following command and keep the terminal open:
ssh -L 9389:localhost:389 cucumber.jenkins-ci.org
@ -20,4 +19,10 @@ Finally, run the application with Jetty, then access `http://localhost:8080/`:
mvn jetty:run
(As you can see above, this connects your test instance to the actual LDAP server, so the data you'll be seeing
is real.
is real.
# Packaging
For deploying to production, this app gets containerized. The container expects to see `/etc/accountapp` mounted
from outside that contains the abovementioned `config.properties`