Skip to content

Commit

Permalink
Docker images from Robert Nemeti
Browse files Browse the repository at this point in the history
  • Loading branch information
nrobert13 committed Aug 11, 2015
1 parent 5bd6256 commit b00a5a1
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 0 deletions.
4 changes: 4 additions & 0 deletions application/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,9 @@ RUN echo debconf shared/accepted-oracle-license-v1-1 seen true | sudo debconf-se
RUN apt-get install -q -y oracle-java8-installer

# Add the dist package of de.idnow.example from de.idnow.example/target/universal/de-idnow-example-1.0-SNAPSHOT.zip
RUN mkdir /opt/idnow
ADD de.idnow.example/target/universal/de-idnow-example-1.0-SNAPSHOT.zip /opt/idnow/

# Start the play netty server on image start
RUN ["unzip","/opt/idnow/de-idnow-example-1.0-SNAPSHOT.zip","-d","/opt/idnow/"]
ENTRYPOINT ["/opt/idnow/de-idnow-example-1.0-SNAPSHOT/bin/de-idnow-example"]
9 changes: 9 additions & 0 deletions application/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,13 @@ cd de.idnow.example
./activator update compile dist
cd ..

#because dockerignore is not able to include parts of a wildcard exclude, we exclude everything but our package
echo -e "build.sh\nrun.sh" > .dockerignore
find de.idnow.example/ ! -regex 'de.idnow.example/?\(target\)?/?\(universal\)?/?\(de-idnow-example-1.0-SNAPSHOT.zip\)?' >> .dockerignore

# now create the docker image
docker build -t nrobert/idnow-app .

#we don't need .dockerignore, as we generate it dynamically
rm -f .dockerignore

4 changes: 4 additions & 0 deletions application/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

#run the container with port 9000 exposed and mapped to host, in order to be able to accept incomming requestes from nginx
docker run -it --rm -p 9000:9000 nrobert/idnow-app
2 changes: 2 additions & 0 deletions nginx-proxy/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run.sh
build.sh
9 changes: 9 additions & 0 deletions nginx-proxy/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
FROM ubuntu:14.04

RUN apt-get install -q -y nginx

ADD nginx-site /etc/nginx/sites-available/default
ADD start-nginx.sh /root/

# forward request and error logs to docker log collector
RUN ln -sf /dev/stdout /var/log/nginx/access.log
RUN ln -sf /dev/stderr /var/log/nginx/error.log

ENTRYPOINT ["/root/start-nginx.sh"]
9 changes: 9 additions & 0 deletions nginx-proxy/nginx-site
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
server {

listen 80 default_server;
server_name _;
location / {
proxy_pass http://192.168.5.171:9000;
}
}

25 changes: 25 additions & 0 deletions nginx-proxy/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash -ex

usage="Usage: $0 <valid IP address of the listening app>"

#check if there is an argument
if [ $# -ne 1 ] ; then
echo $usage
exit 1
fi
#check if the arg is a valid IP address
oIFS=$IFS
IFS="."
arr=($1)
IFS=$oIFS
for i in "${!arr[@]}"
do
if [ $i -gt 3 ] || [ ${arr[$i]} -gt 255 ] ; then
echo $usage
exit 1
fi

done

#run the container with port 80 exposed and mapped to the host so it's accesible
docker run -it --rm -p 80:80 docker-example-nginx-proxy $1
7 changes: 7 additions & 0 deletions nginx-proxy/start-nginx.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash -ex

#pass on the listening ip of the app server to nginx
perl -pli -e "/proxy_pass/ and s/\/[\d\.]*:/\/$1:/" etc/nginx/sites-available/default

#run nginx in foreground
nginx -g "daemon off;"

0 comments on commit b00a5a1

Please sign in to comment.