This application is a rewrite of https://github.com/dockersamples/example-voting-app We only use Java Vertx framework. In next releases, we will introduce other langages as Kotlin, Ceylon or JS. At this day, it is a nice proof-of-concept with the awesome Vertx.
Download Docker. If you are on Mac or Windows, Docker Compose will be automatically installed. On Linux, make sure you have the latest version of Compose. Original post comes from there. We rewrote it with VertX.
Build the images in this directory:
mvn clean package docker:build
You should have a similar result with docker images
:
✘ nicolas@MacBook > ~/software/vertx/vertx-voting-app > master > docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
vertxswarm/verticle-result 1.0-SNAPSHOT ebeb1bb53f78 22 minutes ago 450 MB
vertxswarm/verticle-result 1.0-SNAPSHOT.27015db ebeb1bb53f78 22 minutes ago 450 MB
vertxswarm/verticle-result latest ebeb1bb53f78 22 minutes ago 450 MB
vertxswarm/verticle-worker 1.0-SNAPSHOT fb702b8f68cf 40 minutes ago 440 MB
vertxswarm/verticle-worker 1.0-SNAPSHOT.27015db fb702b8f68cf 40 minutes ago 440 MB
vertxswarm/verticle-worker latest fb702b8f68cf 40 minutes ago 440 MB
vertxswarm/verticle-vote 1.0-SNAPSHOT 4b7a5532ba97 40 minutes ago 438 MB
vertxswarm/verticle-vote 1.0-SNAPSHOT.27015db 4b7a5532ba97 40 minutes ago 438 MB
vertxswarm/verticle-vote latest 4b7a5532ba97 40 minutes ago 438 MB
Run in this directory:
docker-compose up
The app will be running at:
You can use too if you update your /etc/hosts
Alternately, if you want to run it on a Docker Swarm, first make sure you have a swarm. If you don't, run:
Follow this guide to provision a local but complete environment with tutorial Local Docker Swarm.
You can directly use the Shell script
docker-machine create --driver virtualbox poc-manager
docker-machine ssh poc-manager "docker swarm init --advertise-addr $(docker-machine ip poc-manager)"
docker-machine create --driver virtualbox poc-worker1
docker-machine create --driver virtualbox poc-worker2
docker-machine ssh poc-worker1 "docker swarm join --token `docker $(docker-machine config poc-manager) swarm join-token worker -q` $(docker-machine ip poc-manager)"
docker-machine ssh poc-worker2 "docker swarm join --token `docker $(docker-machine config poc-manager) swarm join-token worker -q` $(docker-machine ip poc-manager)"
Once you have your swarm, in this directory run:
docker stack deploy --compose-file docker-stack.yml demo
- A verticle webapp which lets you vote between two options
- A Redis queue which collects new votes
- A verticle worker which consumes votes and stores them in…
- A Postgres database backed by a Docker volume
- A verticle webapp which shows the results of the voting in real time
We choose to use these Maven plugin :
For Verticle vote
For Verticle worker
For Verticle result
In a near future, we will update too :
The voting application only accepts one vote per client. It does not register votes if a vote has already been submitted from a client.
Greetings to:
- Vertx team
- Guillaume Borg (from Treeptik)