This repo contains the configuration for deploying the Vehicle Quotes system components. A .NET demo application.
It uses Docker and Docker Compose. It is organized using git submodules.
In order to deploy, do the following:
- Checkout the desired tag or commit in
source. - Check that the correct values are set in the
.envfile and in the files inside thesecretsdir. - Rebuild and restart the system with
docker compose up -d --build. - If there are database changes, run the migrations with:
docker compose exec maintenance bashto connect to the maintenance container.export ConnectionStrings__VehicleQuotesContext=$(cat /run/secrets/vehicle-quotes-db-connection-string)to load the connection string into an env var.dotnet ef migrations list --startup-project ./VehicleQuotes.AdminPortal --project ./VehicleQuotes.Coreto check if there are pending migrations.dotnet ef database update --startup-project ./VehicleQuotes.AdminPortal --project ./VehicleQuotes.Coreto run the migrations.
- Now the various system components should be running and accessible via
localhost, each in a separate port. The default configuration (as given by the.envfile) is this:- The Admin Portal on port 8001.
- The Web Api on port 8002.
- The database on port 5432.
If you want to shut down the system, you can stop the containers with
docker compose stop.
If you want to monitor the system while deploying, tail the logs with
docker compose logs -f.
You can stop all containers with docker compose stop. This will not delete the containers, it will only stop them.
Tear down with docker compose down. This will delete all containers.
These commands need to be run from within this repo's root directory.
You can access the logs on each of the individual apps. This can be done with:
- For the Admin Portal:
docker compose logs -f admin-portal. - For the Web API:
docker compose logs -f web-api. - For the database:
docker compose logs -f db.
You can see the logs from all the containers in a single stream with:
docker compose logs -fThese commands need to be run from within this repo's root directory.
The database process will run in a container as well. The data files will be stored in a Volume named db-postgres-data.
You can connect to the database using:
psql -h localhost -d vehicle_quotes -U vehicle_quotes -WYou can also connect to it from within the maintenance container. First connect to the container. From within this repo's root directory, this can be done like so:
docker compose exec maintenance bashAnd then:
psql -h db -d vehicle_quotes -U vehicle_quotes -WThe password can be found in
secrets/vehicle-quotes-db-password.txt.
Our system uses cookies which are protected using .NET's Data Protection API. To make sure it works well across deployments, part of its configuration involves storing the keys in a non-volatile location. The data-protection-keys directory serves that purpose.
More info here:
- The key was not found in the key ring. Unable to validate token
- Configure ASP.NET Core Data Protection - PersistKeysToFileSystem
- Configure ASP.NET Core Data Protection - Persisting keys when hosting in a Docker container
During normal operations of building and rebuilding images and containers, the docker engine will accumulate old, untagged, unreferenced images on disk. These are called "dangling images".
To see all the existing images, use docker image ls -a. The ones which have <none> in their TAG and REPOSITORY are the dangling ones.
From time to time, it's good to clean these up. This can be done with docker image prune.