ASP.NET Core with PostgreSQL and Docker Demo
Application demo designed to show how ASP.NET Core and PostgreSQL can be run in Docker containers. The app uses Entity Framework to create a simple database that stores Docker commands and examples. It also shows how Angular can be integrated with Web API to display customer information.
Running the App with Docker Compose
-
Install
Docker Desktop for Mac
orDocker Desktop for Windows
. -
Navigate to the
AspNetCorePostgreSQLDockerApp
subfolder in a console window. -
Open the
Client
folder in a terminal window and run the following commands at the root of the folder (requires Node.js):npm install
npm install -g @angular/cli
ng build
-
Move back up a level to the
AspNetCorePostgreSQLDockerApp
in the terminal window:-
Run
docker-compose build
-
Run
docker-compose up
-
-
Navigate to http://localhost:5000 in your browser to view the site.
Using the Web App for Container Services on Azure
- Run
docker-compose -f docker-compose.prod.yml build
. - Tag the
aspnetcoreapp
image as[yourDockerHubUserAccount]/aspnetcoreapp
. Make sure you substitute your Docker Hub user account for[yourDockerHubUserAccount]
. - Push the image to Docker Hub using
docker push [yourDockerHubUserAccount]/aspnetcoreapp
. - Open
docker-compose azure.yml
file and change the image for theweb
service to[yourDockerHubUserAccount]/aspnetcoreapp
. - Create a new
Web App for Containers
service in Azure. You'll need to add it to a new or existing Resource Group. - On the
Docker
tab, switchOptions
toDocker Compose
,Image Source
toDocker Hub
and upload thedocker-compose azure.yml
file using theConfiguration File
section of the screen. - Wait for the service to start (it may take a few minutes to pull the image and fire up the Web App Service) and then click the web link it provides in the
Overview
section to hit the app.