diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..e8dc3e737 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +FROM ubuntu:14.04 +MAINTAINER no-one-yet + +ENV USER tatami +ENV TATAMI_DIR /opt/tatami +ENV JETTY_VERSION 8.1.8.v20121106 + +RUN apt-get update +RUN apt-get install -y git-core curl wget openjdk-6-jdk + +RUN bash -c 'mkdir -p $TATAMI_DIR/{application,maven,data,data/elasticsearch,log,log/elasticsearch}' + +WORKDIR $TATAMI_DIR + +RUN wget http://central.maven.org/maven2/org/mortbay/jetty/dist/jetty-deb/$JETTY_VERSION/jetty-deb-$JETTY_VERSION.deb && \ + dpkg -i jetty-deb-$JETTY_VERSION.deb && \ + rm -f jetty-deb-$JETTY_VERSION.deb && \ + rm -rf /opt/jetty/webapps/* + +RUN touch toto +ADD target/root.war /opt/jetty/webapps/root.war + +WORKDIR /opt/jetty + +CMD ["java", "-jar", "start.jar", "OPTIONS=Server,jsp,resources,websocket,ext,plus,annotations"] diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..040c14141 --- /dev/null +++ b/Makefile @@ -0,0 +1,102 @@ +.SILENT : + .PHONY : all + +USERNAME:=pouicr +APPNAME:=tatami +IMAGE:=$(USERNAME)/$(APPNAME) +DB:=cassandra +DBIMG:=spotify/cassandra +IP:=`sudo docker inspect --format '{{ .NetworkSettings.IPAddress }}' $(APPNAME)` + +define docker_run_flags +-p 8080:8080 \ +--link cassandra:cassandra +endef + +## This help screen +help: + printf "Available targets:\n\n" + awk '/^[a-zA-Z\-\awk_0-9]+:/ { \ + helpMessage = match(lastLine, /^## (.*)/); \ + if (helpMessage) { \ + helpCommand = substr($$1, 0, index($$1, ":")); \ + helpMessageMessage = substr(lastLine, RSTART + 3, RLENGTH); \ + printf "%-15s %s\RLENGTHn", helpCommand, helpMessage; \ + } \ + } \ + { lastLine = $$0 }' $(MAKEFILE_LIST) + +## Build the volume image +volume: + echo "Building $(APPNAME) volumes..." + -sudo docker run -v $(PWD)/target/root.war:/opt/jetty/webapps/root.war --name $(APPNAME)_volumes busybox true + +## Remove the volume image +rm_volume: + echo "Remove $(APPNAME) volumes..." + -sudo docker rm $(APPNAME)_volumes + +## Run in dev mode (mount the volume) +dev: volume + $(eval docker_run_flags += --volumes-from $(APPNAME)_volumes) + @echo "Dev mode activated" + + +## Build the image +build: + echo "Building $(IMAGE) docker image..." + sudo docker build --rm -t $(IMAGE) . + +## Stop and delete the container +clean: stop rm + +## Up app and DB +up: volume dev start_db start + +## Stop and rm app and DB +down: stop_db rm_db stop rm rm_volume + +## Start the container +start: + echo "Starting $(IMAGE) docker image..." + sudo docker run -d $(docker_run_flags) --name $(APPNAME) $(IMAGE) + +## Start bash inside the app container +bash: + echo "Starting bash inside $(APPNAME) docker container..." + sudo docker exec -it $(APPNAME) /bin/bash + +## Stop the container +stop: + echo "Stopping container $(APPNAME)..." + -sudo docker stop $(APPNAME) + +## Delete the container +rm: + echo "Deleting container $(APPNAME)..." + -sudo docker rm $(APPNAME) + +## Delete image +rmi: + echo "Deleting image $(IMAGE)..." + -sudo docker rmi $(IMAGE) + +## Show container logs +logs: + echo "Logs of the $(APPNAME) container..." + sudo docker logs -f $(APPNAME) + +## Start db +start_db: + echo "Starting $(DB) docker image..." + sudo docker run -d --name $(DB) $(DBIMG) + +## Stop db +stop_db: + echo "Stopping container $(DB)..." + -sudo docker stop $(DB) + +## Remove db container +rm_db: + echo "Deleting container $(DB)..." + -sudo docker rm $(DB) diff --git a/PR.md b/PR.md new file mode 100644 index 000000000..74a74e194 --- /dev/null +++ b/PR.md @@ -0,0 +1,41 @@ +PullRequest +=========== + +Add Docker support +----------------- + +In order to deploy Tatami on a Docker host easily, here are the required steps (required make and maven installed): +* mvn clean package -Pdocker (-DskipTests) +* (optional) Change the username inside the Makefile +* make build: will create the docker image (java, jetty) and copy the war inside + +Here you have a /tatami docker image. It required a cassandra container to run. + +Here you can choose: +* Using make: + * make start_db will pull and run a spotify cassandra docker image + * make start will run and link the tatami and cassandra containers. + * check it is running by doing "docker ps" +* Using fig (required fig installed or using https://registry.hub.docker.com/u/dduportal/fig/): + * (optional) aligne your image name in the fig.yml + * fig up -d + * check it is running by doing "fig ps" + +You should now have a tatami running at localhost:8080 + +Stop you app by doing: +* make stop rm +* make stop_db rm_db +or +* fig stop +* fig rm --force + + +What about development using those docker images +------------------------------------------------- + +In order to test your devs into those builtin images you can: +* Work as usual, using your prefered IDE in order to create your snapshot root.war +* Instead of running "make start" which will create a new container base on your tatami image with the war embedded, use "make dev start". It will start the same \ + image but will link it to the war present in your target folder. +* Use shortcut: "make up" on the morning (!) to start DB and App in dev mode. "make down" to clean your env. diff --git a/fig.yml b/fig.yml new file mode 100644 index 000000000..945577006 --- /dev/null +++ b/fig.yml @@ -0,0 +1,10 @@ +cassandra: + image: "spotify/cassandra:latest" + expose: + - "9160" +tatami: + image: "pouicr/tatami" + ports: + - "8080:8080" + links: + - cassandra:cassandra diff --git a/pom.xml b/pom.xml index af20586ab..305fa0ecc 100755 --- a/pom.xml +++ b/pom.xml @@ -58,12 +58,13 @@ apple-push 0 DEBUG - PAPERTRAIL - logs.papertrailapp.com - 38143 + CONSOLE + localhost 128M + localhost http://sandbox.tatamisoft.com localhost + localhost 25 tatami@ippon.fr true @@ -102,6 +103,67 @@ + + docker + + + + 0 + DEBUG + CONSOLE + localhost + 38143 + 512M + http://localhost:8080 + cassandra + ldap://10.55.0.4:389 + localhost + 25 + tatami@ippon.fr + + true + false + any + embedded + /opt/tatami/data/elasticsearch + /opt/tatami/log/elasticsearch + false + false + + 2003 + + + + + ro.isdc.wro4j + wro4j-maven-plugin + ${maven.wro4j.version} + + + compile + + run + + + + + tatami-vendor,tatami-app,tatami-account,tatami-app-account + false + ${basedir}/src/main/webapp/WEB-INF/generated-wro4j + ${basedir}/src/main/webapp + false + + + + ro.isdc.wro4j + wro4j-extensions + ${maven.wro4j.version} + + + + + + prod @@ -115,6 +177,7 @@ 38143 512M https://app.tatamisoft.com + localhost ldap://10.55.0.4:389 localhost 25 @@ -380,6 +443,7 @@ 64M ${project.version} http://localhost:8080 + localhost ldap://directory:389 dc=ippon,dc=fr (uid={0}) diff --git a/src/main/resources/META-INF/tatami/tatami.properties b/src/main/resources/META-INF/tatami/tatami.properties index 6e045ff88..4b6c4b3c5 100755 --- a/src/main/resources/META-INF/tatami/tatami.properties +++ b/src/main/resources/META-INF/tatami/tatami.properties @@ -39,7 +39,7 @@ apple.push.certificate=${apple.push.certificate} apple.push.password=${apple.push.password} #Cassandra configuration -cassandra.host=127.0.0.1:9160 +cassandra.host=${tatami.cassandra.host}:9160 cassandra.clusterName=Tatami cluster cassandra.keyspace=tatami