Skip to content

Commit

Permalink
Added missing Docker files to facilitate a basic docker-compose setup.
Browse files Browse the repository at this point in the history
Simplified Ruby code.
  • Loading branch information
Magnus de Pourbaix committed Feb 12, 2016
1 parent 9130056 commit 31b1f28
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 20 deletions.
12 changes: 12 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
frontend-js:
build: ./frontend-js
ports:
- "8080:8080"
news-server-groovy:
build: ./news-server-groovy
news-server-java:
build: ./news-server-java
news-server-js:
build: ./news-server-js
news-server-rb:
build: ./news-server-rb
2 changes: 1 addition & 1 deletion frontend-js/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ COPY target/$VERTICLE_FILE $VERTICLE_HOME/
# Launch the verticle
WORKDIR $VERTICLE_HOME
ENTRYPOINT ["sh", "-c"]
CMD ["java -jar $VERTICLE_FILE -cluster"]
CMD ["java -jar $VERTICLE_FILE -ha"]
1 change: 1 addition & 0 deletions frontend-js/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
<images>
<image>
<name>${docker.namespace}/${project.artifactId}:${project.version}</name>
<alias>${project.artifactId}</alias>
<build>
<from>java:8</from>
<tags>
Expand Down
2 changes: 1 addition & 1 deletion news-server-java/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ COPY target/$VERTICLE_FILE $VERTICLE_HOME/
# Launch the verticle
WORKDIR $VERTICLE_HOME
ENTRYPOINT ["sh", "-c"]
CMD ["java -jar $VERTICLE_FILE -cluster"]
CMD ["java -jar $VERTICLE_FILE -ha"]
3 changes: 2 additions & 1 deletion news-server-java/src/main/java/app/NewsServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public static void main(String... args) {
public void start(Future<Void> fut) {
EventBus eb = vertx.eventBus();
// Send a message every second
vertx.setPeriodic(1000, v -> eb.publish("news-feed", "Some news about JAVA!"));
System.out.println("Ready to send news from JAVA!");
vertx.setPeriodic(1000, v -> eb.publish("news-feed", "Some news from JAVA!"));
}
}
16 changes: 16 additions & 0 deletions news-server-js/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM java:8

ENV VERTICLE_FILE news-server-js-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 -ha"]
16 changes: 16 additions & 0 deletions news-server-rb/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM java:8

ENV VERTICLE_FILE news-server-rb-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 -ha"]
24 changes: 7 additions & 17 deletions news-server-rb/src/main/rb/app/news_server.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
require 'vertx/vertx'
options = {
'haEnabled' => true
}
Vertx::Vertx.clustered_vertx(options) { |res_err,res|
if (res_err == nil)
vertx = res
eventBus = vertx.event_bus()
puts "Ready to send news from Ruby!"
require "vertx/vertx"
include Vertx

# Send a message every second
vertx.set_periodic(1000) { |v|
eventBus.publish("news-feed", "Some news from Ruby!")
}
else
puts "Failed: #{res_err}"
end
}
puts("Ready to send news from Ruby!")
$vertx::set_periodic(1000) do
eventBus = $vertx.event_bus()
eventBus.publish("news-feed", "News from Ruby!")
end
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
<images>
<image>
<name>${docker.namespace}/${project.artifactId}:${project.version}</name>
<alias>${project.artifactId}</alias>
<build>
<from>java:8</from>
<tags>
Expand Down

0 comments on commit 31b1f28

Please sign in to comment.