diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 77530e213..c36cd2b3a 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -77,7 +77,6 @@ services: catalog.api: environment: - ASPNETCORE_ENVIRONMENT=Development - - ASPNETCORE_URLS=http://0.0.0.0:80;https://0.0.0.0:443; - ConnectionString=${ESHOP_AZURE_CATALOG_DB:-Server=sql.data;Database=Microsoft.eShopOnContainers.Services.CatalogDb;User Id=sa;Password=Pass@word} - PicBaseUrl=${ESHOP_AZURE_STORAGE_CATALOG_URL:-http://localhost:5202/api/v1/c/catalog/items/[0]/pic/} #Local: You need to open your local dev-machine firewall at range 5100-5110. - EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq} @@ -92,7 +91,7 @@ services: - OrchestratorType=${ORCHESTRATOR_TYPE} ports: - "5101:80" - - "9101:443" + - "9101:81" ordering.api: environment: @@ -415,4 +414,10 @@ services: - WebhooksUrl=http://webhooks.api - SelfUrl=http://webhooks.client/ ports: - - "5114:80" \ No newline at end of file + - "5114:80" + + envoy: + volumes: + - ./src/ApiGateways/Envoy/config:/etc/envoy + ports: + - "51051:51051" \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 11839c8b8..3b2f4f77d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -237,4 +237,10 @@ services: context: . dockerfile: src/Web/WebhookClient/Dockerfile depends_on: - - webhooks.api \ No newline at end of file + - webhooks.api + + envoy: + image: envoy:v1 + build: + context: src/ApiGateways/Envoy + dockerfile: Dockerfile \ No newline at end of file diff --git a/eShopOnContainers-ServicesAndWebApps.sln b/eShopOnContainers-ServicesAndWebApps.sln index 882bca09f..4bf2fa51d 100644 --- a/eShopOnContainers-ServicesAndWebApps.sln +++ b/eShopOnContainers-ServicesAndWebApps.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27130.2027 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29020.237 MinimumVisualStudioVersion = 10.0.40219.1 Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{FEA0C318-FFED-4D39-8781-265718CA43DD}" EndProject @@ -148,7 +148,20 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebhookClient", "src\Web\We EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Devspace.Support", "Devspace.Support", "{68F5041D-51F2-4630-94B6-B49789F5E51A}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Devspaces.Support", "src\BuildingBlocks\Devspaces.Support\Devspaces.Support.csproj", "{56C2EF0B-6BF2-41D9-BE07-6E6D08D06B35}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Devspaces.Support", "src\BuildingBlocks\Devspaces.Support\Devspaces.Support.csproj", "{56C2EF0B-6BF2-41D9-BE07-6E6D08D06B35}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Envoy", "Envoy", "{882A8F3A-C61F-4C44-86DD-A5A258714BF2}" + ProjectSection(SolutionItems) = preProject + src\ApiGateways\Envoy\Dockerfile = src\ApiGateways\Envoy\Dockerfile + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "config", "config", "{3ABEEE8C-35E0-4185-9825-C44326151F5B}" + ProjectSection(SolutionItems) = preProject + src\ApiGateways\Envoy\config\catalog.proto = src\ApiGateways\Envoy\config\catalog.proto + src\ApiGateways\Envoy\config\catalog.proto-descriptor.pb = src\ApiGateways\Envoy\config\catalog.proto-descriptor.pb + src\ApiGateways\Envoy\Dockerfile = src\ApiGateways\Envoy\Dockerfile + src\ApiGateways\Envoy\config\envoy.yaml = src\ApiGateways\Envoy\config\envoy.yaml + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -1862,6 +1875,8 @@ Global {766D7E92-6AF0-476C-ADD5-282BF4D8C576} = {E279BF0F-7F66-4F3A-A3AB-2CDA66C1CD04} {68F5041D-51F2-4630-94B6-B49789F5E51A} = {DB0EFB20-B024-4E5E-A75C-52143C131D25} {56C2EF0B-6BF2-41D9-BE07-6E6D08D06B35} = {68F5041D-51F2-4630-94B6-B49789F5E51A} + {882A8F3A-C61F-4C44-86DD-A5A258714BF2} = {77849D35-37D4-4802-81DC-9477B2775A40} + {3ABEEE8C-35E0-4185-9825-C44326151F5B} = {882A8F3A-C61F-4C44-86DD-A5A258714BF2} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {25728519-5F0F-4973-8A64-0A81EB4EA8D9} diff --git a/src/ApiGateways/Envoy/Dockerfile b/src/ApiGateways/Envoy/Dockerfile new file mode 100644 index 000000000..0f714330f --- /dev/null +++ b/src/ApiGateways/Envoy/Dockerfile @@ -0,0 +1 @@ +FROM envoyproxy/envoy \ No newline at end of file diff --git a/src/ApiGateways/Envoy/config/catalog.proto b/src/ApiGateways/Envoy/config/catalog.proto new file mode 100644 index 000000000..5fda69526 --- /dev/null +++ b/src/ApiGateways/Envoy/config/catalog.proto @@ -0,0 +1,42 @@ +syntax = "proto3"; + +package CatalogApi; + +import "google/api/annotations.proto"; + +message CatalogItemRequest { + int32 id = 1; +} + +message CatalogItemResponse { + int32 id = 1; + string name = 2; + string description=3; + double price=4; + string picture_file_name=5; + string picture_uri=6; + CatalogType catalog_type=8; + CatalogBrand catalog_brand=10; + int32 available_stock=11; + int32 restock_threshold=12; + int32 max_stock_threshold=13; + bool on_reorder=14; +} + +message CatalogBrand { + int32 id = 1; + string name = 2; +} + +message CatalogType { + int32 id = 1; + string type = 2; +} + +service Catalog { + rpc GetItemById (CatalogItemRequest) returns (CatalogItemResponse) { + option (google.api.http) = { + get: "/api/v1/catalog/items/{id}" + }; + } +} \ No newline at end of file diff --git a/src/ApiGateways/Envoy/config/catalog.proto-descriptor.pb b/src/ApiGateways/Envoy/config/catalog.proto-descriptor.pb new file mode 100644 index 000000000..7c94ce9f0 Binary files /dev/null and b/src/ApiGateways/Envoy/config/catalog.proto-descriptor.pb differ diff --git a/src/ApiGateways/Envoy/config/envoy.yaml b/src/ApiGateways/Envoy/config/envoy.yaml new file mode 100644 index 000000000..9e191ace2 --- /dev/null +++ b/src/ApiGateways/Envoy/config/envoy.yaml @@ -0,0 +1,56 @@ +admin: + access_log_path: /tmp/admin_access.log + address: + socket_address: { address: 0.0.0.0, port_value: 9901 } + +static_resources: + listeners: + - name: listener1 + address: + socket_address: { address: 0.0.0.0, port_value: 51051 } + filter_chains: + - filters: + - name: envoy.http_connection_manager + typed_config: + "@type": type.googleapis.com/envoy.config.filter.network.http_connection_manager.v2.HttpConnectionManager + stat_prefix: grpc_json + codec_type: AUTO + route_config: + name: local_route + virtual_hosts: + - name: local_service + domains: ["*"] + routes: + - match: { prefix: "/" } + route: { cluster: grpc, timeout: { seconds: 60 } } + http_filters: + - name: envoy.grpc_json_transcoder + config: + proto_descriptor: "/etc/envoy/catalog.proto-descriptor.pb" + services: ["CatalogApi.Catalog"] + print_options: + add_whitespace: true + always_print_primitive_fields: true + always_print_enums_as_ints: false + preserve_proto_field_names: false + - name: envoy.router + + clusters: + - name: grpc + connect_timeout: 1.25s + type: logical_dns + lb_policy: round_robin + dns_lookup_family: V4_ONLY + http2_protocol_options: {} + load_assignment: + cluster_name: grpc + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + # WARNING: "docker.for.mac.localhost" has been deprecated from Docker v18.03.0. + # If you're running an older version of Docker, please use "docker.for.mac.localhost" instead. + # Reference: https://docs.docker.com/docker-for-mac/release-notes/#docker-community-edition-18030-ce-mac59-2018-03-26 + address: catalog.api + port_value: 81 \ No newline at end of file diff --git a/src/ApiGateways/Web.Bff.Shopping/apigw/configuration.json b/src/ApiGateways/Web.Bff.Shopping/apigw/configuration.json index b3e01d773..8d823d443 100644 --- a/src/ApiGateways/Web.Bff.Shopping/apigw/configuration.json +++ b/src/ApiGateways/Web.Bff.Shopping/apigw/configuration.json @@ -5,8 +5,8 @@ "DownstreamScheme": "http", "DownstreamHostAndPorts": [ { - "Host": "catalog.api", - "Port": 80 + "Host": "envoy", + "Port": 51051 } ], "UpstreamPathTemplate": "/api/{version}/c/{everything}", diff --git a/src/Services/Catalog/Catalog.API/Catalog.API.csproj b/src/Services/Catalog/Catalog.API/Catalog.API.csproj index 2b66b6f0c..2d5e36507 100644 --- a/src/Services/Catalog/Catalog.API/Catalog.API.csproj +++ b/src/Services/Catalog/Catalog.API/Catalog.API.csproj @@ -38,7 +38,6 @@ - diff --git a/src/Services/Catalog/Catalog.API/Program.cs b/src/Services/Catalog/Catalog.API/Program.cs index 3cd36a451..73d644526 100644 --- a/src/Services/Catalog/Catalog.API/Program.cs +++ b/src/Services/Catalog/Catalog.API/Program.cs @@ -75,19 +75,15 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API .UseConfiguration(configuration) .ConfigureKestrel(options => { - var ports = GetDefinedPorts(configuration); - foreach (var port in ports.Distinct()) + options.Listen(IPAddress.Any, 80, listenOptions => { - options.ListenAnyIP(port.portNumber, listenOptions => - { - Console.WriteLine($"Binding to port {port.portNumber} (https is {port.https})"); - if (port.https) - { - listenOptions.UseHttps("eshop.pfx"); - listenOptions.Protocols = HttpProtocols.Http1AndHttp2; - } - }); - } + listenOptions.Protocols = HttpProtocols.Http1; + }); + options.Listen(IPAddress.Any, 81, listenOptions => + { + listenOptions.Protocols = HttpProtocols.Http2; + }); + }) .UseStartup() .UseApplicationInsights()