From 1bb33240a26cd7519412262d55c330fc39b738b8 Mon Sep 17 00:00:00 2001 From: Petr Styblo Date: Wed, 29 Nov 2023 17:06:33 +0100 Subject: [PATCH] currencyservice: bring back multistage build (#1276) --- CHANGELOG.md | 2 ++ src/currencyservice/Dockerfile | 27 ++++++++++++++++----------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3cfe2273b1..6d7ee6f26b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ release. ## Unreleased +* [currencyservice] bring back multistage build + ([#1276](https://github.com/open-telemetry/opentelemetry-demo/pull/1276)) * [currencyservice]: update opentelemetry-cpp to 1.12.0 ([#1275](https://github.com/open-telemetry/opentelemetry-demo/pull/1275)) * update loadgenerator dependencies and the base image diff --git a/src/currencyservice/Dockerfile b/src/currencyservice/Dockerfile index 9b0a85f855..3f470fad9c 100644 --- a/src/currencyservice/Dockerfile +++ b/src/currencyservice/Dockerfile @@ -14,22 +14,21 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM alpine +FROM alpine as builder -RUN apk update -RUN apk add git cmake make g++ grpc-dev re2-dev protobuf-dev c-ares-dev +RUN apk update && apk add git cmake make g++ grpc-dev protobuf-dev ARG OPENTELEMETRY_CPP_VERSION=1.12.0 RUN git clone https://github.com/open-telemetry/opentelemetry-cpp \ - && cd opentelemetry-cpp/ \ - && git checkout tags/v${OPENTELEMETRY_CPP_VERSION} -b v${OPENTELEMETRY_CPP_VERSION} \ - && mkdir build \ - && cd build \ - && cmake .. -DCMAKE_CXX_STANDARD=17 -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ - -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF \ - -DWITH_EXAMPLES=OFF -DWITH_OTLP_GRPC=ON \ - && make -j$(nproc || sysctl -n hw.ncpu || echo 1) install && cd ../.. && rm -rf opentelemetry-cpp + && cd opentelemetry-cpp/ \ + && git checkout tags/v${OPENTELEMETRY_CPP_VERSION} -b v${OPENTELEMETRY_CPP_VERSION} \ + && mkdir build \ + && cd build \ + && cmake .. -DCMAKE_CXX_STANDARD=17 -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ + -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF \ + -DWITH_EXAMPLES=OFF -DWITH_OTLP_GRPC=ON \ + && make -j$(nproc || sysctl -n hw.ncpu || echo 1) install && cd ../.. COPY . /currencyservice @@ -38,5 +37,11 @@ RUN cd /currencyservice \ && cmake .. \ && make -j$(nproc || sysctl -n hw.ncpu || echo 1) install + +FROM alpine as release + +RUN apk update && apk add grpc-dev protobuf-dev +COPY --from=builder /usr/local /usr/local + EXPOSE ${CURRENCY_SERVICE_PORT} ENTRYPOINT ./usr/local/bin/currencyservice ${CURRENCY_SERVICE_PORT}