Skip to content

Commit

Permalink
Merge pull request eventuate-tram#41 from dartartem/development
Browse files Browse the repository at this point in the history
Added development container.
  • Loading branch information
cer authored May 20, 2020
2 parents 94c7567 + 896d500 commit e08a70d
Show file tree
Hide file tree
Showing 28 changed files with 204 additions and 45 deletions.
5 changes: 2 additions & 3 deletions _build-and-test-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
set -e

dockerall="./gradlew ${DATABASE?}${MODE?}Compose"
dockercdc="./gradlew ${DATABASE?}${MODE?}cdcCompose"
dockerinfrastructure="./gradlew ${DATABASE?}${MODE?}infrastructureCompose"

./gradlew testClasses

${dockerall}Down
${dockercdc}Build
${dockercdc}Up
${dockerinfrastructure}Up

./gradlew -x :end-to-end-tests:test -x :snapshot-tests:test build

Expand Down
4 changes: 2 additions & 2 deletions build-and-test-snapshots.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
set -e

dockerall="./gradlew mysqlbinlogCompose"
dockercdc="./gradlew mysqlbinlogcdcCompose"
dockerinfrastructure="./gradlew mysqlbinloginfrastructureCompose"
dockertextsearch="./gradlew mysqlbinlogwithorderhistorytextsearchserviceCompose"

${dockertextsearch}Down
${dockerall}Down
${dockercdc}Up
${dockerinfrastructure}Up

./gradlew assemble

Expand Down
35 changes: 29 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ apply plugin: 'docker-compose'
subprojects {

apply plugin: "java"
sourceCompatibility = 8
targetCompatibility = 8

sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
mavenCentral()
Expand Down Expand Up @@ -51,18 +52,18 @@ dockerCompose {
startedServices = ["elasticsearch", "orderhistorytextsearchservice"]
}

mysqlbinlogcdc {
mysqlbinloginfrastructure {
projectName = null
useComposeFiles = ["docker-compose-mysql-binlog.yml"]
startedServices = ["cdcservice"]
startedServices = ["cdcservice", "zipkin"]
}

postgrespolling {
projectName = null
useComposeFiles = ["docker-compose-postgres-polling.yml"]
}

postgrespollingcdc {
postgrespollinginfrastructure {
projectName = null
useComposeFiles = ["docker-compose-postgres-polling.yml"]
startedServices = ["cdcservice"]
Expand All @@ -73,9 +74,31 @@ dockerCompose {
useComposeFiles = ["docker-compose-postgres-wal.yml"]
}

postgreswalcdc {
postgreswalinfrastructure {
projectName = null
useComposeFiles = ["docker-compose-postgres-wal.yml"]
startedServices = ["cdcservice"]
}

javaDevelopment {
projectName = null
useComposeFiles = ["docker-compose-java-development.yml"]
}
}

task prepareJavaDevelopmentDockerImage(type:Exec) {
commandLine './prepare-java-development-docker-image.sh'
}

javaDevelopmentComposeBuild.dependsOn(prepareJavaDevelopmentDockerImage)

task buildAndStartServicesMySqlBinlog(type: GradleBuild) {
List<String> t = []

t.add("javaDevelopmentComposeBuild")
t.add("mysqlbinloginfrastructureComposeUp")
t.addAll(subprojects.collect { it.name }.collect { ":" + it + ":assemble" })
t.add("mysqlbinlogComposeUp")

tasks = t
}
29 changes: 29 additions & 0 deletions buildSrc/src/main/groovy/ServicePlugin.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import org.gradle.api.Plugin
import org.gradle.api.Project

class ServicePlugin implements Plugin<Project> {

@Override
void apply(Project project) {

project.apply(plugin: 'org.springframework.boot')
project.apply(plugin: "io.spring.dependency-management")

project.dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-sleuth:${project.ext.springCloudSleuthVersion}"
}
}


project.dependencies {

compile 'org.springframework.cloud:spring-cloud-starter-sleuth'
compile 'org.springframework.cloud:spring-cloud-starter-zipkin'
compile 'io.zipkin.brave:brave-bom:4.17.1'

compile "io.eventuate.tram.core:eventuate-tram-spring-cloud-sleuth-integration:${project.ext.eventuateTramVersion}"
}

}
}
4 changes: 2 additions & 2 deletions customer-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM openjdk:14-jdk-alpine3.10
RUN apk --no-cache add curl
FROM openjdk:8u252-slim-buster
RUN apt-get update && apt-get install -y curl
HEALTHCHECK --start-period=30s --interval=5s CMD curl -f http://localhost:8080/actuator/health || exit 1
CMD java ${JAVA_OPTS} -jar customer-service-*.jar
COPY build/libs/customer-service-*.jar .
4 changes: 2 additions & 2 deletions customer-service/Dockerfile-maven
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM openjdk:14-jdk-alpine3.10
RUN apk --no-cache add curl
FROM openjdk:8u252-slim-buster
RUN apt-get update && apt-get install -y curl
HEALTHCHECK --start-period=30s --interval=5s CMD curl -f http://localhost:8080/actuator/health || exit 1
CMD java ${JAVA_OPTS} -jar customer-service-0.1.0-SNAPSHOT.jar
COPY ./target/customer-service-0.1.0-SNAPSHOT.jar .
Expand Down
7 changes: 3 additions & 4 deletions customer-service/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
apply plugin: ServicePlugin

dependencies {
compile project(":common-swagger")
compile project(":customer-backend")
Expand All @@ -6,7 +8,4 @@ dependencies {
compile "org.springframework.boot:spring-boot-starter"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.boot:spring-boot-starter-web"
}

apply plugin: 'org.springframework.boot'
apply plugin: "io.spring.dependency-management"
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@
import io.eventuate.examples.tram.ordersandcustomers.customers.domain.Customer;
import io.eventuate.examples.tram.ordersandcustomers.customers.service.CustomerService;
import io.eventuate.tram.viewsupport.rebuild.DomainSnapshotExportService;
import io.eventuate.tram.viewsupport.rebuild.TopicPartitionOffset;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class CustomerController {

Expand All @@ -29,6 +26,7 @@ public CustomerController(CustomerService customerService,
this.domainSnapshotExportService = domainSnapshotExportService;
}


@RequestMapping(value = "/customers", method = RequestMethod.POST)
public CreateCustomerResponse createCustomer(@RequestBody CreateCustomerRequest createCustomerRequest) {
Customer customer = customerService.createCustomer(createCustomerRequest.getName(), createCustomerRequest.getCreditLimit());
Expand Down
4 changes: 4 additions & 0 deletions customer-service/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ spring.datasource.username=mysqluser
spring.datasource.password=mysqlpw
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
cdc.service.url: http://localhost:8099

spring.sleuth.enabled=true
spring.sleuth.sampler.probability=1
spring.zipkin.base.url=http://${DOCKER_HOST_IP:localhost}:9411/
6 changes: 6 additions & 0 deletions docker-compose-java-development.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: '3'
services:

java-development:
build: ./java-development
image: eventuateio/eventuate-tram-examples-customers-and-orders-java-development:${DOCKER_IMAGE_TAG:-latest}
30 changes: 30 additions & 0 deletions docker-compose-mysql-binlog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ services:
EVENTUATELOCAL_KAFKA_BOOTSTRAP_SERVERS: kafka:29092
EVENTUATELOCAL_ZOOKEEPER_CONNECTION_STRING: zookeeper:2181
CDC_SERVICE_URL: http://cdcservice:8080
SPRING_SLEUTH_ENABLED: "true"
SPRING_SLEUTH_SAMPLER_PROBABILITY: 1
SPRING_ZIPKIN_BASE_URL: http://zipkin:9411/

customerservice:
build:
Expand All @@ -39,6 +42,9 @@ services:
EVENTUATELOCAL_KAFKA_BOOTSTRAP_SERVERS: kafka:29092
EVENTUATELOCAL_ZOOKEEPER_CONNECTION_STRING: zookeeper:2181
CDC_SERVICE_URL: http://cdcservice:8080
SPRING_SLEUTH_ENABLED: "true"
SPRING_SLEUTH_SAMPLER_PROBABILITY: 1
SPRING_ZIPKIN_BASE_URL: http://zipkin:9411/

orderhistoryservice:
build:
Expand All @@ -55,6 +61,9 @@ services:
SPRING_DATA_MONGODB_URI: mongodb://mongodb/customers_and_orders
EVENTUATELOCAL_KAFKA_BOOTSTRAP_SERVERS: kafka:29092
EVENTUATELOCAL_ZOOKEEPER_CONNECTION_STRING: zookeeper:2181
SPRING_SLEUTH_ENABLED: "true"
SPRING_SLEUTH_SAMPLER_PROBABILITY: 1
SPRING_ZIPKIN_BASE_URL: http://zipkin:9411/

zookeeper:
image: confluentinc/cp-zookeeper:5.2.4
Expand Down Expand Up @@ -117,3 +126,24 @@ services:
EVENTUATELOCAL_CDC_MYSQL_BINLOG_CLIENT_UNIQUE_ID: 1234567890
EVENTUATELOCAL_CDC_READ_OLD_DEBEZIUM_DB_OFFSET_STORAGE_TOPIC: "false"
EVENTUATE_CDC_KAFKA_ENABLE_BATCH_PROCESSING: ${EVENTUATE_CDC_KAFKA_ENABLE_BATCH_PROCESSING}

java-development:
image: eventuateio/eventuate-tram-examples-customers-and-orders-java-development:latest
volumes:
- .:/development
- /var/run/docker.sock:/var/run/docker.sock
environment:
SPRING_DATASOURCE_URL: jdbc:mysql://mysql/eventuate
SPRING_DATASOURCE_USERNAME: mysqluser
SPRING_DATASOURCE_PASSWORD: mysqlpw
SPRING_DATASOURCE_DRIVER_CLASS_NAME: com.mysql.jdbc.Driver
SPRING_SLEUTH_ENABLED: "true"
SPRING_SLEUTH_SAMPLER_PROBABILITY: 1
SPRING_ZIPKIN_BASE_URL: http://zipkin:9411/

zipkin:
image: openzipkin/zipkin:2.21
ports:
- "9411:9411"
environment:
JAVA_OPTS: -Xmx128m
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ deployUrl=file:///Users/cer/.m2/testdeploy
eventuateMavenRepoUrl=https://dl.bintray.com/eventuateio-oss/eventuate-maven-release/,file:///Users/cer/.m2/testdeploy,https://dl.bintray.com/eventuateio-oss/eventuate-maven-rc,https://snapshots.repositories.eventuate.io/repository

springBootVersion=2.2.6.RELEASE
springCloudSleuthVersion=2.1.0.RELEASE
eventuateTramVersion=0.24.0.RELEASE
eventuateUtilVersion=0.4.0.RELEASE
dockerComposePluginVersion=0.4.5
Expand All @@ -16,3 +17,4 @@ eventuateCommonImageVersion=0.9.0.RELEASE
eventuateMessagingKafkaImageVersion=0.9.0.RELEASE
eventuateCdcImageVersion=0.6.1.RELEASE
eventuateCdcKafkaEnableBatchProcessing=false

28 changes: 28 additions & 0 deletions java-development/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM openjdk:8u252-slim-buster

WORKDIR /development
RUN apt-get update && \
apt-get install -y curl && \
apt-get install -y jq && \
apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg2 \
software-properties-common && \
( curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add - ) && \
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/debian \
$(lsb_release -cs) \
stable" && \
apt-get update && \
apt-get install -y docker-ce-cli && \
curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose && \
chmod +x /usr/local/bin/docker-compose && \
rm -rf /var/lib/apt/lists/*

COPY build /tmp-src

RUN echo "Building in image..." && (cd /tmp-src ; ./gradlew testClasses assemble ; cd ; rm -fr /tmp-src)

CMD echo Ready ; sleep 260000
2 changes: 1 addition & 1 deletion jmeter-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM openjdk:14-jdk-alpine3.10
FROM openjdk:8u252-slim-buster
RUN wget -q -O - http://mirror.linux-ia64.org/apache//jmeter/binaries/apache-jmeter-5.2.1.tgz | tar -xzf - -C /usr/local
RUN mkdir /usr/local/plans
RUN mkdir /usr/local/results
Expand Down
6 changes: 3 additions & 3 deletions jmeter-service/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
apply plugin: 'org.springframework.boot'
apply plugin: "io.spring.dependency-management"

dependencies {
compile project(":common-swagger")

Expand All @@ -7,6 +10,3 @@ dependencies {
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.boot:spring-boot-starter-web"
}

apply plugin: 'org.springframework.boot'
apply plugin: "io.spring.dependency-management"
2 changes: 1 addition & 1 deletion jmeter-service/scripts/run-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ docker rm eventuate-tram-examples-customers-and-orders_cdcservice_1

./jmeter-service/scripts/run-jmeter.sh

./gradlew $* mysqlbinlogcdcComposeUp
./gradlew $* mysqlbinloginfrastructureComposeUp

while true ; do
date
Expand Down
4 changes: 2 additions & 2 deletions order-history-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM openjdk:14-jdk-alpine3.10
RUN apk --no-cache add curl
FROM openjdk:8u252-slim-buster
RUN apt-get update && apt-get install -y curl
HEALTHCHECK --start-period=30s --interval=5s CMD curl -f http://localhost:8080/actuator/health || exit 1
CMD java ${JAVA_OPTS} -jar order-history-service-*.jar
COPY build/libs/order-history-service-*.jar .
4 changes: 2 additions & 2 deletions order-history-service/Dockerfile-maven
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM openjdk:14-jdk-alpine3.10
RUN apk --no-cache add curl
FROM openjdk:8u252-slim-buster
RUN apt-get update && apt-get install -y curl
HEALTHCHECK --start-period=30s --interval=5s CMD curl -f http://localhost:8080/actuator/health || exit 1
CMD java ${JAVA_OPTS} -jar order-history-service-0.1.0-SNAPSHOT.jar
COPY ./target/order-history-service-0.1.0-SNAPSHOT.jar .
5 changes: 2 additions & 3 deletions order-history-service/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ buildscript {
}
}

apply plugin: 'org.springframework.boot'
apply plugin: "io.spring.dependency-management"
apply plugin: ServicePlugin

dependencies {
compile project(":order-history-backend")
Expand All @@ -18,5 +17,5 @@ dependencies {
compile "org.springframework.boot:spring-boot-starter"
compile "org.springframework.boot:spring-boot-starter-web"
compile "org.springframework.boot:spring-boot-starter-actuator"

}

Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ spring.datasource.hikari.maximumPoolSize=100

eventuatelocal.kafka.bootstrap.servers=${DOCKER_HOST_IP:localhost}:9092
eventuatelocal.zookeeper.connection.string=${DOCKER_HOST_IP:localhost}:2181
spring.data.mongodb.uri=mongodb://${DOCKER_HOST_IP:localhost}/customers.orders
spring.data.mongodb.uri=mongodb://${DOCKER_HOST_IP:localhost}/customers.orders

spring.sleuth.enabled=true
spring.sleuth.sampler.probability=1
spring.zipkin.base.url=http://${DOCKER_HOST_IP:localhost}:9411/
4 changes: 2 additions & 2 deletions order-history-text-search-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM openjdk:14-jdk-alpine3.10
RUN apk --no-cache add curl
FROM openjdk:8u252-slim-buster
RUN apt-get update && apt-get install -y curl
HEALTHCHECK --start-period=30s --interval=5s CMD curl -f http://localhost:8080/actuator/health || exit 1
CMD java ${JAVA_OPTS} -jar order-history-text-search-service-*.jar
COPY build/libs/order-history-text-search-service-*.jar .
4 changes: 2 additions & 2 deletions order-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM openjdk:14-jdk-alpine3.10
RUN apk --no-cache add curl
FROM openjdk:8u252-slim-buster
RUN apt-get update && apt-get install -y curl
HEALTHCHECK --start-period=30s --interval=5s CMD curl -f http://localhost:8080/actuator/health || exit 1
CMD java ${JAVA_OPTS} -jar order-service-*.jar
COPY build/libs/order-service-*.jar .
4 changes: 2 additions & 2 deletions order-service/Dockerfile-maven
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM openjdk:14-jdk-alpine3.10
RUN apk --no-cache add curl
FROM openjdk:8u252-slim-buster
RUN apt-get update && apt-get install -y curl
HEALTHCHECK --start-period=30s --interval=5s CMD curl -f http://localhost:8080/actuator/health || exit 1
CMD java ${JAVA_OPTS} -jar order-service-0.1.0-SNAPSHOT.jar
COPY ./target/order-service-0.1.0-SNAPSHOT.jar .
Expand Down
Loading

0 comments on commit e08a70d

Please sign in to comment.