Buy some Magical Unicorns and deploy the Unicorn Store to a Docker container running .NET Core on Alpine Linux.
To get started you will need:
-
Docker installed on your local machine.
-
An IDE for building .NET Core applications such as Visual Studio
Once you have the prerequisites installed on your local development machine you should be able to run the Unicorn Store locally either in your IDE or in a local container. Take the time to read mutiple environments in ASP.NET Core and safe storage of app secrets in development in ASP.NET Core before starting so you understand the various different configuration options.
The Unicorn Store is meant to run in a Docker container and demonstrates how you can run the UnicornDB in Amazon RDS while storing the RDS credentials to the database in AWS Secrets Manager. This allows the Unicorn Store application to safely connect to the database from the container without storing the secrets in a file on the container.
If you want to test locally you have the option to set a couple of flags in the various different appsettings files such as: appsettings.Development.json
-
CacheDbResults
- Cache in-memory in ASP.NET Core -
UseInMemoryStore
- Set totrue
to use the in-memory database on Mac and Linux systems. -
UseLocalDB
- Set totrue
to use LocalDB on Windows systems. -
UseLocalSecrets
- Use the Secret Manager tool in local development to set the secret to connect to your UnicornDB database. Ensure that the local secret you create for the connection to the UnicornDB mirrors the secret value format when you retrieve a RDS secret from Secrets Manager. The structure should follow the below example:{ "unicornstore-secret": { "username": "unicorndbuser", "password": "unicrondbpassword", "engine": "sqlserver", "host": "unicorn-db-us-west-2.rds.amazonaws.com", "port": 1433, "dbInstanceIdentifier": "unicorn-store-test" } }
-
RunInFargate
- Set totrue
when running the container in AWS Fargate.
docker-compose build
docker-compose -f docker-compose.yml -f docker-compose.development.yml up