Skip to content

Latest commit

 

History

History
51 lines (39 loc) · 3.78 KB

5_Containerize_application_and_run_locally.md

File metadata and controls

51 lines (39 loc) · 3.78 KB

Add Docker support for your application and run container locally with its own database - HOW TO

Starting branch

workshop-run-container-local-dev

What we are going to do in this part of the course:

  • Add Dockerfile to our application in the root folder
  • Verify Dockerfile
  • Inspect relevant scripts and YAML-files related to containerization
  • Run MS SQL database in separate container in the same network as the service so that the service and database can communicate
  • Run application WhoOwesWhat in its own container and make sure the health endpoints work and that you can execute read & write operations

Add Docker support...

In Visual Studio we can use built-in functionality to generate a Dockerfile that fits our project. Add Docker support... Dockerfile in root folder

Inspect scripts and docker compose files

Go through the files related to docker compose, the Dockerfile and .bat scripts.

Create MS SQL image and run in a container

Verify that you can connect to the database from your local environment

  • Enter Microsoft SQL Server Management Studio (SSMS).
  • Log into your database that runs in the container you set up.
  • From your local environment the container is seen as localhost, with the port we specified in our docker-compose setup - port 1434.
  • Use the user and password that we specified in our docker-compose setup files (same as the variables in the connectionstring our containerized application uses). Docker compose YAML for database (with database credentials)
  • The WhoOwesWhat database wil not exist yet, since the application needs to run, seed database and apply migrations to create the database. We will come to this later. The most important thing in this section is verifying that you can connect to the database.

Login to containerized database via SSMS: Login - containerized database

Create WhoOwesWhat image and run our application in a container

Verify that contiainer runs and enter the Swagger API for WhoOwesWhat

  1. Verify that migrations has been run and that the database for WhoOwesWhat is created

Verify database connection and that database is created: Verify database connection and that database is created

  1. Test WhoOwesWhat endpoints: