Cqrs example application
Test using http://petstore.swagger.io/ and replace the swagger.json with:
- http://APP_READ_HOST:APP_READ_PORT/api-docs/swagger.json
- http://APP_WRITE_HOST:APP_WRITE_PORT/api-docs/swagger.json
You can specify environment variables via .env file (sample file in main directory)
-
Application
VERSION= Version from build.sbt (0.1.0)APP_READ_HOST= Host address for read side application
APP_READ_PORT= TCP port for read side applicationELASTIC_PROTOCOL= Http or Https
ELASTIC_HOST= Host address for elasticsearch instance
ELASTIC_PORT= TCP port for elasticsearch instanceDB_USER= Mysql database username
DB_PASSWORD= Mysql database user password
DB_NAME= Mysql database name
DB_URL= Mysql database addressCLUSTER_READ_HOST= Host address for read module in akka cluster
CLUSTER_READ_PORT= TCP port for read module in akka clusterAPP_WRITE_HOST= Host address for write side application
APP_WRITE_PORT= TCP port for write side applicationCLUSTER_WRITE_HOST= Host address for write module in akka cluster
CLUSTER_WRITE_PORT= TCP port for write module in akka clusterCLUSTER_SEED_WRITE_ADDRESS= Full address for write module in akka cluster
CLUSTER_SEED_READ_ADDRESS= Full address for read module in akka cluster
sbt cqrs-write/run or/and sbt cqrs-read/run
- Publish Image
sbt docker
This publish image to local repository.
| REPOSITORY | TAG | IMAGE ID | CREATED | SIZE |
|---|---|---|---|---|
| com.example/cqrs-write | 0.1.0 | 6ab19ac09b90 | About a minute ago | 501MB |
| com.example/cqrs-read | 0.1.0 | d6c7c85c94f8 | About a minute ago | 504MB |
| openjdk | 8-jre | 66bf39162ea7 | About a minute ago | 443MB |
- Run Containers
docker-compose up
docker ps
| CONTAINER ID | IMAGE | PORTS | NAMES |
|---|---|---|---|
| 963dc10d6093 | com.example/cqrs-read:0.1.0 | 0.0.0.0:8160->8160/tcp | cqrs-example_cqrs.read_1 |
| 963dc10d6093 | com.example/cqrs-write:0.1.0 | 0.0.0.0:8170->8170/tcp | cqrs-example_cqrs.write_1 |
| 60202fa008bf | elasticsearch:latest | 0.0.0.0:9200->9200/tcp | cqrs-example_cqrs.mysql_1 |
| 60202fa008bf | mysql:5.7.22 | 0.0.0.0:3308->3306/tcp | cqrs-example_cqrs.elasticsearch_1 |