diff --git a/.dockerignore b/.dockerignore index 4f16b6f65f..4541556e29 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,6 +1,9 @@ .github docs internal +src/*/README.md +src/*/Dockerfile +src/*/*/Dockerfile ################################### # currencyservice diff --git a/CHANGELOG.md b/CHANGELOG.md index 0dc6156796..9cfb662db0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -198,5 +198,7 @@ significant modifications will be credited to OpenTelemetry Authors. ([#691](https://github.com/open-telemetry/opentelemetry-demo/pull/691)) * Fix payment service version to support temporality environment variable ([#693](https://github.com/open-telemetry/opentelemetry-demo/pull/693)) +* Update recommendationservice python base image and dependencies +([#700](https://github.com/open-telemetry/opentelemetry-demo/pull/700)) * Reduce spans generated from quote service ([#702](https://github.com/open-telemetry/opentelemetry-demo/pull/702)) diff --git a/docs/current_architecture.md b/docs/current_architecture.md index 91b997bb18..2535af4e19 100644 --- a/docs/current_architecture.md +++ b/docs/current_architecture.md @@ -40,7 +40,7 @@ checkoutservice --->|gRPC| currencyservice checkoutservice --->|HTTP| emailservice checkoutservice --->|gRPC| paymentservice checkoutservice -->|gRPC| shippingservice -checkoutservice -->|TCP| queue +checkoutservice ---->|TCP| queue frontend -->|gRPC| adservice frontend -->|gRPC| cartservice @@ -54,6 +54,8 @@ frauddetectionservice -->|TCP| queue productcatalogservice -->|gRPC| featureflagservice +recommendationservice -->|gRPC| featureflagservice + shippingservice -->|gRPC| featureflagservice featureflagservice --> featureflagstore diff --git a/src/recommendationservice/Dockerfile b/src/recommendationservice/Dockerfile index 3e542988a7..361ba0669e 100644 --- a/src/recommendationservice/Dockerfile +++ b/src/recommendationservice/Dockerfile @@ -1,4 +1,4 @@ -# Copyright 2020 Google LLC +# Copyright The OpenTelemetry Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -12,21 +12,42 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM python:3.10 +FROM python:3.10-slim-bullseye as base -WORKDIR /usr/src/app/ +# +# Fetch requirements +# +FROM base as builder +RUN apt-get -qq update \ + && apt-get install -y --no-install-recommends g++ \ + && rm -rf /var/lib/apt/lists/* -COPY ./src/recommendationservice/ ./ -COPY ./pb/ ./proto/ +WORKDIR /usr/src/app/ +COPY ./src/recommendationservice/requirements.txt ./ RUN pip install --upgrade pip -RUN pip install -r ./requirements.txt +RUN pip install --prefix="/reqs" -r requirements.txt -RUN opentelemetry-bootstrap -a install +# +# Build gRPC files +# +FROM base as grpc-builder +WORKDIR /usr/src/app/ +COPY ./pb/ ./proto/ -# add files into working directory RUN python -m pip install grpcio-tools==1.48.2 RUN python -m grpc_tools.protoc -I=./proto/ --python_out=./ --grpc_python_out=./ ./proto/demo.proto +# +# Runtime +# +FROM base as runtime +WORKDIR /usr/src/app/ +COPY --from=builder /reqs /usr/local +COPY --from=grpc-builder /usr/src/app/ . +COPY ./src/recommendationservice/ ./ + +RUN opentelemetry-bootstrap -a install + EXPOSE ${RECOMMENDATION_SERVICE_PORT} ENTRYPOINT [ "opentelemetry-instrument", "python", "recommendation_server.py" ] diff --git a/src/recommendationservice/logger.py b/src/recommendationservice/logger.py index fc193ae9be..bd66bd1aae 100644 --- a/src/recommendationservice/logger.py +++ b/src/recommendationservice/logger.py @@ -1,6 +1,6 @@ #!/usr/bin/python # -# Copyright 2018 Google LLC +# Copyright The OpenTelemetry Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/src/recommendationservice/recommendation_server.py b/src/recommendationservice/recommendation_server.py index 883c7cb823..86fd2b274c 100644 --- a/src/recommendationservice/recommendation_server.py +++ b/src/recommendationservice/recommendation_server.py @@ -1,6 +1,6 @@ #!/usr/bin/python # -# Copyright 2018 Google LLC +# Copyright The OpenTelemetry Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/src/recommendationservice/requirements.txt b/src/recommendationservice/requirements.txt index 4e948debbf..b3f7540e48 100644 --- a/src/recommendationservice/requirements.txt +++ b/src/recommendationservice/requirements.txt @@ -1,8 +1,7 @@ -google-api-core==2.4.0 grpcio-health-checking==1.43.0 grpcio==1.43.0 -opentelemetry-distro==0.34b0 -opentelemetry-exporter-otlp-proto-grpc==1.13.0 +opentelemetry-distro==0.36b0 +opentelemetry-exporter-otlp-proto-grpc==1.15.0 python-dotenv==0.21.0 python-json-logger==2.0.4 -psutil==5.9.2 # Importing this will also import opentelemetry-instrumentation-system-metrics when running opentelemetry-bootstrap \ No newline at end of file +psutil==5.9.2 # Importing this will also import opentelemetry-instrumentation-system-metrics when running opentelemetry-bootstrap