The ServicesDAO portal provides a platform for the service DAOs which provide services in a decentralized manner through a modular implementation of MVPR.
To run the application, Docker
should be installed and configured on your system. Necesseary information is here.
In order to access the database, mysql client is to be installed on your system. Necessary information is here.
Example for Ubuntu:
sudo apt-get update
sudo apt-get install mysql-client
In order to build microservices individually and run the tests from command prompt dotnet sdk 3.1 or higher should be installed on your system. Necessary information is here.
Example for Ubuntu:
wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt update
sudo apt install apt-transport-https
sudo apt install dotnet-sdk-3.1
Project consists of two solutions:
docker-compose up
The command will create:
A local network is created by docker-compose (dao_network) and above microservices communicate with each other within that network.
To project to be work with full functionality, VotingEngine and ReputationService microservices and their database instances should be entegrated.
git clone https://github.com/EKON-YAZILIM/ServicesDAO_VotingEngine
Enter the ServicesDAO_VotingEngine project file. In the terminal code .
when you type, the project files will open.
The docker-compose.yml file in the ServicesDAO_VotingEngine project needs to be edited.
# dao_rabbitmq:
# image: rabbitmq:3-management
# container_name: 'dao_rabbitmq'
# environment:
# RABBITMQ_DEFAULT_USER: "daorabbit"
# RABBITMQ_DEFAULT_PASS: "dao2021*"
# ports:
# - 5673:5673
# - 5672:5672
# - 15672:15672
# volumes:
# - ~/.docker-conf/rabbitmq/data/:/var/lib/rabbitmq/
# - ~/.docker-conf/rabbitmq/log/:/var/lib/log
# healthcheck:
# test: rabbitmq-diagnostics -q status
# interval: 10s
# timeout: 30s
# retries: 15
# networks:
# - daonetwork
dao_votingengine:
image: ${DOCKER_REGISTRY-}daovotingengine
platform: linux/x86_64
build:
context: .
dockerfile: DAO_VotingEngine/Dockerfile
# depends_on:
# dao_rabbitmq:
# condition: service_healthy
restart: always
networks:
- daonetwork
dao_reputationservice:
image: ${DOCKER_REGISTRY-}daoreputationservice
platform: linux/x86_64
build:
context: .
dockerfile: DAO_ReputationService/Dockerfile
# depends_on:
# dao_rabbitmq:
# condition: service_healthy
restart: always
networks:
- daonetwork
Under ServicesDAO_VotingEngine project directory, open terminal and run:
docker-compose up
After docker-compose is up, you can access the application from the below link.
dao_webportal - http://localhost:8895
Using below links, you can see the status, logs and/or erros of the belonging microservice from localhost.
dao_identityservice - http://localhost:8890
dao_dbservice - http://localhost:8889
dao_logservice - http://localhost:8891
dao_notificationservice - http://localhost:8892
dao_apigateway - http://localhost:8896
The applciation databases can be accessed from within their own containers or from certain ports to localhost.
Example:
> docker exec -it <container_name of the database> bash -l
/# mysql -u root -p <name of the database>
>
> mysql -u <user> -p'<user password>' -h 127.0.0.1 -P 3306(exposed port) -D <database name>
For dao_db:
> mysql -u root -p'<root password>' -h 127.0.0.1 -P 3309 -D daodb
Thera are 2 database instances of the application;
Application logs and notifications are carried/delivered by a RabbitMQ instance - dao_rabbitmq.
dao_rabbitmq user interface adress is http://localhost:15672
If you are an Associate, you must pay a fee to be able to job.
If you are a VotingAssociate, you can directly recruit.
All applications can be built and run in their own docker containers with the following command;
docker build -f "./Dockerfile" -t [IMAGE_NAME]:dev "[SolutionPath]\ServicesDAO"
docker run -p [application access port]:80 -name:[NAME] [IMAGE_NAME]:dev --
For the application to work, all containers should be created in the same network also database, rabbitmq and api endpoints can be redefined.
After .NET core 3.1 and .NET SDK 3.1.20 are installed on the environment, all applications can be built individually by running the commands below under the project solution folder;
dotnet build ./DAO_ApiGateway/DAO_ApiGateway.csproj
dotnet build ./DAO_DbService/DAO_DbService.csproj
dotnet build ./DAO_IdentityService/DAO_IdentityService.csproj
dotnet build ./DAO_LogService/DAO_LogService.csproj
dotnet build ./DAO_NotificationService/DAO_NotificationService.csproj
dotnet build ./DAO_WebPortal/DAO_WebPortal.csproj
dao_db:
MySQL
Main database of the application.
dao_logsdb:
MySQL
Log database of exceptions and operations of the application.
dao_rabbitmq:
RabbitMQ
Serves as bus service, responsible for transmitting logs and notifications from every microservice to dao_logservice and dao_notificationservice.
dao_dbservice:
Shared data-access layer for application main database.
Accessed by:
Identity Service
Notification Service
Web Portal (Thru DAO_ApiGateway)
dao_logservice:
Data-access layer for dao_logsdb.
dao_notificationservice:
Responsible for sending notifications via email.
dao_webportal:
Provides application and user interactions with user interface.
Helpers Library:
Contains application models, constants, application wide generic methods(MySQL connection, RabbitMQ subscription, Json Serializing, Encryption etc...) of the application.
Application Mysql database instances should be up and running with a testing environment setup.
To run tests from terminal dotnet sdk should be installed on your system.
The easiest and recommended way is pulling a mysql docker image and run in a docker container with minimum parameters.
docker run --detach --name=test-mysql -p 3309:3306 --env="MYSQL_ROOT_PASSWORD=mypassword" mysql
To access the mysql instance in the container:
docker exec -it test-mysql bash -l
To access the database from the mysql container terminal :
mysql -u root -p
Enter Password: **********
mysql>
The root password, the expose port and many other parameters can be changed optionally. The test database connection string should be written under the PlatformSettings section taking place in the \PathToSolution\ServicesDAO\
"PlatformSettings": {
"DbConnectionString": "Server=localhost;Port=3313;Database=test_votingdb;Uid=root;Pwd=mypassword;",
...
}
After configuring the database, run the following commands from the test project directory.
For DAO_DbService:
\PathToSolution\UnitTests\DAO_DbService.Test\ dotnet test
For DAO_IdentityService:
\PathToSolution\UnitTests\DAO_IdentityService.Test\ dotnet test
Code documentation files in format is autogenerated everytime the project is build under bin folder.
The process below is explained for dao_webportal and is identical for every microservice included in this repository. To enable HTTPS, https settings of the application should be added to the Docker Container configuration and the an ssl certificate file should be introduced if necessary.
Example of enabling HTTPS using 'docker-compose.override.yml' file:
dao_webportal: environment:
An ssl certificate can be generated and placed in a location on the machine where the docker container is running. One way to generate an SSL certificate is explained here.
The definition of the generated ssl certificate in the docker compose file is as follows:
dao_webportal:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=https://+;http://+:80
- ASPNETCORE_HTTPS_PORT=443
#Password for the certificate
- ASPNETCORE_Kestrel__Certificates__Default__Password=< password of the generated certificate >
#Path of the certificate file
- ASPNETCORE_Kestrel__Certificates__Default__Path= < location of the ssl certificate in docker container. Example: '/https/aspnetapp.pfx' >
volumes:
#Mount the local volume where the certificate exists to docker container
- < location of the ssl certificate in the host machine> : < location of the ssl certificate in docker container. Example: '~/.aspnet/https:/https:ro'>