diff options
| author | Saumit <justsaumit@protonmail.com> | 2025-09-27 02:14:26 +0530 |
|---|---|---|
| committer | Saumit <justsaumit@protonmail.com> | 2025-09-27 02:14:26 +0530 |
| commit | 82e03978b89938219958032efb1448cc76baa181 (patch) | |
| tree | 626f3e54d52ecd49be0ed3bee30abacc0453d081 /src/shipping/Dockerfile | |
Initial snapshot - OpenTelemetry demo 2.1.3 -f
Diffstat (limited to 'src/shipping/Dockerfile')
| -rw-r--r-- | src/shipping/Dockerfile | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/shipping/Dockerfile b/src/shipping/Dockerfile new file mode 100644 index 0000000..589b2e4 --- /dev/null +++ b/src/shipping/Dockerfile @@ -0,0 +1,45 @@ +# Copyright The OpenTelemetry Authors +# SPDX-License-Identifier: Apache-2.0 + + +FROM --platform=${BUILDPLATFORM} docker.io/library/rust:1.88 AS builder +ARG TARGETARCH +ARG TARGETPLATFORM +ARG BUILDPLATFORM + +RUN echo Building on ${BUILDPLATFORM} for ${TARGETPLATFORM} + +# Install dependencies - cross-compilation setup for ARM64, native otherwise +RUN apt-get update && \ + if [ "${TARGETPLATFORM}" = "linux/arm64" ] && [ "${BUILDPLATFORM}" != "linux/arm64" ] ; then \ + apt-get install --no-install-recommends -y g++-aarch64-linux-gnu libc6-dev-arm64-cross libprotobuf-dev protobuf-compiler ca-certificates && \ + rustup target add aarch64-unknown-linux-gnu; \ + else \ + apt-get install --no-install-recommends -y g++ libc6-dev libprotobuf-dev protobuf-compiler ca-certificates; \ + fi + +WORKDIR /app/ + +COPY /src/shipping/ /app/ + +# Build - cross-compile for ARM64 or native build +RUN if [ "${TARGETPLATFORM}" = "linux/arm64" ] && [ "${BUILDPLATFORM}" != "linux/arm64" ] ; then \ + env CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \ + CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc \ + CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++ \ + cargo build -r --target aarch64-unknown-linux-gnu && \ + cp /app/target/aarch64-unknown-linux-gnu/release/shipping /app/target/release/shipping; \ + else \ + cargo build -r; \ + fi + + +FROM gcr.io/distroless/cc-debian12:nonroot + +WORKDIR /app + +COPY --from=builder /app/target/release/shipping shipping + +EXPOSE ${SHIPPING_PORT} + +CMD ["./shipping"] |
