philjhale / helloworld-dotnet-containerised

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Hello world containerised .NET Core web API app

A reminder of how to create a containerised .NET Core app and deploy it.

For more information see ASP.NET Core in a container.

Application created using the command dotnet new webapi. A Dockerfile can be created automatically using the VSCode Docker extension.

Local usage

dotnet run

Navigate to https://localhost:5001/WeatherForecast.

Local Docker usage

docker build . -t dotnet-docker
docker run -p 5000:5000 --env PORT=5000 dotnet-docker

Navigate to http://localhost:5000/WeatherForecast.

Running on Google Cloud Run

Pre-requisites:

  • A Google Cloud Account with Cloud Run enabled.
  • gcloud CLI installed.

For more information see:

PROJECT_ID=your-project-id
gcloud auth login

gcloud config set project $PROJECT_ID

# Build, tag and push the container to Google Container Registry
docker build . -t dotnet-docker
docker tag dotnet-docker eu.gcr.io/$PROJECT_ID/dotnet-docker
docker push eu.gcr.io/$PROJECT_ID/dotnet-docker

# Deploy. All unauthenticated invocations.
gcloud run deploy dotnet-docker --image=eu.gcr.io/$PROJECT_ID/dotnet-docker --project=$PROJECT_ID --platform=managed --region=europe-west1

Navigate to [https://serivceurl/weatherforecast].

To delete execute gcloud run services delete dotnet-docker --platform=managed --project=$PROJECT_ID.

Running on Heroku

Pre-requisites:

  • A Heroku account.
  • Heroku CLI.

For more information see:

heroku login

heroku container:login

heroku create

heroku container:push web

heroku container:release web

heroku open

Navigate to [https://serivceurl/weatherforecast].

To delete execute heroku apps:destroy.

About


Languages

Language:C# 84.7%Language:Dockerfile 15.3%