Skip to content

Latest commit

 

History

History
107 lines (74 loc) · 4.34 KB

build-and-run.md

File metadata and controls

107 lines (74 loc) · 4.34 KB

Build and run solution

Option 1: Build and run with GitHub Codespaces (recommended)

Pre-requisites

Steps

  1. Select Code and open in Codespace from GitHub
  2. After the codespaces has initialized, select to debug and run All Containers to run the sample locally

Option 2: Build and run with VS Code Dev Containers

Pre-requisites

  • Docker (with docker-compose)
  • VS Code with the remote containers extension installed

Steps

  1. Fork the sample repo
  2. Clone the repo: git clone https://github.com/{username}/container-apps-store-api-microservice
  3. Open the cloned repo in VS Code
  4. Follow the prompt to open in a dev container
  5. Select the debug All Services and run the sample locally

Any changes made to the project and checked into your GitHub repo will trigger a GitHub action to build and deploy

Option 3: Build and run with VS Code Directly

Pre-requisites

  1. Fork the sample repo
  2. Clone the repo: git clone https://github.com/{username}/container-apps-store-api-microservice
  3. Open the cloned repo in VS Code
  4. Follow the prompt to install recommended extensions
  5. Select the debug All Services and run the sample locally

Any changes made to the project and checked into your GitHub repo will trigger a GitHub action to build and deploy

Option 4: Build and run manually

Pre-requisites

Steps

  1. Fork the sample repo
  2. Clone the repo: git clone https://github.com/{username}/container-apps-store-api-microservice
  3. Build the sample:
cd node-service
npm install
cd ../go-service
go install
cd ../python-service
pip install -r requirements.txt
cd ..
  1. Run the sample
Local run and debug

Dapr will be used to start microservices and enable APIs for things like service discovery and state management. The code for store-api service invokes other services at the localhost:daprport host address, and sets the dapr-app-id HTTP header to enable service discovery using an HTTP proxy feature.

Run the node-app (store-api) service in a new terminal window:

dapr run --app-id node-app --app-port 3000 --dapr-http-port 3501 --components-path ./dapr-components -- npm run start

Run the python-app (order) service in a new terminal window:

dapr run --app-id python-app --app-port 5000 --dapr-http-port 3500 --components-path ./dapr-components -- python3 app.py

Run the go-app (inventory) service in a new terminal window:

dapr run --app-id go-app --app-port 8050 --dapr-http-port 3502 --components-path ./dapr-components -- go run .

State management: orders app calls the Dapr State Store APIs which are bound to a Redis container that is preinstalled with Dapr. When the application is later deployed to Azure Container Apps, the component config yaml will be modified to point to an Azure CosmosDb instance. No code changes will be needed since the Dapr State Store API is completely portable.