Skip to content

Commit

Permalink
Merge pull request #5 from Lorkster/master
Browse files Browse the repository at this point in the history
Merging from master
  • Loading branch information
Lorkster committed Feb 9, 2016
2 parents 6bcdcd6 + 0050605 commit e968042
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 8 deletions.
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,24 @@
# Easiest running of examples
* Run: `mvn package`
* Run the *-fat.jar for each respective module, for example:
`java -jar java -jar target/news-server-rb-1.0-SNAPSHOT-fat.jar -cp target/classes -cluster`
`java -jar target/news-server-rb-1.0-SNAPSHOT-fat.jar -cp target/classes -cluster`

# Docker Maven
# Docker:

* Running the Docker container locally might compromise your network interfaces and making the normal `java -jar xxx -cluster`
usage not work. Just a heads up.


## Docker Maven
* `mvn clean package` in project root or any module, or `mvn docker:build` in any module (still needs `mvn package`to have been run).
* For each module you want to deploy in Docker run: `mvn docker:start`
* To stop, simply do `mvn docker:stop` in the same module.
* Alternatively you can use the Docker command line and start with:
* `docker run -t -i -p 8080:8080 vertxdemo/frontend-js:1.0-SNAPSHOT`
* `docker run -t -i vertxdemo/news-server-java:1.0-SNAPSHOT`
* Check your Docker container for it's ip and access frontend at that address i.e. <http://xxx.xxx.xxx.xxx:8080>.

# Docker Command Line
## Docker Command Line
* Currently hardcoded to a specific version of the fat jar, check in `Dockerfile`.
* Install Docker... <https://www.docker.com/products/docker-toolbox>
* Build by moving the each respective module and execute for example `docker build -t vertxdemo/frontend-js .`
Expand Down
4 changes: 2 additions & 2 deletions frontend-js/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<configuration>
<images>
<image>
<name>vertxdemo/${project.artifactId}:${project.version}</name>
<name>${docker.namespace}/${project.artifactId}:${project.version}</name>
<build>
<from>java:8</from>
<tags>
Expand All @@ -71,7 +71,7 @@
</assembly>
</build>
<run>
<cmd>java -jar /opt/vertx/${project.artifactId}-${project.version}-fat.jar -cluster</cmd>
<cmd>java -jar /opt/vertx/${project.artifactId}-${project.version}-fat.jar -ha</cmd>
<ports>
<port>8080:8080</port>
</ports>
Expand Down
16 changes: 16 additions & 0 deletions news-server-groovy/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM java:8

ENV VERTICLE_FILE news-server-groovy-1.0-SNAPSHOT-fat.jar

# Set the location of the verticles
ENV VERTICLE_HOME /usr/verticles

#EXPOSE 8080

# Copy your fat jar to the container
COPY target/$VERTICLE_FILE $VERTICLE_HOME/

# Launch the verticle
WORKDIR $VERTICLE_HOME
ENTRYPOINT ["sh", "-c"]
CMD ["java -jar $VERTICLE_FILE -cluster"]
4 changes: 4 additions & 0 deletions news-server-groovy/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jolokia</groupId>
<artifactId>docker-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

Expand Down
11 changes: 11 additions & 0 deletions news-server-groovy/src/main/docker/assembly.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<assembly>
<fileSets>
<fileSet>
<directory>${project.build.directory}</directory>
<includes>
<include>${project.artifactId}-${project.version}-fat.jar</include>
</includes>
<outputDirectory>.</outputDirectory>
</fileSet>
</fileSets>
</assembly>
2 changes: 1 addition & 1 deletion news-server-groovy/src/main/groovy/app/NewsServer.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import util.Runner
class NewsServer extends AbstractVerticle{

public static void main (String... args){
Runner.runClusteredExample(NewsServer.class)
Runner.runHaExample(NewsServer.class)
}

@Override
Expand Down
1 change: 1 addition & 0 deletions news-server-rb/src/main/rb/app/news_server.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'vertx/vertx'
options = {
'haEnabled' => true
}
Vertx::Vertx.clustered_vertx(options) { |res_err,res|
if (res_err == nil)
Expand Down
5 changes: 3 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<version>1.0-SNAPSHOT</version>
<properties>
<vertx.version>3.2.0</vertx.version>
<docker.namespace>vertxdemo</docker.namespace>
<!-- must be set in each sub-project -->
<main.verticle/>
</properties>
Expand Down Expand Up @@ -112,7 +113,7 @@
<configuration>
<images>
<image>
<name>vertxdemo/${project.artifactId}:${project.version}</name>
<name>${docker.namespace}/${project.artifactId}:${project.version}</name>
<build>
<from>java:8</from>
<tags>
Expand All @@ -135,7 +136,7 @@
</assembly>
</build>
<run>
<cmd>java -jar /opt/vertx/${project.artifactId}-${project.version}-fat.jar -cluster</cmd>
<cmd>java -jar /opt/vertx/${project.artifactId}-${project.version}-fat.jar -ha</cmd>
</run>
</image>
</images>
Expand Down

0 comments on commit e968042

Please sign in to comment.