One of the nice things about Dapr is the ability to make the transition from executing against different backing services without ever having to change a line of code. This is especially important if you would like to run completely locally without any reliance on cloud-based services. You will notice in the `/manifests/branch/local` location that a number of dapr configs have been provided. These dapr configs will allow you to run each of the dapr-ized services in a local manner relying on local storage, local Redis and a local secret store.
With that said, there are a few short steps you will need to perform in order to set up your local development environment. The instructions below will guide you through setting up a GitHub Codespace and subsequently running all RedDog services.
3. Switch to the Run and Debug screen and debug the Bootstrapper. Upon completion, you should now have a "reddogdemo" database in the given SQL Server instance.
>The Accounting Service within RedDog relies on SQL Server for persistent storage. As such, you will notice that the `.devcontainer` configuration for Codespaces (located withing the `.devcontainer` folder) points at a Docker compose file that includes a container image reference to SQL Server. While the image will be pulled into your Codespace for you, the database itself will still need to be provisioned. Included in the RedDog repo is an EF Core migration that can be run to provision the database. This migration functionality is located within RedDog.Bootstrapper.
Now that everything is in place, try running a few services. For example, you can try running the OrderService by utilizing the provided VS Code tasks and doing the following:
You should now be able to call endpoints exposed by the OrderService. Try posting an order to `http://localhost:5100/order`. To do so, a series of .rest files have been provided for you in the root of the RedDog solution in a folder named "rest-samples". If successful (and other Dapr services are running) you should see the OrderService receive the posted order and then utilize the pubsub component to publish an OrderSummary message.
You can follow the steps above to begin running other services (MakeLine, Loyalty, ReceiptGeneration, VirtualWorker or AccountingService) and observe as the local dapr configs allow you to run against local storage, local Redis and a local secret store.
A few helpful VS Code tasks and launch configurations have been provided to help you run all services and the RedDog UI at the same time. To do so, follow these instructions:
### Running All Dapr-ized Services
1. Run all Dapr services by doing the following:
- Open the Command Palette
- Select `Tasks: Run Task`
- Select `Dapr (All Services)`
2. Debug all services by doing the following:
- Switch to the Run and Debug screen
- From the dropdown, choose to `Debug All Services`
3. After all services are running, switch to the `Ports` tab within VS Code (likely located to the right of your Terminal window) and find ports 5200 and 5700. These two ports are for the MakeLine Service and the Accounting Service, respectively. For both of these ports, set the Visibility to Public. This will allow the RedDog.UI to make calls to each of these services to retrieve necessary data for display purposes.
### Running the RedDog.UI
1. In the terminal window, navigate into the RedDog.UI folder
2. Perform an npm install to install necessary dependencies for the UI
```
npm install
```
3. Before running the RedDog.UI, we need to create a .env file in the root of this web app to set the base URL for the MakeLine and Accounting services. To do so, create a file named `.env` in the RedDog.UI folder. Execute the following to easily create the file:
```
touch .env
```
4. In this file, place the following contents:
```
VUE_APP_MAKELINE_BASE_URL=http://localhost:5200
VUE_APP_ACCOUNTING_BASE_URL=http://localhost:5700
```
8. Switch to the Run and Debug Screen and, from the dropdown, choose `Debug UI` and begin debugging the UI.
9. After a few moments, you will notice port 8080 show up in the Ports window. Set this port to public.
10. Launch the UI by clicking on the VS code pop-up in the lower-right of your screen or by clicking on the "Open in Browser" icon on the port 8080 line within the "Ports" window.
At this point, you should have all dapr services running as well as the RedDog.UI. After a few moments, the RedDog.UI will begin showing metrics related to orders being created and worked by the VirtualCustomer and VirtualWorker services. All of the services within RedDog will be exercised by the VirtualCustomer creating orders. Take a peek at the various debug windows for each of the services to see data being processed in real-time.