Build and Run the Application
The API can be configured to run locally or in a Docker container.
Build and Run Locally
Instructions
-
Open Command Prompt or PowerShell.
-
Navigate to the
<PROJECT-NAME>/simple-api/src/api
folder. -
Run the following command to build the project:
dotnet build
-
Run the following command to start the project:
dotnet run --project xxENSONOxx.xxSTACKSxx.API/xxENSONOxx.xxSTACKSxx.API.csproj
Build and Run in Docker Container
Instructions for Docker
-
Open your terminal.
-
Navigate to the
<PROJECT-NAME>/simple-api/src/api
folder. -
Run the following command to build a Docker image:
docker build -t dotnet-api .
This uses the Dockerfile in this folder to generate the Docker image.
-
After the Docker image is created, run the following command to start the Docker container:
docker run -p 5000:80 --mount type=bind,source=/path/to/PROJECT-NAME/simple-api/src/api/xxENSONOxx.xxSTACKSxx.API/appsettings.json,target=/app/config/appsettings.json
Verify that the Application Has Started
- Open your web browser.
- Go to http://localhost:5000/v1/menu. This should return a valid JSON response.
- To view the Open API UI, go to http://localhost:5000/swagger/index.html. This will show the API endpoints.
Note
If you have changed the domain (originally Menu
), the path will reflect that change. For example, if your domain
is Foo
, then the path will be ../v1/foo
instead of ../v1/menu
.