A starter template for development of ASP .NET Core Web API inside Docker containers with Visual Studio Code
- Install the prerequisites
- Docker for Desktop
- Visual Studio Code
- install extention Remote Development
- git
- Clone the repo
git clone https://github.com/vtrifonov-esfiddle/aspnet-webapi-starter.git
- Open the repo root directory in VS Code
- Press F1 in VS Code
- type
>Remote-Containers: Reopen in Container
- Press F5 in VS Code to start debugging
- On your dev machine navigate to http://localhost:5000/
The following environment variables are available for aspnet-webapi-starter
container
- WORKSPACE_DIR_DOCKER_MOUNT
- this is the repository workspace root directory docker mount
- e.g
/host_mnt/c/GithubRepos/aspnet-webapi-starter
- necessary for bind mounts because you cannot start nested docker container from
aspnet-webapi-starter
on non-linux host machine
- DOCKER_REGISTRY
- your github docker registry
- allows you to tag/push/pull images to your docker registry without hardcoding it
- you need to login to the registry to use it
- e.g:
docker.pkg.github.com/vtrifonov-esfiddle/aspnet-webapi-starter
- this matches
docker.pkg.github.com/${{ github.repository }}
from the github workflowCI
- this matches
- GITHUB_USERNAME
- your github username
To work locally with your docker registry you need read and write access. Performs the steps once you have generated your repo from the template
- create
PAT
(personal access token) with the following permissions via https://github.com/settings/tokens- read:packages
- repo, write:packages
- on the dev container login to the registry using
PAT
- the username is provided via an environment variable available on the dev container
docker login docker.pkg.github.com -u $GITHUB_USERNAME