Skip to content

Commit

Permalink
Merge pull request cer#26 from dartpopikyardo/master
Browse files Browse the repository at this point in the history
Сonverted all docker-compose files to use build: rather than volumes
  • Loading branch information
cer authored Oct 26, 2016
2 parents f750d9c + d168a8b commit 083047c
Show file tree
Hide file tree
Showing 17 changed files with 69 additions and 72 deletions.
22 changes: 13 additions & 9 deletions _build-and-test-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

set -e

if [ -z "$DOCKER_HOST_IP" ] ; then
if [ -z "$DOCKER_HOST" ] ; then
export DOCKER_HOST_IP=`hostname`
else
echo using ${DOCKER_HOST?}
XX=${DOCKER_HOST%\:*}
export DOCKER_HOST_IP=${XX#tcp\:\/\/}
fi
echo set DOCKER_HOST_IP $DOCKER_HOST_IP
fi

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

DOCKER_COMPOSE="docker-compose -p event-sourcing-examples"
Expand All @@ -28,14 +39,6 @@ fi

${DOCKER_COMPOSE?} up -d mongodb $EXTRA_INFRASTRUCTURE_SERVICES

if [ -z "$DOCKER_HOST_IP" ] ; then
if which docker-machine >/dev/null; then
export DOCKER_HOST_IP=$(docker-machine ip default)
else
export DOCKER_HOST_IP=localhost
fi
echo set DOCKER_HOST_IP $DOCKER_HOST_IP
fi

if [ -z "$SPRING_DATA_MONGODB_URI" ] ; then
export SPRING_DATA_MONGODB_URI=mongodb://${DOCKER_HOST_IP?}/mydb
Expand All @@ -46,11 +49,12 @@ export SERVICE_HOST=$DOCKER_HOST_IP

./gradlew $* build -x :e2e-test:test

if [ -z "$EVENTUATE_API_KEY_ID" -o -z "$EVENTUATE_API_KEY_SECRET" ] ; then
if [ -z "$EVENTUATE_LOCAL" ] && [ -z "$EVENTUATE_API_KEY_ID" -o -z "$EVENTUATE_API_KEY_SECRET" ] ; then
echo You must set EVENTUATE_API_KEY_ID and EVENTUATE_API_KEY_SECRET
exit -1
fi

${DOCKER_COMPOSE?} build

${DOCKER_COMPOSE?} up -d

Expand Down
4 changes: 4 additions & 0 deletions java-spring/accounts-command-side-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM java:openjdk-8u91-jdk
CMD java ${JAVA_OPTS} -jar accounts-command-side-service.jar
EXPOSE 8080
COPY build/libs/accounts-command-side-service.jar .
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.chrisrichardson.eventstore.javaexamples.banking.backend.queryside.accounts;

import com.mongodb.WriteResult;
import io.eventuate.Int128;
import net.chrisrichardson.eventstore.javaexamples.banking.common.accounts.AccountChangeInfo;
import net.chrisrichardson.eventstore.javaexamples.banking.common.accounts.AccountTransactionInfo;
import net.chrisrichardson.eventstore.javaexamples.banking.common.transactions.TransferState;
Expand Down Expand Up @@ -29,7 +30,7 @@ public AccountInfoUpdateService(AccountInfoRepository accountInfoRepository, Mon
}


public void create(String accountId, String customerId, String title, BigDecimal initialBalance, String description, String version) {
public void create(String accountId, String customerId, String title, BigDecimal initialBalance, String description, Int128 version) {
try {
AccountChangeInfo ci = new AccountChangeInfo();
ci.setAmount(toIntegerRepr(initialBalance));
Expand All @@ -40,8 +41,8 @@ public void create(String accountId, String customerId, String title, BigDecimal
.set("description", description)
.set("balance", toIntegerRepr(initialBalance))
.push("changes", ci)
.set("creationDate", getFromEventId(version))
.set("version", version),
.set("creationDate", new Date(version.getHi()))
.set("version", version.asString()),
AccountInfo.class);
logger.info("Saved in mongo");

Expand Down Expand Up @@ -81,12 +82,4 @@ public void updateTransactionStatus(String accountId, String transactionId, Tran
set("transactions." + transactionId + ".status", status),
AccountInfo.class);
}

private Date getFromEventId(String eventId) {
String[] s = eventId.split("-");
if (s.length != 2) {
return new Date();
}
return new Date(Long.parseUnsignedLong(s[0], 16));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import io.eventuate.DispatchedEvent;
import io.eventuate.EventHandlerMethod;
import io.eventuate.EventSubscriber;
import io.eventuate.Int128;
import net.chrisrichardson.eventstore.javaexamples.banking.backend.common.accounts.*;
import net.chrisrichardson.eventstore.javaexamples.banking.backend.common.transactions.CreditRecordedEvent;
import net.chrisrichardson.eventstore.javaexamples.banking.backend.common.transactions.DebitRecordedEvent;
Expand Down Expand Up @@ -34,7 +35,7 @@ public AccountQueryWorkflow(AccountInfoUpdateService accountInfoUpdateService) {
public void create(DispatchedEvent<AccountOpenedEvent> de) {
AccountOpenedEvent event = de.getEvent();
String id = de.getEntityId();
String eventId = de.getEventId().asString();
Int128 eventId = de.getEventId();
logger.info("**************** account version=" + id + ", " + eventId);
BigDecimal initialBalance = event.getInitialBalance();

Expand All @@ -57,8 +58,8 @@ public void recordTransfer(DispatchedEvent<MoneyTransferCreatedEvent> de) {
String moneyTransferId = de.getEntityId();
String fromAccountId = de.getEvent().getDetails().getFromAccountId();
String toAccountId = de.getEvent().getDetails().getToAccountId();
logger.info("**************** account version=" + fromAccountId + ", " + de.getEventId().asString());
logger.info("**************** account version=" + toAccountId + ", " + de.getEventId().asString());
logger.info("**************** account version=" + fromAccountId + ", " + eventId);
logger.info("**************** account version=" + toAccountId + ", " + eventId);

AccountTransactionInfo ti = new AccountTransactionInfo(moneyTransferId,
fromAccountId,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.chrisrichardson.eventstore.javaexamples.banking.backend.queryside.accounts;

import io.eventuate.Int128;
import io.eventuate.javaclient.spring.jdbc.EventuateJdbcEventStoreConfiguration;
import io.eventuate.javaclient.spring.jdbc.IdGenerator;
import io.eventuate.javaclient.spring.jdbc.IdGeneratorImpl;
Expand Down Expand Up @@ -46,7 +47,7 @@ public void shouldSaveAccountInfo() throws ExecutionException, InterruptedExcept
IdGenerator x = new IdGeneratorImpl();
String accountId = x.genId().asString();
String customerId = x.genId().asString();
String version = x.genId().asString();
Int128 version = x.genId();

String title = "Checking account";
BigDecimal initialBalance = new BigDecimal("1345");
Expand All @@ -63,7 +64,7 @@ public void shouldSaveAccountInfo() throws ExecutionException, InterruptedExcept
assertEquals(initialBalance.longValue() * 100, accountInfo.getBalance());
assertEquals(1, accountInfo.getChanges().size());
assertTrue(accountInfo.getTransactions().isEmpty());
assertEquals(version, accountInfo.getVersion());
assertEquals(version.asString(), accountInfo.getVersion());


String changeId = x.genId().asString();
Expand Down Expand Up @@ -99,7 +100,7 @@ public void shouldHandleDuplicateSaveAccountInfo() throws ExecutionException, In
IdGenerator x = new IdGeneratorImpl();
String accountId = x.genId().asString();
String customerId = x.genId().asString();
String version = x.genId().asString();
Int128 version = x.genId();

String title = "Checking account";
BigDecimal initialBalance = new BigDecimal("1345");
Expand All @@ -114,7 +115,7 @@ public void shouldUpdateTransactionStatus() {
IdGenerator x = new IdGeneratorImpl();
String accountId = x.genId().asString();
String customerId = x.genId().asString();
String version = x.genId().asString();
Int128 version = x.genId();

String title = "Checking account";
BigDecimal initialBalance = new BigDecimal("1345");
Expand Down
4 changes: 4 additions & 0 deletions java-spring/accounts-query-side-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM java:openjdk-8u91-jdk
CMD java ${JAVA_OPTS} -jar accounts-query-side-service.jar
EXPOSE 8080
COPY build/libs/accounts-query-side-service.jar .
4 changes: 4 additions & 0 deletions java-spring/api-gateway-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM java:openjdk-8u91-jdk
CMD java ${JAVA_OPTS} -jar api-gateway-service.jar
EXPOSE 8080
COPY build/libs/api-gateway-service.jar .
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<logger name="net.chrisrichardson.eventstore.javaexamples.banking" level='info'>
</logger>

<logger name="io.eventuate" level='debug'>
<logger name="io.eventuate.activity" level='debug'>
</logger>

</configuration>
3 changes: 2 additions & 1 deletion java-spring/build-and-test-all-eventuate-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

export JAVA_OPTS="-Xmx128m -Xms128m"
export EXTRA_INFRASTRUCTURE_SERVICES=cdcservice
../_build-and-test-all.sh -f docker-compose-eventuate-local.yml -P eventuateDriver=local $*
export EVENTUATE_LOCAL=yes
../_build-and-test-all.sh -f docker-compose-eventuate-local.yml $* -P eventuateDriver=local
2 changes: 1 addition & 1 deletion java-spring/common-backend/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<logger name="org.springframework" level='info'>
</logger>

<logger name="io.eventuate" level='debug'>
<logger name="io.eventuate.activity" level='debug'>
</logger>

</configuration>
4 changes: 4 additions & 0 deletions java-spring/customers-command-side-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM java:openjdk-8u91-jdk
CMD java ${JAVA_OPTS} -jar customers-command-side-service.jar
EXPOSE 8080
COPY build/libs/customers-command-side-service.jar .
4 changes: 4 additions & 0 deletions java-spring/customers-query-side-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM java:openjdk-8u91-jdk
CMD java ${JAVA_OPTS} -jar customers-query-side-service.jar
EXPOSE 8080
COPY build/libs/customers-query-side-service.jar .
28 changes: 14 additions & 14 deletions java-spring/docker-compose-common.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
apigateway:
image: java:openjdk-8u91-jdk
command: java ${JAVA_OPTS} -jar /app/api-gateway-service.jar --accounts.commandside.service.host=accountscommandside --transfers.commandside.service.host=transactionscommandside --accounts.queryside.service.host=accountsqueryside --customers.commandside.service.host=customerscommandside --customers.queryside.service.host=customersqueryside
environment:
SPRING_DATA_MONGODB_URI: mongodb://mongodb/mydb
build: ./api-gateway-service/
ports:
- "8080:8080"
environment:
SPRING_DATA_MONGODB_URI: mongodb://mongodb/mydb
ACCOUNTS_COMMANDSIDE_SERVICE_HOST: accountscommandside
TRANSFERS_COMMANDSIDE_SERVICE_HOST: transactionscommandside
ACCOUNTS_QUERYSIDE_SERVICE_HOST: accountsqueryside
CUSTOMERS_COMMANDSIDE_SERVICE_HOST: customerscommandside
CUSTOMERS_QUERYSIDE_SERVICE_HOST: customersqueryside


accountscommandside:
image: java:openjdk-8u91-jdk
command: java ${JAVA_OPTS} -jar /app/accounts-command-side-service.jar
build: ./accounts-command-side-service/
ports:
- "8085:8080"

transactionscommandside:
image: java:openjdk-8u91-jdk
command: java ${JAVA_OPTS} -jar /app/transactions-command-side-service.jar
build: ./transactions-command-side-service/
ports:
- "8082:8080"

accountsqueryside:
image: java:openjdk-8u91-jdk
command: java ${JAVA_OPTS} -jar /app/accounts-query-side-service.jar
build: ./accounts-query-side-service/
environment:
SPRING_DATA_MONGODB_URI: mongodb://mongodb/mydb
ports:
- "8081:8080"

customerscommandside:
image: java:openjdk-8u91-jdk
command: java ${JAVA_OPTS} -jar /app/customers-command-side-service.jar
build: ./customers-command-side-service/
ports:
- "8083:8080"

customersqueryside:
image: java:openjdk-8u91-jdk
command: java ${JAVA_OPTS} -jar /app/customers-query-side-service.jar
build: ./customers-query-side-service/
ports:
- "8084:8080"
environment:
Expand Down
14 changes: 0 additions & 14 deletions java-spring/docker-compose-eventuate-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ apigateway:
extends:
file: docker-compose-common.yml
service: apigateway
volumes:
- ./api-gateway-service/build/libs:/app
links:
- accountscommandside
- transactionscommandside
Expand All @@ -68,8 +66,6 @@ accountscommandside:
extends:
file: docker-compose-common.yml
service: accountscommandside
volumes:
- ./accounts-command-side-service/build/libs:/app
links:
- mysql
- kafka
Expand All @@ -89,8 +85,6 @@ transactionscommandside:
extends:
file: docker-compose-common.yml
service: transactionscommandside
volumes:
- ./transactions-command-side-service/build/libs:/app
links:
- mysql
- kafka
Expand All @@ -105,14 +99,10 @@ transactionscommandside:
EVENTUATELOCAL_CDC_DB_USER_NAME: root
EVENTUATELOCAL_CDC_DB_PASSWORD: rootpassword



accountsqueryside:
extends:
file: docker-compose-common.yml
service: accountsqueryside
volumes:
- ./accounts-query-side-service/build/libs:/app
links:
- mongodb
- mysql
Expand All @@ -134,8 +124,6 @@ customerscommandside:
extends:
file: docker-compose-common.yml
service: customerscommandside
volumes:
- ./customers-command-side-service/build/libs:/app
links:
- mysql
- kafka
Expand All @@ -154,8 +142,6 @@ customersqueryside:
extends:
file: docker-compose-common.yml
service: customersqueryside
volumes:
- ./customers-query-side-service/build/libs:/app
links:
- mongodb
- mysql
Expand Down
13 changes: 0 additions & 13 deletions java-spring/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ apigateway:
extends:
file: docker-compose-common.yml
service: apigateway
volumes:
- ./api-gateway-service/build/libs:/app
links:
- accountscommandside
- transactionscommandside
Expand All @@ -16,8 +14,6 @@ accountscommandside:
extends:
file: docker-compose-common.yml
service: accountscommandside
volumes:
- ./accounts-command-side-service/build/libs:/app
environment:
EVENTUATE_API_KEY_ID: ${EVENTUATE_API_KEY_ID}
EVENTUATE_API_KEY_SECRET: ${EVENTUATE_API_KEY_SECRET}
Expand All @@ -26,8 +22,6 @@ transactionscommandside:
extends:
file: docker-compose-common.yml
service: transactionscommandside
volumes:
- ./transactions-command-side-service/build/libs:/app
environment:
EVENTUATE_API_KEY_ID: ${EVENTUATE_API_KEY_ID}
EVENTUATE_API_KEY_SECRET: ${EVENTUATE_API_KEY_SECRET}
Expand All @@ -37,8 +31,6 @@ accountsqueryside:
extends:
file: docker-compose-common.yml
service: accountsqueryside
volumes:
- ./accounts-query-side-service/build/libs:/app
links:
- mongodb
environment:
Expand All @@ -49,8 +41,6 @@ customerscommandside:
extends:
file: docker-compose-common.yml
service: customerscommandside
volumes:
- ./customers-command-side-service/build/libs:/app
environment:
EVENTUATE_API_KEY_ID: ${EVENTUATE_API_KEY_ID}
EVENTUATE_API_KEY_SECRET: ${EVENTUATE_API_KEY_SECRET}
Expand All @@ -59,9 +49,6 @@ customersqueryside:
extends:
file: docker-compose-common.yml
service: customersqueryside
image: java:openjdk-8u91-jdk
volumes:
- ./customers-query-side-service/build/libs:/app
links:
- mongodb
environment:
Expand Down
2 changes: 1 addition & 1 deletion java-spring/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ eventuateMavenRepoUrl=http://mavenrepo.eventuate.io/release

springBootVersion=1.3.5.RELEASE

eventuateClientVersion=0.10.0.RELEASE
eventuateClientVersion=0.12.0.RELEASE
eventuateLocalVersion=0.4.0.RELEASE
4 changes: 4 additions & 0 deletions java-spring/transactions-command-side-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM java:openjdk-8u91-jdk
CMD java ${JAVA_OPTS} -jar transactions-command-side-service.jar
EXPOSE 8080
COPY build/libs/transactions-command-side-service.jar .

0 comments on commit 083047c

Please sign in to comment.