Skip to content
This repository was archived by the owner on Jan 11, 2024. It is now read-only.

Docker Compose improved for avoiding issues while starting in a not Swarm environment #23

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
102 changes: 57 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,38 @@
This project contains Docker and Kubernetes Scripts for deploying Fineract CN, especially in Development.

## Requirements
- Kubernetes
- Docker
- Docker-compose
- Java

### Software Platform

1. Kubernetes
2. Docker
3. Docker-compose
4. Java

# Deploy and provision Fineract CN using Kubernetes
Make sure you set up and connect to your Kubernetes cluster. You can follow [this](https://cwiki.apache.org/confluence/display/FINERACT/Install+and+configure+kubectl+and+Google+Cloud+SDK+on+ubuntu+16.04) guide to set up a Kubernetes cluster on GKE.

- Enter the Kubernetes directory.

`cd kubernetes_scripts`

```console
cd kubernetes_scripts
```
- To deploy all the Fineract CN services on your cluster, run :

`bash kubectl-start-up.sh`
```console
bash kubectl-start-up.sh
```
- You should make sure an external ip address had been assigned to all the deployed services by running:

`kubectl get services`
```console
kubectl get services
```
- Finally provison the microservices by running:

`cd bash_scripts`

`bash provision.sh --deploy-on-kubernetes playground` # where playground is your tenant name

```console
cd bash_scripts
bash provision.sh --deploy-on-kubernetes playground # where playground is your tenant name
```
- To shut down and reset you cluster, run:

`bash kubectl-shut-down.sh`

```console
bash kubectl-shut-down.sh
```
# Deploy and provision Fineract CN using Docker and Docker-compose

You can either deploy and provision Fineract CN automatically using bash scripts or manually using Postman.
Expand All @@ -42,46 +46,50 @@ You can either deploy and provision Fineract CN automatically using bash scripts
# 1. Deploy and provision Fineract automatically using bash scripts

- To start up all the Fineract CN services run:

`bash start-up.sh`
```console
bash start-up.sh
```
- Then log the last Fineract CN microservice deployed by docker compose (fineract-cn-notification) to make sure all your Fineract services are now available.

`docker logs -f fineract-cn-docker-compose_notifications-ms_1`
```console
docker logs -f fineract-cn-docker-compose_notifications-ms_1
```
- Finally provison the microservices by

`cd bash_scripts`

`bash provision.sh playground` # where playground is your tenant name

```console
cd bash_scripts
bash provision.sh playground # where playground is your tenant name
```
## 2. Deploy Fineract manually using postman

## Perquisites

### Generate .env file with RSA keys
`java -cp external_tools/lang-0.1.0-BUILD-SNAPSHOT.jar org.apache.fineract.cn.lang.security.RsaKeyPairFactory UNIX > .env`

```console
java -cp external_tools/lang-0.1.0-BUILD-SNAPSHOT.jar org.apache.fineract.cn.lang.security.RsaKeyPairFactory UNIX > .env
```
This library is taken from [fineract-cn-lang](https://github.com/apache/fineract-cn-lang#generate-and-print-rsa-keys).

If needed you can pull a fresh copy of it:
`wget https://mifos.jfrog.io/mifos/libs-snapshot-local/org/apache/fineract/cn/lang/0.1.0-BUILD-SNAPSHOT/lang-0.1.0-BUILD-SNAPSHOT.jar external_tools/lang-0.1.0-BUILD-SNAPSHOT.jar`

```console
wget https://mifos.jfrog.io/mifos/libs-snapshot-local/org/apache/fineract/cn/lang/0.1.0-BUILD-SNAPSHOT/lang-0.1.0-BUILD-SNAPSHOT.jar external_tools/lang-0.1.0-BUILD-SNAPSHOT.jar
```
### Add other environment variables to the end of the .env file
`cat env_variables >> .env`

```console
cat env_variables >> .env
```
If you run some service from localhost then [add these services to your hosts file](#use-the-postman-scripts-when-running-locally).

## Procedure

### Start external tools (database, cassandra, etc)
```
```console
cd external_tools
docker-compose up
```

### Start micro services
First only start provisioner-ms by running following in project root:

```
```console
docker-compose up provisioner-ms
```
after it has started (and created table seshat to Postgre database) you can start rest of the services.
Expand All @@ -92,7 +100,7 @@ In the docker-compose.yml (that resides in project root) there are more than 10
Running all services together consumes a lot of memory. So you can start a subset of services.

For example you could start the following additional micro services and an fims-web-app:
```
```console
docker-compose up rhythm-ms identity-ms customer-ms accounting-ms deposit-ms portfolio-ms office-ms teller-ms fims-web-app
```
If you want you can add other micro services (listed in docker-compose.yml) to the list.
Expand All @@ -110,7 +118,7 @@ Instead demo_server we have Postman scripts and we use 'playground' as tenant na

We provide a postman-request-collection as well as a postman-environment that defines variables that are used to hold values received in responses.
Both files are located under [postman-initial-requests folder](postman_scripts):
```
```console
postman_scripts/Fineract-Cn-Initial-Requests.postman_collection.json
postman_scripts/Fineract-Cn-Initial-Setup-Environment.postman_environment.json
```
Expand All @@ -125,7 +133,7 @@ Initialize Postman as follows:

The first request will retrieve a token. The response should look like this, with a different token:

```
```json
{
"token": "Bearer eyJhbGciOiJSUzUxMiJ9.eyJhdWQiOiJwcm92aXNpb25lci12MSIsInN1YiI6IndlcGVtbmVmcmV0IiwiL21pZm9zLmlvL3NpZ25hdHVyZVRpbWVzdGFtcCI6IjIwMTctMDQtMThUMDlfNDRfMjIiLCIvbWlmb3MuaW8vdG9rZW5Db250ZW50IjoiUk9MRV9BRE1JTiIsImlzcyI6InN5c3RlbSIsImlhdCI6MTUwMDA1NjgxNywiZXhwIjoxNTAwNDE2ODE3fQ.OfxTUTStJbKQc4rAPW5PLIQYNjCG_uqcNPR4up6pIQBWLDxkgEiU9EF1WrB5NQdzXBJIHqjDFQpaVywm5DersIh4LxPGD3MZj3TqZK5_LUcZvBDTa4Xgb41e3xXkWB4TkN6KqfmiK12Ngjrrj7qZGBdtypDmFmZwKQRZIOL6T3QbI7LpbPGpeWjpWZirFgtcn5B1Z_h3r9rirCzecUdVjlaplQufxDuVFJS0R3N67pyuGQENvCAC716ID5KbokTQtITXfjnCztFuQBbtCPcYLIzxsKv_-E5k6Gd0pv01OC0XpY3NSgfAolVVgvSXKoRnL3NwAMP2yuzX6i8hR_q82Q",
"accessTokenExpiration": "2019-07-18T22:26:57.784"
Expand All @@ -144,9 +152,9 @@ Use the accounts_with_type.csv file found in postman_scripts and [follow the ins

1. Check if the micro services to which the requests are made are up and running.
Check the container for details of failures (if any):

```console
docker-compose logs provisioner-ms

```
2. Check that apps have registered with eureka: http://localhost:8761/

3. Reach out to [mailing list](https://lists.apache.org/[email protected]) with the relevant details
Expand All @@ -162,7 +170,7 @@ Navigate to http://localhost:8888 in your browser and enter the credentials of t

The following user-profile is available in fims-web-app after above setup was completed successfully:

```
```console
tenant: playground
user: mifos
password: password
Expand All @@ -172,7 +180,7 @@ password: password
Postman scripts use service names (postgres, provisioner-ms, etc) when referring to different services.
If you want to use the same Postman scripts when running micro services locally then add into your hosts (/etc/hosts in Unix) file:

```
```console
127.0.0.1 eureka
127.0.0.1 postgres
127.0.0.1 cassandra
Expand All @@ -196,9 +204,13 @@ If you want to use the same Postman scripts when running micro services locally

### How to reset everything and start from scratch

Run ./shut-down-and-reset.sh or

Run
```console
./shut-down-and-reset.sh
```
or

```console
cd external_tools
docker-compose stop
docker-compose rm
Expand Down
11 changes: 8 additions & 3 deletions external_tools/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ services:
deploy:
replicas: 1
restart_policy:
condition: any
condition: on-failure
delay: 10s
max_attempts: 3

Expand All @@ -32,7 +32,7 @@ services:
deploy:
replicas: 1
restart_policy:
condition: any
condition: on-failure
delay: 10s
max_attempts: 3

Expand All @@ -46,6 +46,11 @@ services:
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
healthcheck:
test: ["CMD-SHELL", "pg_isready"]
interval: 10s
timeout: 5s
retries: 5
ports:
- "5432:5432"
volumes:
Expand All @@ -63,7 +68,7 @@ services:
deploy:
replicas: 1
restart_policy:
condition: any
condition: on-failure
delay: 10s
max_attempts: 3
volumes:
Expand Down