diff --git a/Dockerfile b/Dockerfile index 1291c9e..bfe8a69 100755 --- a/Dockerfile +++ b/Dockerfile @@ -17,11 +17,15 @@ COPY . . COPY --from=proto /build/pkg/pb pkg/pb RUN env GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o matchmaking-function-grpc-plugin-server-go_$TARGETOS-$TARGETARCH - FROM alpine:3.19 ARG TARGETOS ARG TARGETARCH WORKDIR /app + +# Optional: add grpc_health_probe binary +ADD https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/v0.4.11/grpc_health_probe-linux-amd64 /usr/local/bin/grpc_health_probe +RUN chmod +x /usr/local/bin/grpc_health_probe + COPY --from=builder /build/matchmaking-function-grpc-plugin-server-go_$TARGETOS-$TARGETARCH matchmaking-function-grpc-plugin-server-go # Plugin arch gRPC server port EXPOSE 6565 diff --git a/docker-compose.yaml b/docker-compose.yaml index cafa3d1..c00cb9b 100755 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,6 +1,12 @@ services: app: + healthcheck: + test: ["CMD", "grpc_health_probe", "-addr=:6565"] + interval: 10s + timeout: 5s + retries: 5 build: . + init: true ports: - "6565:6565" - "8080:8080" @@ -24,4 +30,13 @@ services: # loki-url: http://host.docker.internal:3100/loki/api/v1/push # mode: non-blocking # max-buffer-size: 4m -# loki-retries: "3" \ No newline at end of file +# loki-retries: "3" + envoy: + image: envoyproxy/envoy:v1.30-latest + ports: + - "7070:7070" + volumes: + - ./envoy.yaml:/etc/envoy/envoy.yaml + depends_on: + app: + condition: service_healthy \ No newline at end of file diff --git a/envoy.yaml b/envoy.yaml new file mode 100644 index 0000000..691ad12 --- /dev/null +++ b/envoy.yaml @@ -0,0 +1,49 @@ +static_resources: + listeners: + - name: grpc_listener + address: + socket_address: + address: 0.0.0.0 + port_value: 7070 + filter_chains: + - filters: + - name: envoy.filters.network.http_connection_manager + typed_config: + "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager + stat_prefix: grpc + codec_type: HTTP2 + route_config: + name: local_route + virtual_hosts: + - name: backend + domains: ["*"] + routes: + - match: + prefix: "/" + route: + cluster: grpc_service + http_filters: + - name: envoy.filters.http.router + typed_config: + "@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router + + clusters: + - name: grpc_service + connect_timeout: 0.25s + type: strict_dns + http2_protocol_options: {} + lb_policy: round_robin + circuit_breakers: + thresholds: + - max_connections: 100 + max_pending_requests: 100 + max_requests: 100 + load_assignment: + cluster_name: grpc_service + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: app + port_value: 6565 \ No newline at end of file