Skip to content

Commit

Permalink
initail commit: Containerized cassandra and customer microservice
Browse files Browse the repository at this point in the history
  • Loading branch information
Anh3h committed Jun 1, 2018
0 parents commit 8b37aaf
Show file tree
Hide file tree
Showing 6 changed files with 205 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.idea/
src/
Fineract.iml
master.sh
migration.sh
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
activemq-definition.yml
eureka-definition.yml
FineractCN.iml
jar_files/
src
.idea/
78 changes: 78 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
FROM openjdk:8-jdk-alpine

ARG provisioner_port=2020
ARG identity_port=2021
ARG rhythm_port=2022
ARG office_port=2023
ARG customer_port=2024
ARG portfolio_port=2025
ARG deposit-account-management_port=2026
ARG teller_port=2027
ARG reporting_port=2028
ARG payroll_port=2029


ENV server.max-http-header-size=16384 \
bonecp.partitionCount=1 \
bonecp.maxConnectionsPerPartition=4 \
bonecp.minConnectionsPerPartition=1 \
bonecp.acquireIncrement=1 \
\
#Call setAdditionalProperties()
\
#spring.application.name="springApplicationName" \
server.port=9090 \
cassandra.clusterName="Test Cluster" \
cassandra.contactPoints=127.0.0.1:9142 \
cassandra.keyspace=seshat \
cassandra.cl.read=ONE \
cassandra.cl.write=ONE \
cassandra.cl.delete=ONE \
mariadb.driverClass=org.mariadb.jdbc.Driver \
mariadb.database=seshat \
mariadb.host=localhost \
mariadb.port=3306 \
mariadb.user=root \
mariadb.password=mysql \
spring.cloud.discovery.enabled=false \
spring.cloud.config.enabled=false \
flyway.enabled=false \
feign.hystrix.enabled=false \
ribbon.eureka.enabled=false \
ribbon.listOfServers=localhost:9090 \
#this.keyPairHolder = RsaKeyPairFactory.createKeyPair();
#system.publicKey.timestamp="this.keyPairHolder.getTimestamp()" \
#system.publicKey.modulus="this.keyPairHolder.publicKey().getModulus().toString()" \
#system.publicKey.exponent="this.keyPairHolder.publicKey().getPublicExponent().toString())" \
\
#server.port="integrationTestEnvironment.getFreshPort().toString()" \
#setKeyPair
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka \
spring.cloud.discovery.enabled=true \
eureka.instance.hostname=localhost \
eureka.client.fetchRegistry=true \
eureka.registration.enabled=true \
eureka.instance.leaseRenewalIntervalInSeconds=1 \
initialInstanceInfoReplicationIntervalSeconds=0 \
eureka.client.instanceInfoReplicationIntervalSeconds=1 \
activemq.brokerUrl=tcp://localhost:61616 \
ribbon.eureka.enabled=true \
\
ribbon.eureka.enabled=true \
#this.keyPairHolder = RsaKeyPairFactory.createKeyPair();
#system.publicKey.timestamp="this.keyPairHolder.getTimestamp()" \
#system.publicKey.modulus="this.keyPairHolder.publicKey().getModulus().toString()" \
#system.publicKey.exponent="this.keyPairHolder.publicKey().getPublicExponent().toString()" \
\
#For provision ms
system.initialclientid=service-runner

WORKDIR /tmp
COPY jar_files .
COPY wait_for_db.sh .
RUN chmod +x wait_for_db.sh
ENV spring.application.name="customer-v1" server.port=$customer_port \
server.contextPath="/customer-v1"
CMD sh './wait_for_db.sh' 0.0.0.0 9042 echo me
#CMD ["java", "-jar", "customer-service-boot-0.1.0-BUILD-SNAPSHOT.jar"]

66 changes: 66 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
version: '3'
services:
# eureka:
# image: springcloud/eureka
# container_name: eureka
# ports:
# - "8761:8761"
# healthcheck:
# test: curl --fail -s http://localhost:8761/ || exit 1
# interval: 1m30s
# timeout: 10s
# retries: 3

# activemq:
# image: webcenter/activemq:5.14.3
# container_name: activemq
# ports:
# - "61616:61616"
# healthcheck:
# test: curl --fail -s http://localhost:61616/ || exit 1
# interval: 1m30s
# timeout: 10s
# retries: 3

# mariadb:
# image: mariadb
# container_name: mariadb
# ports:
# - "3306:3306"
# environment:
# - MYSQL_ROOT_PASSWORD=mysql
# healthcheck:
# test: mysql -uroot -pmysql
# interval: 1m30s
# timeout: 10s
# retries: 3

cassandra:
image: cassandra
container_name: cassandra
ports:
- "127.0.0.1:9142:9042"
networks:
- webnet
healthcheck:
test: cqlsh
interval: 1m30s
timeout: 10s
retries: 3

domain-ms:
build:
context: .
dockerfile: Dockerfile
networks:
- webnet
depends_on:
# - eureka
# - activemq
# - mariadb
- cassandra
#command: sh './wait_for_db.sh' cassandra 9142 echo me
#command: ["sh", "-c", "wait_for_db.sh", "cassandra", "9142", "java", "-jar", "customer-service-boot-0.1.0-BUILD-SNAPSHOT.jar"]

networks:
webnet:
34 changes: 34 additions & 0 deletions migration_script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
declare -a domain_ms=("provisioner" "identity" "rhythm" "office" "customer" "portfolio" "deposit-account-management" "teller" "reporting" "payroll")
declare -a core_ms=("api" "async" "cassandra" "command" "data-jpa" "lang" "mariadb" "crypto")

lib_dir="${PWD}/jar_files/"
rm -r ${lib_dir}
mkdir ${lib_dir}
cd /$HOME/.m2/repository/org/apache/fineract/cn

echo "Migrating domain microservice"
for dir in "${domain_ms[@]}"
do
cd "$dir/service-boot/0.1.0-BUILD-SNAPSHOT"
cp service-boot-0.1.0-BUILD-SNAPSHOT.jar ${lib_dir}$dir-service-boot-0.1.0-BUILD-SNAPSHOT.jar
echo "Completed migrating ${PWD} "
echo ""
cd ../../..
done

echo "----------------------------------------------------------------------------------------"
echo "Migrating core microservice"
for dir in "${core_ms[@]}"
do
cd "$dir/0.1.0-BUILD-SNAPSHOT"
cp *.jar ${lib_dir}
echo "Completed migrating ${PWD} "
echo ""
cd ../..
done

cd "anubis/api/0.1.0-BUILD-SNAPSHOT"
cp *.jar ${lib_dir}
echo "Completed migrating ${PWD} "
echo ""
cd ../..
16 changes: 16 additions & 0 deletions wait_for_db.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

host="$1"
port="$2"
shift
shift
cmd="$@"

echo ${host} ${port}
while ! nc -z ${host} ${port}; do
>&2 echo "Cassandra is unavailable - sleeping"
sleep 1
done

>&2 echo "Cassandra is up - executing command"
exec $cmd

0 comments on commit 8b37aaf

Please sign in to comment.