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
In Visual Studio we can use built-in functionality to generate a Dockerfile that fits our project.
Go through the files related to docker compose, the Dockerfile and .bat scripts.
- Our script will run this file: Docker compose YAML for database (with database credentials)
- Script to create mssql image and run in container: docker-compose.up.bat
- 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:
- Our script will run this file: Docker compose YAML for application WhoOwesWhat
- Script to create mssql image and run in container: docker-compose.up.bat
- Verify that migrations has been run and that the database for WhoOwesWhat is created
Verify database connection and that database is created:
- Test WhoOwesWhat endpoints:
- Test health endpoints
- Create a user
- Authorize / Get the user you created
- This URL should work now: Swagger URL for localhost:5025