Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker support #803

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
102 changes: 102 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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)
41 changes: 41 additions & 0 deletions PR.md
Original file line number Diff line number Diff line change
@@ -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 <username>/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.
10 changes: 10 additions & 0 deletions fig.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cassandra:
image: "spotify/cassandra:latest"
expose:
- "9160"
tatami:
image: "pouicr/tatami"
ports:
- "8080:8080"
links:
- cassandra:cassandra
70 changes: 67 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,13 @@
<spring.profiles.active>apple-push</spring.profiles.active>
<jetty.scanIntervalSeconds>0</jetty.scanIntervalSeconds>
<logback.loglevel>DEBUG</logback.loglevel>
<logback.appender>PAPERTRAIL</logback.appender>
<logback.syslogHost>logs.papertrailapp.com</logback.syslogHost>
<logback.syslogHost.port>38143</logback.syslogHost.port>
<logback.appender>CONSOLE</logback.appender>
<logback.syslogHost>localhost</logback.syslogHost>
<ehcache.maxBytesLocalHeap>128M</ehcache.maxBytesLocalHeap>
<tatami.cassandra.host>localhost</tatami.cassandra.host>
<tatami.url>http://sandbox.tatamisoft.com</tatami.url>
<tatami.smtp.host>localhost</tatami.smtp.host>
<tatami.smtp.host>localhost</tatami.smtp.host>
<tatami.smtp.port>25</tatami.smtp.port>
<tatami.smtp.from>tatami@ippon.fr</tatami.smtp.from>
<tatami.wro4j.enabled>true</tatami.wro4j.enabled>
Expand Down Expand Up @@ -102,6 +103,67 @@
</plugins>
</build>
</profile>
<profile>
<id>docker</id>
<properties>
<!-- Spring profiles available : tatamibot, metrics, apple-push -->
<spring.profiles.active></spring.profiles.active>
<jetty.scanIntervalSeconds>0</jetty.scanIntervalSeconds>
<logback.loglevel>DEBUG</logback.loglevel>
<logback.appender>CONSOLE</logback.appender>
<logback.syslogHost>localhost</logback.syslogHost>
<logback.syslogHost.port>38143</logback.syslogHost.port>
<ehcache.maxBytesLocalHeap>512M</ehcache.maxBytesLocalHeap>
<tatami.url>http://localhost:8080</tatami.url>
<tatami.cassandra.host>cassandra</tatami.cassandra.host>
<tatami.ldapauth.url>ldap://10.55.0.4:389</tatami.ldapauth.url>
<tatami.smtp.host>localhost</tatami.smtp.host>
<tatami.smtp.port>25</tatami.smtp.port>
<tatami.smtp.from>tatami@ippon.fr</tatami.smtp.from>
<tatami.google.analytics.key></tatami.google.analytics.key>
<tatami.wro4j.enabled>true</tatami.wro4j.enabled>
<tatami.message.reloading.enabled>false</tatami.message.reloading.enabled>
<tatami.connection.security>any</tatami.connection.security>
<tatami.elasticsearch.engine.mode>embedded</tatami.elasticsearch.engine.mode>
<tatami.elasticsearch.path.data>/opt/tatami/data/elasticsearch</tatami.elasticsearch.path.data>
<tatami.elasticsearch.path.log>/opt/tatami/log/elasticsearch</tatami.elasticsearch.path.log>
<tatami.elasticsearch.http.enabled>false</tatami.elasticsearch.http.enabled>
<tatami.automatic.registration>false</tatami.automatic.registration>
<tatami.metrics.graphite.host></tatami.metrics.graphite.host>
<tatami.metrics.graphite.port>2003</tatami.metrics.graphite.port>
</properties>
<build>
<plugins>
<plugin>
<groupId>ro.isdc.wro4j</groupId>
<artifactId>wro4j-maven-plugin</artifactId>
<version>${maven.wro4j.version}</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<configuration>
<targetGroups>tatami-vendor,tatami-app,tatami-account,tatami-app-account</targetGroups>
<minimize>false</minimize>
<destinationFolder>${basedir}/src/main/webapp/WEB-INF/generated-wro4j</destinationFolder>
<contextFolder>${basedir}/src/main/webapp</contextFolder>
<ignoreMissingResources>false</ignoreMissingResources>
</configuration>
<dependencies>
<dependency>
<groupId>ro.isdc.wro4j</groupId>
<artifactId>wro4j-extensions</artifactId>
<version>${maven.wro4j.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>prod</id>
<properties>
Expand All @@ -115,6 +177,7 @@
<logback.syslogHost.port>38143</logback.syslogHost.port>
<ehcache.maxBytesLocalHeap>512M</ehcache.maxBytesLocalHeap>
<tatami.url>https://app.tatamisoft.com</tatami.url>
<tatami.cassandra.host>localhost</tatami.cassandra.host>
<tatami.ldapauth.url>ldap://10.55.0.4:389</tatami.ldapauth.url>
<tatami.smtp.host>localhost</tatami.smtp.host>
<tatami.smtp.port>25</tatami.smtp.port>
Expand Down Expand Up @@ -380,6 +443,7 @@
<ehcache.maxBytesLocalHeap>64M</ehcache.maxBytesLocalHeap>
<tatami.version>${project.version}</tatami.version>
<tatami.url>http://localhost:8080</tatami.url>
<tatami.cassandra.host>localhost</tatami.cassandra.host>
<tatami.ldapauth.url>ldap://directory:389</tatami.ldapauth.url>
<tatami.ldapauth.searchbase>dc=ippon,dc=fr</tatami.ldapauth.searchbase>
<tatami.ldapauth.searchfilter>(uid={0})</tatami.ldapauth.searchfilter>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/tatami/tatami.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down