Skip to content

Commit

Permalink
fix: make sure the PoC can be build and is runnable (#4)
Browse files Browse the repository at this point in the history
* Fix POC to get a working project

* avoid hanging swaggerui

* Getting started: elaborate on how to get started

* remove unwanted commands
  • Loading branch information
fgheysels authored Mar 17, 2022
1 parent fce0e3c commit 12dba57
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 45 deletions.
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,16 @@ When looking at the telemetry tree, it looks as following:

Before you can run this, you need to:

1. Run solution with Docker Compose
2. Get bacon by calling the API - GET http://localhost:789/api/v1/bacon
3. Create order to eat bacon asynchronously by calling the API - POST http://localhost:787/api/v1/market
1. Create an Application Insights resource in your Azure Subscription
2. Create an Azure Service Bus namespace resource in your Azure Subscription
3. Create a queue called `orders` in the Azure Service Bus namespace
4. Create a `docker-compose.override.yml` file and set the Application Insights instrumentation key and Service Bus connectionstring
5. Run solution with Docker Compose by running `docker compose up` from the folder where the `docker-compose.yml` file is located
6. Get bacon by calling the API - GET http://localhost:789/api/v1/bacon
7. Create order to eat bacon asynchronously by calling the API - POST http://localhost:787/api/v1/market

> You can use a tool like Postman to perform API requests, or you can use the Swagger UI page which is available at `localhost:787/api/docs` for the Market API and at `localhost:789/api/docs` for the Bacon API.
```json
{
"amount": 2
Expand Down
4 changes: 1 addition & 3 deletions src/Arcus.API.Bacon/Controllers/BaconController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ public BaconController(IBaconRepository baconRepository, ILogger<BaconController
/// <remarks>Provides an overview of various bacon flavors.</remarks>
/// <response code="200">Bacon is served!</response>
/// <response code="503">Uh-oh! Things went wrong</response>
[HttpGet(Name = "Bacon_Get")]
[ProducesResponseType(typeof(HealthReport), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(HealthReport), StatusCodes.Status503ServiceUnavailable)]
[HttpGet(Name = "Bacon_Get")]
[SwaggerResponseHeader(200, "RequestId", "string", "The header that has a request ID that uniquely identifies this operation call")]
[SwaggerResponseHeader(200, "X-Transaction-Id", "string", "The header that has the transaction ID is used to correlate multiple operation calls.")]
public async Task<IActionResult> Get()
Expand Down
4 changes: 1 addition & 3 deletions src/Arcus.API.Bacon/Controllers/HealthController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ public HealthController(HealthCheckService healthCheckService)
/// <remarks>Provides an indication about the health of the API.</remarks>
/// <response code="200">API is healthy</response>
/// <response code="503">API is unhealthy or in degraded state</response>
[HttpGet(Name = "Health_Get")]
[ProducesResponseType(typeof(HealthReport), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(HealthReport), StatusCodes.Status503ServiceUnavailable)]
[HttpGet(Name = "Health_Get")]
[SwaggerResponseHeader(200, "RequestId", "string", "The header that has a request ID that uniquely identifies this operation call")]
[SwaggerResponseHeader(200, "X-Transaction-Id", "string", "The header that has the transaction ID is used to correlate multiple operation calls.")]
public async Task<IActionResult> Get()
Expand Down
10 changes: 5 additions & 5 deletions src/Arcus.API.Bacon/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ EXPOSE 80

FROM mcr.microsoft.com/dotnet/core/sdk:3.1.202-alpine3.10 AS build
WORKDIR /src
COPY ["Arcus.API.Bacon.csproj", ""]

COPY . .
WORKDIR "/src/."
RUN dotnet build "Arcus.API.Bacon.csproj" -c Release -o /app
COPY ["./Arcus.API.Bacon/Arcus.API.Bacon.csproj", ""]
COPY . ./

WORKDIR "/src"

FROM build AS publish
RUN dotnet publish "Arcus.API.Bacon.csproj" -c Release -o /app
RUN dotnet publish "./Arcus.API.Bacon/Arcus.API.Bacon.csproj" -c Release -o /app

FROM base AS final
WORKDIR /app
Expand Down
8 changes: 1 addition & 7 deletions src/Arcus.API.Bacon/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ private static IConfiguration CreateConfiguration(string[] args)
{
IConfigurationRoot configuration =
new ConfigurationBuilder()
.AddCommandLine(args)
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddCommandLine(args)
.AddEnvironmentVariables()
.Build();

Expand All @@ -62,12 +61,7 @@ private static IHostBuilder CreateHostBuilder(string[] args, IConfiguration conf
.ConfigureAppConfiguration(configBuilder => configBuilder.AddConfiguration(configuration))
.ConfigureSecretStore((config, stores) =>
{
#if DEBUG
stores.AddConfiguration(config);
#endif
//#error Please provide a valid secret provider, for example Azure Key Vault: https://security.arcus-azure.net/features/secrets/consume-from-key-vault
stores.AddAzureKeyVaultWithManagedServiceIdentity("https://your-keyvault.vault.azure.net/");
})
.UseSerilog(DefineLoggerConfiguration)
.ConfigureWebHostDefaults(webBuilder =>
Expand Down
4 changes: 1 addition & 3 deletions src/Arcus.API.Market/Controllers/HealthController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ public HealthController(HealthCheckService healthCheckService)
/// <remarks>Provides an indication about the health of the API.</remarks>
/// <response code="200">API is healthy</response>
/// <response code="503">API is unhealthy or in degraded state</response>
[HttpGet(Name = "Health_Get")]
[ProducesResponseType(typeof(HealthReport), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(HealthReport), StatusCodes.Status503ServiceUnavailable)]
[HttpGet(Name = "Health_Get")]
[SwaggerResponseHeader(200, "RequestId", "string", "The header that has a request ID that uniquely identifies this operation call")]
[SwaggerResponseHeader(200, "X-Transaction-Id", "string", "The header that has the transaction ID is used to correlate multiple operation calls.")]
public async Task<IActionResult> Get()
Expand Down
2 changes: 0 additions & 2 deletions src/Arcus.API.Market/Controllers/MarketController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ public MarketController(IOrderRepository orderRepository, IBaconService baconSer
/// <response code="201">Order is created</response>
/// <response code="503">Uh-oh! Things went wrong</response>
[HttpPost(Name = "Market_CreateOrder")]
[ProducesResponseType(typeof(HealthReport), StatusCodes.Status201Created)]
[ProducesResponseType(typeof(HealthReport), StatusCodes.Status503ServiceUnavailable)]
[SwaggerResponseHeader(201, "RequestId", "string", "The header that has a request ID that uniquely identifies this operation call")]
[SwaggerResponseHeader(201, "X-Transaction-Id", "string", "The header that has the transaction ID is used to correlate multiple operation calls.")]
public async Task<IActionResult> CreateOrder([FromBody] OrderRequest orderRequest)
Expand Down
10 changes: 4 additions & 6 deletions src/Arcus.API.Market/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@ EXPOSE 80

FROM mcr.microsoft.com/dotnet/core/sdk:3.1.202-alpine3.10 AS build
WORKDIR /src
COPY ["Arcus.API.Salads.csproj", ""]

COPY ["./Arcus.API.Market/Arcus.API.Market.csproj", ""]
COPY . .
WORKDIR "/src/."
RUN dotnet build "Arcus.API.Salads.csproj" -c Release -o /app

FROM build AS publish
RUN dotnet publish "Arcus.API.Salads.csproj" -c Release -o /app
RUN dotnet publish "./Arcus.API.Market/Arcus.API.Market.csproj" -c Release -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "Arcus.API.Salads.dll"]
ENTRYPOINT ["dotnet", "Arcus.API.Market.dll"]

8 changes: 1 addition & 7 deletions src/Arcus.API.Market/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ private static IConfiguration CreateConfiguration(string[] args)
{
IConfigurationRoot configuration =
new ConfigurationBuilder()
.AddCommandLine(args)
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddCommandLine(args)
.AddEnvironmentVariables()
.Build();

Expand All @@ -62,12 +61,7 @@ private static IHostBuilder CreateHostBuilder(string[] args, IConfiguration conf
.ConfigureAppConfiguration(configBuilder => configBuilder.AddConfiguration(configuration))
.ConfigureSecretStore((config, stores) =>
{
#if DEBUG
stores.AddConfiguration(config);
#endif
//#error Please provide a valid secret provider, for example Azure Key Vault: https://security.arcus-azure.net/features/secrets/consume-from-key-vault
stores.AddAzureKeyVaultWithManagedServiceIdentity("https://your-keyvault.vault.azure.net/");
})
.UseSerilog(DefineLoggerConfiguration)
.ConfigureWebHostDefaults(webBuilder =>
Expand Down
2 changes: 1 addition & 1 deletion src/Arcus.Shared/SerilogFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Arcus.Shared
{
public class SerilogFactory
{
private const string ApplicationInsightsInstrumentationKeyName = "ApplicationInsights_InstrumentationKey";
private const string ApplicationInsightsInstrumentationKeyName = "APPINSIGHTS_INSTRUMENTATIONKEY";

public static void ConfigureSerilog(string componentName, LoggerConfiguration loggerConfiguration, IConfiguration configuration, IServiceProvider serviceProvider, bool useHttpCorrelation = true)
{
Expand Down
7 changes: 2 additions & 5 deletions src/Arcus.Workers.Orders/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@ EXPOSE 80

FROM mcr.microsoft.com/dotnet/core/sdk:3.1.202-alpine3.10 AS build
WORKDIR /src
COPY ["Arcus.Workers.Orders.csproj", ""]

COPY ["./Arcus.Workers.Orders/Arcus.Workers.Orders.csproj", ""]
COPY . .
WORKDIR "/src/."
RUN dotnet build "Arcus.Workers.Orders.csproj" -c Release -o /app

FROM build AS publish
RUN dotnet publish "Arcus.Workers.Orders.csproj" -c Release -o /app
RUN dotnet publish "./Arcus.Workers.Orders/Arcus.Workers.Orders.csproj" -c Release -o /app

FROM base AS final
WORKDIR /app
Expand Down

0 comments on commit 12dba57

Please sign in to comment.