forked from vert-x/vertx-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request vert-x#25 from vert-x3/docker-examples
Move the docker examples from the vert-stack to the vert-examples
- Loading branch information
Showing
23 changed files
with
693 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
= Vert.x Doker Examples | ||
|
||
Here you will find examples demonstrating how to run Vert.x applications in Docker container. To run these examples you need https://www.docker.com/[Docker] installed on your computer. More details about these examples are in the http://vert-x3.github.io/docs/vertx-docker/[Vert.x Docker Manual]. | ||
|
||
== vertx-docker-java | ||
|
||
This example deploys a Java verticle inside Docker. | ||
|
||
The link:vertx-docker-java | ||
|
||
To build and run it: | ||
---- | ||
docker build -t sample/vertx-java . | ||
docker run -t -i -p 8080:8080 sample/vertx-java | ||
---- | ||
|
||
== vertx-docker-javascript | ||
|
||
This example deploys a JavaScript verticle inside Docker. | ||
|
||
The link:vertx-docker-javascript | ||
|
||
To build and run it: | ||
---- | ||
docker build -t sample/vertx-javascript . | ||
docker run -t -i -p 8080:8080 sample/vertx-javascript | ||
---- | ||
|
||
== vertx-docker-groovy | ||
|
||
This example deploys a Groovy verticle inside Docker. | ||
|
||
The link:vertx-docker-groovy | ||
|
||
To build and run it: | ||
---- | ||
docker build -t sample/vertx-groovy . | ||
docker run -t -i -p 8080:8080 sample/vertx-groovy | ||
---- | ||
|
||
== vertx-docker-ruby | ||
|
||
This example deploys a Ruby verticle inside Docker. | ||
|
||
The link:vertx-docker-ruby | ||
|
||
To build and run it: | ||
---- | ||
docker build -t sample/vertx-ruby . | ||
docker run -t -i -p 8080:8080 sample/vertx-ruby | ||
---- | ||
|
||
== vertx-docker-example | ||
|
||
This example builds and deploys a Java verticle inside Docker using Apache Maven | ||
|
||
The link:vertx-docker-example | ||
|
||
To build and run it: | ||
---- | ||
mvn clean package | ||
docker run -t -i -p 8080:8080 vertx/vertx3-example | ||
---- | ||
|
||
== vertx-docker-example-fabric8 | ||
|
||
This example builds and deploys a Java verticle inside Docker and generate the medatadata required by Fabric8. | ||
|
||
The link:vertx-docker-example-fabric8 | ||
|
||
To build and run it: | ||
---- | ||
mvn clean package | ||
# Set $DOCKER_REGISTRY to poin on the Docker Registry provided by Fabric8 | ||
docker push $DOCKER_REGISTRY/vertx/vertx3-example-fabric8 | ||
mvn io.fabric8:fabric8-maven-plugin:2.1.4:apply | ||
---- | ||
|
||
== vertx-docker-java-fatjar | ||
|
||
This example deploys a Java verticle inside Docker. The verticle is packaged as a _fat jar_. | ||
|
||
The link:vertx-docker-java-fatjar | ||
|
||
To build and run it: | ||
---- | ||
docker build -t sample/vertx-java-fat . | ||
docker run -t -i -p 8080:8080 sample/vertx-java-fat | ||
---- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Vert.x Docker Example for Fabric8 | ||
|
||
This project builds a docker image launching a very simple Vert.x verticle that you can deploy using Fabric8 | ||
|
||
# Build the image | ||
|
||
To build the docker image, just launch: | ||
|
||
`mvn clean package` | ||
|
||
Notice that you need to have docker installed on your machine. | ||
|
||
# Deployment on Fabric8 | ||
|
||
The build creates the `kubernates.json` file with the required metadata. | ||
|
||
First, deploy the image on the Docker registry manage by fabric8: | ||
|
||
`docker push $DOCKER_REGISTRY/vertx/vertx3-example-fabric8` | ||
|
||
Then, apply it: | ||
|
||
`mvn io.fabric8:fabric8-maven-plugin:2.1.4:apply` | ||
|
||
That's all. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<groupId>io.vertx</groupId> | ||
<artifactId>vertx-examples</artifactId> | ||
<version>3.0.0-SNAPSHOT</version> | ||
<relativePath>../../pom.xml</relativePath> | ||
</parent> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>vertx-docker-example-fabric</artifactId> | ||
<name>Sample Docker Image for Fabric8</name> | ||
|
||
<properties> | ||
<!-- Metadata to generate the kubernates.json - ignore them if you don't plan to use kubernates / fabric8 --> | ||
<docker.image>vertx/vertx3-example-fabric8</docker.image> | ||
<fabric8.label.container>vert.x</fabric8.label.container> | ||
<fabric8.label.group>example</fabric8.label.group> | ||
<docker.port.container.http>8080</docker.port.container.http> | ||
</properties> | ||
|
||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.vertx</groupId> | ||
<artifactId>vertx-core</artifactId> | ||
<version>3.0.0-SNAPSHOT</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.1</version> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
</configuration> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>org.jolokia</groupId> | ||
<artifactId>docker-maven-plugin</artifactId> | ||
<version>0.11.5</version> | ||
<executions> | ||
<execution> | ||
<id>build</id> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>build</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<images> | ||
<image> | ||
<name>${docker.image}</name> | ||
<build> | ||
<from>vertx/vertx3</from> | ||
<tags> | ||
<tag>${project.version}</tag> | ||
</tags> | ||
<ports> | ||
<port>8080</port> | ||
</ports> | ||
<command>vertx run io.vertx.example.HelloWorldVerticle -cp | ||
/usr/verticles/${project.artifactId}-${project.version}.jar | ||
</command> | ||
<assembly> | ||
<mode>dir</mode> | ||
<basedir>/usr/verticles</basedir> | ||
<descriptor>assembly.xml</descriptor> | ||
</assembly> | ||
</build> | ||
</image> | ||
</images> | ||
</configuration> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>io.fabric8</groupId> | ||
<artifactId>fabric8-maven-plugin</artifactId> | ||
<version>2.1.4</version> | ||
<executions> | ||
<execution> | ||
<id>json</id> | ||
<phase>generate-resources</phase> | ||
<goals> | ||
<goal>json</goal> | ||
</goals> | ||
</execution> | ||
<execution> | ||
<id>attach</id> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>attach</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
|
||
<plugin> | ||
<artifactId>maven-deploy-plugin</artifactId> | ||
<configuration> | ||
<!-- should not be deployed --> | ||
<skip>true</skip> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
10 changes: 10 additions & 0 deletions
10
docker-examples/vertx-docker-example-fabric8/src/main/docker/assembly.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<assembly> | ||
<dependencySets> | ||
<dependencySet> | ||
<includes> | ||
<include>:${project.artifactId}</include> | ||
</includes> | ||
<outputDirectory>.</outputDirectory> | ||
</dependencySet> | ||
</dependencySets> | ||
</assembly> |
13 changes: 13 additions & 0 deletions
13
...mples/vertx-docker-example-fabric8/src/main/java/io/vertx/example/HelloWorldVerticle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package io.vertx.example; | ||
|
||
import io.vertx.core.AbstractVerticle; | ||
|
||
|
||
public class HelloWorldVerticle extends AbstractVerticle { | ||
|
||
@Override | ||
public void start() throws Exception { | ||
vertx.createHttpServer().requestHandler(req -> req.response().end("Hello World!")).listen(8080); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Vert.x Docker Example | ||
|
||
This project builds a docker image launching a very simple Vert.x verticle. | ||
|
||
# Build the image | ||
|
||
To build the docker image, just launch: | ||
|
||
`mvn clean package` | ||
|
||
Notice that you need to have docker installed on your machine. | ||
|
||
# Launching the image | ||
|
||
Just launch: | ||
|
||
`docker run -p 8080:8080 -i -t vertx/vertx3-example` | ||
|
||
You should get a `Hello World` message on `http://localhost:8080`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<groupId>io.vertx</groupId> | ||
<artifactId>vertx-examples</artifactId> | ||
<version>3.0.0-SNAPSHOT</version> | ||
<relativePath>../../pom.xml</relativePath> | ||
</parent> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>vertx-docker-example</artifactId> | ||
<name>Sample Docker Image with Maven</name> | ||
|
||
<properties> | ||
<docker.image>vertx/vertx3-example</docker.image> | ||
</properties> | ||
|
||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.vertx</groupId> | ||
<artifactId>vertx-core</artifactId> | ||
<version>3.0.0-SNAPSHOT</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.1</version> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
</configuration> | ||
</plugin> | ||
|
||
<plugin> | ||
<!-- | ||
This plugin builds the Docker image. It merges src/main/docker/Dockerfile with the resources set in the | ||
configuration. The resources should embed the current project and its dependencies. Here there is no | ||
dependencies. | ||
--> | ||
<groupId>com.spotify</groupId> | ||
<artifactId>docker-maven-plugin</artifactId> | ||
<version>0.2.8</version> | ||
<executions> | ||
<execution> | ||
<id>docker</id> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>build</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<dockerDirectory>${project.basedir}/src/main/docker</dockerDirectory> | ||
<imageName>${docker.image}</imageName> | ||
<resources> | ||
<resource> | ||
<targetPath>/verticles</targetPath> | ||
<directory>${project.build.directory}</directory> | ||
<includes> | ||
<include>${project.artifactId}-${project.version}.jar</include> | ||
</includes> | ||
</resource> | ||
</resources> | ||
</configuration> | ||
</plugin> | ||
|
||
<plugin> | ||
<artifactId>maven-deploy-plugin</artifactId> | ||
<configuration> | ||
<!-- should not be deployed --> | ||
<skip>true</skip> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
23 changes: 23 additions & 0 deletions
23
docker-examples/vertx-docker-example/src/main/docker/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# A simple example showing how the vertx image can be used. | ||
|
||
FROM vertx/vertx3 | ||
|
||
# Set the location of the verticles | ||
ENV VERTICLE_HOME /usr/verticles | ||
|
||
# Set the name of the verticle to deploy | ||
ENV VERTICLE_NAME io.vertx.example.HelloWorldVerticle | ||
|
||
# Set vertx option | ||
ENV VERTX_OPTIONS "" | ||
|
||
### | ||
# The rest of the file should be fine. | ||
### | ||
|
||
COPY ./verticles $VERTICLE_HOME | ||
|
||
# We use the "sh -c" to turn around https://github.com/docker/docker/issues/5509 - variable not expanded | ||
ENTRYPOINT ["sh", "-c"] | ||
CMD ["vertx run $VERTICLE_NAME -cp $VERTICLE_HOME/* $VERTX_OPTIONS"] | ||
|
12 changes: 12 additions & 0 deletions
12
docker-examples/vertx-docker-example/src/main/java/io/vertx/example/HelloWorldVerticle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package io.vertx.example; | ||
|
||
import io.vertx.core.AbstractVerticle; | ||
|
||
|
||
public class HelloWorldVerticle extends AbstractVerticle { | ||
|
||
@Override | ||
public void start() throws Exception { | ||
vertx.createHttpServer().requestHandler(req -> req.response().end("Hello World!")).listen(8080); | ||
} | ||
} |
Oops, something went wrong.