diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..636f769 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,9 @@ +**/bin/ +**/obj/ +.vs/ +TestResults/ +.git/ +.repo-tasks/ +.repo-context/ +.tasks/ +.agile/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6fde5b1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,22 @@ +# syntax=docker/dockerfile:1.7 +ARG SDK_IMAGE=mcr.microsoft.com/dotnet/sdk:10.0 +ARG RUNTIME_IMAGE=mcr.microsoft.com/dotnet/aspnet:10.0 + +FROM ${SDK_IMAGE} AS build +ARG NUGET_FEED_URL=http://192.168.10.100:3000/api/packages/AgileWebs/nuget/index.json +ARG NUGET_FEED_USERNAME= +ARG NUGET_FEED_TOKEN= +WORKDIR /src +COPY . . + +RUN if [ -n "$NUGET_FEED_USERNAME" ] && [ -n "$NUGET_FEED_TOKEN" ]; then dotnet nuget add source "$NUGET_FEED_URL" --name gitea-org --username "$NUGET_FEED_USERNAME" --password "$NUGET_FEED_TOKEN" --store-password-in-clear-text --allow-insecure-connections --configfile /root/.nuget/NuGet/NuGet.Config; fi + +RUN dotnet restore "src/Furniture.Bff.Rest/Furniture.Bff.Rest.csproj" --configfile /root/.nuget/NuGet/NuGet.Config +RUN dotnet publish "src/Furniture.Bff.Rest/Furniture.Bff.Rest.csproj" -c Release -o /app/publish /p:UseAppHost=false --no-restore + +FROM ${RUNTIME_IMAGE} AS runtime +WORKDIR /app +ENV ASPNETCORE_URLS=http://+:8080 ASPNETCORE_ENVIRONMENT=Production +EXPOSE 8080 +COPY --from=build /app/publish . +ENTRYPOINT ["dotnet", "Furniture.Bff.Rest.dll"] diff --git a/docs/roadmap/feature-epics.md b/docs/roadmap/feature-epics.md new file mode 100644 index 0000000..5a79ed8 --- /dev/null +++ b/docs/roadmap/feature-epics.md @@ -0,0 +1,18 @@ +# Feature Epics + +## Repository +furniture-bff + +## Core Epics +- Epic 1: Expand domain-aligned capabilities for restaurant operations. +- Epic 2: Stabilize service contracts for containerized runtime integration. +- Epic 3: Improve observability and operational readiness for demo compose environments. + +## Domain-Specific Candidate Features +- Order lifecycle consistency and state transitions. +- Kitchen queue and dispatch optimization hooks. +- Operations control-plane policies (flags, service windows, overrides). +- POS closeout and settlement summary alignment. + +## Documentation Contract +Any code change in this repository must include docs updates in the same branch. diff --git a/docs/runbooks/containerization.md b/docs/runbooks/containerization.md new file mode 100644 index 0000000..652360f --- /dev/null +++ b/docs/runbooks/containerization.md @@ -0,0 +1,41 @@ +# Containerization Runbook + +## Image Build + +If the repo consumes internal packages from Gitea, pass feed credentials as build args. + +```bash +docker build --build-arg NUGET_FEED_USERNAME= --build-arg NUGET_FEED_TOKEN= -t agilewebs/furniture-bff:dev . +``` + +## Local Run + +```bash +docker run --rm -p 8080:8080 --name furniture-bff agilewebs/furniture-bff:dev +``` + +## Health Probe + +- Path: `/health` +- Fallback path: `/healthz` +- Port: `8080` + +## Runtime Notes + +- Requires `FurnitureService__GrpcAddress` to target furniture-service in distributed runs. +- gRPC client contract protobuf is vendored at `src/Furniture.Bff.Rest/Protos/furniture_runtime.proto` to keep image builds repo-local. + +## Health Endpoint Consistency + +- Canonical probe: `/health` +- Compatibility probe: `/healthz` +- Container port: `8080` + +## Demo Integration + +- Participates in: **furniture** demo compose stack. +- Integration artifact path: `greenfield/demo/furniture/docker-compose.yml` +## Known Limitations + +- Current runtime adapters are still predominantly in-memory for deterministic local/demo behavior. +- Demo PostgreSQL seeds validate integration contracts and smoke determinism, but do not yet imply full persistence implementation parity. diff --git a/src/Furniture.Bff.Rest/Furniture.Bff.Rest.csproj b/src/Furniture.Bff.Rest/Furniture.Bff.Rest.csproj index 59cf374..9a52bd8 100644 --- a/src/Furniture.Bff.Rest/Furniture.Bff.Rest.csproj +++ b/src/Furniture.Bff.Rest/Furniture.Bff.Rest.csproj @@ -15,7 +15,7 @@ - + diff --git a/src/Furniture.Bff.Rest/Program.cs b/src/Furniture.Bff.Rest/Program.cs index a99f89e..a975cd1 100644 --- a/src/Furniture.Bff.Rest/Program.cs +++ b/src/Furniture.Bff.Rest/Program.cs @@ -9,6 +9,7 @@ using Furniture.Service.Grpc; using Microsoft.Extensions.Primitives; const string CorrelationHeaderName = "x-correlation-id"; +const string CorsPolicyName = "FurnitureBffCors"; var builder = WebApplication.CreateBuilder(args); var edgeProtocol = builder.Configuration["FurnitureBff:EdgeProtocol"] ?? "rest"; @@ -23,6 +24,21 @@ builder.Services.AddHealthChecks(); builder.Services.AddBlueprintRuntimeCore(); builder.Services.AddFurnitureBffApplicationRuntime(); builder.Services.AddScoped(); +var allowedOrigins = builder.Configuration.GetSection("FurnitureBff:AllowedOrigins").Get() ?? + ["http://localhost:22380", "http://127.0.0.1:22380"]; +builder.Services.AddCors(options => +{ + options.AddPolicy(CorsPolicyName, policy => + { + if (Array.Exists(allowedOrigins, origin => origin == "*")) + { + policy.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader(); + return; + } + + policy.WithOrigins(allowedOrigins).AllowAnyMethod().AllowAnyHeader(); + }); +}); builder.Services.AddGrpcClient(options => { var serviceAddress = builder.Configuration["FurnitureService:GrpcAddress"] ?? "http://localhost:5252"; @@ -30,6 +46,7 @@ builder.Services.AddGrpcClient(options }); var app = builder.Build(); +app.UseCors(CorsPolicyName); app.Use(async (context, next) => { @@ -54,6 +71,7 @@ app.MapGet($"{EndpointConventions.ApiPrefix}/{{furnitureId}}/availability", asyn }); app.MapHealthChecks("/healthz"); +app.MapHealthChecks("/health"); app.Run(); diff --git a/src/Furniture.Bff.Rest/Protos/furniture_runtime.proto b/src/Furniture.Bff.Rest/Protos/furniture_runtime.proto new file mode 100644 index 0000000..785ba0f --- /dev/null +++ b/src/Furniture.Bff.Rest/Protos/furniture_runtime.proto @@ -0,0 +1,20 @@ +syntax = "proto3"; + +option csharp_namespace = "Furniture.Service.Grpc"; + +package furniture.service.grpc; + +service FurnitureRuntime { + rpc GetFurnitureAvailability (GetFurnitureAvailabilityGrpcRequest) returns (GetFurnitureAvailabilityGrpcResponse); +} + +message GetFurnitureAvailabilityGrpcRequest { + string furniture_id = 1; + string correlation_id = 2; +} + +message GetFurnitureAvailabilityGrpcResponse { + string furniture_id = 1; + string display_name = 2; + int32 quantity_available = 3; +}