Docker
Docker local deployment guide
Pre-requisites
Before proceeding, make sure you have the latest version of docker installed.
Steps to deploy Presta LMS using docker-compose
- Configure hosts
Update your hosts with the following values:
sudo echo "127.0.1.1 iam.me.co.ke accounts.me.co.ke lending.me.co.ke eguarantorship.me.co.ke eguarantorship-api.me.co.ke prestapay.me.co.ke gateway-rabbitmq local-lending.presta.co.ke kopesha.service presta-reports iam21.me.co.ke partners.me.co.ke" >> /etc/hosts
- Download the required files.
In a directory of your choosing, clone the presta-docker-services repository and navigate into the ./presta-docker-services directory by entering the following commands:
git clone --depth 1 -b main https://github.com/workpointltd/presta-docker-services.git && cd ./presta-docker-services
The most important files in the docker deployment the keycloak,gateway, lms folder, we're not going to build docker images of the applications from scratch, but docker-compose already imports built images from ECR registry where our continuous-deployment push the new built images when we release new versions.
- Run keycloak & databases
Change directory into the keycloak folder and execute the docker compose file
cd keycloak && docker compose up -d && cd ../
All necessary environment variable values have been pre-configured, allowing you to begin using the application directly with these pre-configured settings. You also have the option to modify the values as needed.
This will start the following services
- mysql-8
- postgresql-13
- mongo-db 4.4
- Redis
- RabbitMq
- Keycloak 21
- Run Gateway Services
The gateway services includes an nginx instance running on port 80. Please shut down any web servers running on the host on port 80 before running the next command to avoid port conflicts.
Change directory into the gateway folder and execute the docker compose file
cd gateway && docker compose up -d && cd ../
This will start the gateway services, which include:
- gateway-service
- tenant-service
- users-master
- users-admin
- presta-iam-ui
- Run LMS
Change directory into the lms folder and execute the docker compose file
cd lms && docker compose up lms -d && cd ../
- Your LMS installation is complete. Please note that the containers are not exposed to the internet and they only bind to the localhost. You don't have to setup Nginx or any other proxy server to the requests, we're already set up Nginx container on docker-compose file as proxy server.
Wait for all containers to be in running state, and then point your browser to http://lending.me.co.ke/ to access the application.
Once the installation is done, you can login into the default account.
Credentials
- Account name: ABC Limited
- username: dev
- password: pass1
Verify the Installation
- Ensure that your containers are running correctly. To view the status of your containers, run the following command:
docker ps
The output should look similar to the following:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b533b0be214e account-id.dkr.ecr.us-west-2.amazonaws.com/prestaapps/kopesha:latest "/bin/sh -c '/wait &…" 17 seconds ago Up 16 seconds 8080/tcp, 0.0.0.0:9090->9090/tcp lms-lms-1
dd08ea537788 account-id.dkr.ecr.us-west-2.amazonaws.com/prestaapps/cloud-gateway:latest "java -jar /app.jar" 6 minutes ago Up 5 minutes 0.0.0.0:8080->8080/tcp presta-gateway
32696fb56533 account-id.dkr.ecr.us-west-2.amazonaws.com/prestaapps/keycloak "/opt/keycloak/bin/k…" 6 minutes ago Up 6 minutes 8443/tcp, 0.0.0.0:1000->8080/tcp keycloak
08d16741857b bitnami/postgresql:13 "/opt/bitnami/script…" 6 minutes ago Up 6 minutes 0.0.0.0:5432->5432/tcp postgresql
ff3cc95624af bitnami/rabbitmq:3.8 "/opt/bitnami/script…" 6 minutes ago Up 6 minutes 4369/tcp, 5551-5552/tcp, 5671/tcp, 0.0.0.0:5672->5672/tcp, 15671/tcp, 25672/tcp, 0.0.0.0:15672->15672/tcp rabbitmq-server
3bc4ca0e01d2 mysql:8.0.40 "docker-entrypoint.s…" 6 minutes ago Up 6 minutes 0.0.0.0:3306->3306/tcp, 33060/tcp mysql
8457ad67b458 bitnami/mongodb:4.4 "/opt/bitnami/script…" 6 minutes ago Up 6 minutes 0.0.0.0:27016->27017/tcp mongodb
8b8c3102e3a4 bitnami/redis:6.2 "/opt/bitnami/script…" 6 minutes ago Up 6 minutes 0.0.0.0:6379->6379/tcp redis-server
557261a8486b account-id.dkr.ecr.us-west-2.amazonaws.com/prestaapps/users-master:latest "java -jar /app.jar" 6 days ago Up 5 minutes 8080/tcp, 0.0.0.0:8081->8081/tcp users
e9c818a7ccf6 account-id.dkr.ecr.us-west-2.amazonaws.com/prestaapps/tenants-master:latest "/bin/sh -c '/wait &…" 6 days ago Up 5 minutes 0.0.0.0:8083->8083/tcp tenant
bef7c9b55645 account-id.dkr.ecr.us-west-2.amazonaws.com/prestaapps/presta-ui:latest "/docker-entrypoint.…" 6 days ago Up 35 seconds 0.0.0.0:80->80/tcp presta-ui
f78d6471963b account-id.dkr.ecr.us-west-2.amazonaws.com/prestaapps/users-admin:latest "/bin/sh -c '/wait &…" 6 days ago Up 6 minutes 0.0.0.0:7000->7000/tcp admin
Upgrading
First we need just to pull latest version of the project, might be some changes on the docker-compose files.
git pull origin main
Now we are going to pull the latest images from registry by doing.
docker compose --file docker-compose.yml pull
and start build and using them again.
docker compose --file docker-compose.yml up --build -d
The default databases are never overwritten once they've been installed, even after upgrading the services.
Alternatively, you can remove the MySQL/ Postgresql/ Mongo volumes by performing the following action, but that it will delete all your database data.
docker volume rm keycloak_mysql_data
docker volume rm keycloak_postgresql_13_data
docker volume rm keycloak_mongodb_data
The restart the services
cd keycloak && docker compose up -d && cd ../
cd gateway && docker compose up -d && cd ../
cd lms && docker compose up lms -d && cd ../