打开docker-compose.yml
添加
- killsb-social-apigw:
- image: ${REGISTRY:-killsbdapr}/killsb-social-apigw:${TAG:-latest}
- build:
- context: .
- dockerfile: src/ApiGateways/SocialEnvoy/Dockerfile
在路径src\ApiGateways\SocialEnvoy
添加envoy.yaml
- admin:
- access_log_path: "/dev/null"
- address:
- socket_address:
- address: 0.0.0.0
- port_value: 8001
- static_resources:
- listeners:
- - address:
- socket_address:
- address: 0.0.0.0
- port_value: 80
- filter_chains:
- - filters:
- - name: envoy.http_connection_manager
- config:
- codec_type: auto
- stat_prefix: ingress_http
- route_config:
- name: eshop_backend_route
- virtual_hosts:
- - name: eshop_backend
- domains:
- - "*"
- cors:
- allow_origin_string_match:
- - safe_regex:
- google_re2: {}
- regex: \*
- allow_methods: "GET, POST, PUT"
- allow_headers: "authorization, content-type, x-requestid, x-requested-with, x-signalr-user-agent"
- allow_credentials: true
- routes:
- - name: "pics"
- match:
- prefix: "/pics/"
- route:
- auto_host_rewrite: true
- prefix_rewrite: "/"
- cluster: image-api
- timeout: 300s
- - name: "c-short"
- match:
- prefix: "/b/"
- route:
- auto_host_rewrite: true
- prefix_rewrite: "/"
- cluster: blog-api
- timeout: 300s
- - name: "c-long"
- match:
- prefix: "/blog-api/"
- route:
- auto_host_rewrite: true
- prefix_rewrite: "/"
- cluster: blog-api
- timeout: 300s
- - name: "f-short"
- match:
- prefix: "/f/"
- route:
- auto_host_rewrite: true
- prefix_rewrite: "/"
- cluster: forum-api
- timeout: 300s
- - name: "f-long"
- match:
- prefix: "/forum-api/"
- route:
- auto_host_rewrite: true
- prefix_rewrite: "/"
- cluster: forum-api
- timeout: 300s
- - name: "f-short"
- match:
- prefix: "/a/"
- route:
- auto_host_rewrite: true
- prefix_rewrite: "/"
- cluster: account-api
- timeout: 300s
- - name: "f-long"
- match:
- prefix: "/account-api/"
- route:
- auto_host_rewrite: true
- prefix_rewrite: "/"
- cluster: account-api
- timeout: 300s
- http_filters:
- - name: envoy.cors
- - name: envoy.router
- access_log:
- - name: envoy.file_access_log
- filter:
- not_health_check_filter: {}
- config:
- json_format:
- time: "%START_TIME%"
- protocol: "%PROTOCOL%"
- duration: "%DURATION%"
- request_method: "%REQ(:METHOD)%"
- request_host: "%REQ(HOST)%"
- path: "%REQ(X-ENVOY-ORIGINAL-PATH?:PATH)%"
- response_flags: "%RESPONSE_FLAGS%"
- route_name: "%ROUTE_NAME%"
- upstream_host: "%UPSTREAM_HOST%"
- upstream_cluster: "%UPSTREAM_CLUSTER%"
- upstream_local_address: "%UPSTREAM_LOCAL_ADDRESS%"
- path: "/tmp/access.log"
- clusters:
- - name: dapr
- connect_timeout: 0.25s
- type: strict_dns
- lb_policy: round_robin
- hosts:
- - socket_address:
- address: 127.0.0.1
- port_value: 3500
- - name: image-api
- connect_timeout: 0.25s
- type: strict_dns
- lb_policy: round_robin
- hosts:
- - socket_address:
- address: ${ENVOY_SOCIAL_IMAGE_API}
- port_value: 80
- - name: blog-api
- connect_timeout: 0.25s
- type: strict_dns
- lb_policy: round_robin
- hosts:
- - socket_address:
- address: ${ENVOY_SOCIAL_BLOG_API}
- port_value: 80
- - name: forum-api
- connect_timeout: 0.25s
- type: strict_dns
- lb_policy: round_robin
- hosts:
- - socket_address:
- address: ${ENVOY_SOCIAL_FORUM_API}
- port_value: 80
- - name: account-api
- connect_timeout: 0.25s
- type: strict_dns
- lb_policy: round_robin
- hosts:
- - socket_address:
- address: ${ACCOUNT_API}
- port_value: 80
添加Dockerfile
- FROM envoyproxy/envoy:v1.14.2
-
- COPY src/ApiGateways/SocialEnvoy/envoy.yaml /tmpl/envoy.yaml.tmpl
- COPY src/ApiGateways/SocialEnvoy/docker-entrypoint.sh /
-
- RUN chmod 500 /docker-entrypoint.sh
-
- RUN apt-get update && \
- apt-get install gettext -y
-
- ENTRYPOINT ["/docker-entrypoint.sh"]
添加docker-entrypoint.sh
- #!/bin/sh
- set -e
-
- echo "Generating envoy.yaml config file..."
- cat /tmpl/envoy.yaml.tmpl | envsubst \$ENVOY_SOCIAL_BLOG_API,\$ENVOY_SOCIAL_FORUM_API,\$ENVOY_SOCIAL_IMAGE_API,\$ACCOUNT_API > /etc/envoy.yaml
-
- echo "Starting Envoy..."
- /usr/local/bin/envoy -c /etc/envoy.yaml
运行vs2022