Lab repository to test microservices.
I've created this repo as a laboratory to test how I could develop a simple microservice composed of a WebApi, a WebServer and a Database. All inside a Docker container.
The chosen technologies where .NET Core as framework, nginx as reverse proxy and MSSQL Server Linux Docker image.
Docker was also used, obviously.
This small guide should help you run the Docker image and run tests.
This WebAPI was developed in ASPNet Core so in order to build, publish and run tests, you must have dotNet Core installed on your environment.
Check out their download page and follow the installation instructions for your system.
After installing, open a terminal window and enter dotnet --version to check if the installation was successful:
Clone this repo and then:
dotnet restore
dotnet build
dotnet publishThis will allow you to correctly build the WebAPI.
In order to run the Docker image, you must have Docker installed in you Windows, Linux or Mac. After installing Docker on your system and certifying that it is running, you should:
~\microservice-lab\docker volume create sqlserverdata
~\microservice-lab\docker-compose build
~\microservice-lab\docker-compose upThe result should look like this:
Alternatively to the aforementioned building steps, you can simply run one of the scripts on the project's root folder.
Run the
bashscriptbuild.sh
After that you can just docker-compose up
By default, I've inserted 6 bank accounts to the database:
You can POST to localhost/api/bank a fund transfer request and the API will try to place it, if the bank accounts have funds and/or are allowed to go overdraft (negative funds). The body should be:
If everything goes right, you should get a
200 OKstatus message.
If a given account number does not exists, you'll get a
404 Not Foundstatus message.
If the origin account doesn't allow overdraft (negative funds), you'll get a
400 Bad Requeststatus message.
You can check an account entries (transaction history) by GET to localhost/api/bank/GetEntriesByAccountId/{accountId}; so, regarding the transfer mentioned above, making this request to the AccountId 2, will return:
And for the AccountId 1:





