Skip to content

Commit a2da98f

Browse files
committed
Update cli.Dockerfile
1 parent 77efdbc commit a2da98f

File tree

1 file changed

+74
-27
lines changed

1 file changed

+74
-27
lines changed

dockerfiles/cli.Dockerfile

Lines changed: 74 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,80 @@
11
# Build in a full featured container
22
ARG TARGETARCH
33

4-
FROM --platform=linux/$TARGETARCH golang:1.25 AS build
4+
# Source stage: prepare source code and install Antithesis SDK
5+
FROM --platform=linux/$TARGETARCH golang:1.25 AS source
56

67
WORKDIR /app
78

89
# Install protobuf compiler and git
910
RUN apt-get update \
10-
&& DEBIAN_FRONTEND=noninteractive \
11+
&& DEBIAN_FRONTEND=noninteractive \
1112
apt-get install --no-install-recommends --assume-yes \
12-
protobuf-compiler=3.21.12-11 libprotoc-dev=3.21.12-11 \
13-
&& rm -rf /var/lib/apt/lists/*
13+
protobuf-compiler=3.21.12-11 libprotoc-dev=3.21.12-11 \
14+
&& rm -rf /var/lib/apt/lists/*
1415

15-
# Install Rust for kitchen-sink-gen
16-
RUN wget -q -O - https://sh.rustup.rs | sh -s -- -y \
17-
&& . $HOME/.cargo/env \
18-
&& echo "TARGETARCH: $TARGETARCH" \
19-
&& ARCH=$(uname -m) \
20-
&& echo "uname -m: $ARCH" \
21-
&& if [ "$TARGETARCH" = "arm64" ] || [ "$ARCH" = "aarch64" ]; then \
22-
rustup target add aarch64-unknown-linux-musl; \
23-
else \
24-
rustup target add x86_64-unknown-linux-musl; \
25-
fi
26-
ENV PATH="$PATH:/root/.cargo/bin"
27-
28-
# Copy CLI build dependencies
16+
# Copy all source code
2917
COPY cmd ./cmd
3018
COPY loadgen ./loadgen
3119
COPY scenarios ./scenarios
3220
COPY workers ./workers/
21+
COPY common ./common
3322
COPY go.mod go.sum ./
3423

24+
# Install Antithesis SDK and instrumentor
25+
RUN go get github.com/antithesishq/antithesis-sdk-go@feature-assertion-wrappers && \
26+
go install github.com/antithesishq/antithesis-sdk-go/tools/antithesis-go-instrumentor@feature-assertion-wrappers
27+
28+
# Instrumented stage: instrument the code with Antithesis
29+
FROM --platform=linux/$TARGETARCH golang:1.25 AS instrumented
30+
31+
# Copy source and instrumentor
32+
COPY --from=source /app /omes_source
33+
COPY --from=source /go/bin/antithesis-go-instrumentor /go/bin/antithesis-go-instrumentor
34+
COPY --from=source /go/pkg/mod /go/pkg/mod
35+
36+
WORKDIR /omes_source
37+
38+
# Instrument OMES with Antithesis
39+
RUN echo "🔧 Instrumenting OMES..." && \
40+
mkdir /omes_transformed && \
41+
antithesis-go-instrumentor /omes_source /omes_transformed && \
42+
cp -r /omes_source/.git /omes_transformed/ 2>/dev/null || true && \
43+
mv /omes_transformed /instrumented && \
44+
mkdir -p /notifier /symbols && \
45+
mv /instrumented/notifier.json /notifier/ 2>/dev/null || true && \
46+
mv /instrumented/symbols.json /symbols/ 2>/dev/null || true
47+
48+
# Build stage: compile the instrumented code
49+
FROM --platform=linux/$TARGETARCH golang:1.25 AS build
50+
51+
ARG TARGETARCH
52+
53+
WORKDIR /app
54+
55+
# Install protobuf compiler and git
56+
RUN apt-get update \
57+
&& DEBIAN_FRONTEND=noninteractive \
58+
apt-get install --no-install-recommends --assume-yes \
59+
protobuf-compiler=3.21.12-11 libprotoc-dev=3.21.12-11 \
60+
&& rm -rf /var/lib/apt/lists/*
61+
62+
# Install Rust for kitchen-sink-gen
63+
RUN wget -q -O - https://sh.rustup.rs | sh -s -- -y \
64+
&& . $HOME/.cargo/env \
65+
&& echo "TARGETARCH: $TARGETARCH" \
66+
&& ARCH=$(uname -m) \
67+
&& echo "uname -m: $ARCH" \
68+
&& if [ "$TARGETARCH" = "arm64" ] || [ "$ARCH" = "aarch64" ]; then \
69+
rustup target add aarch64-unknown-linux-musl; \
70+
else \
71+
rustup target add x86_64-unknown-linux-musl; \
72+
fi
73+
ENV PATH="$PATH:/root/.cargo/bin"
74+
75+
# Copy instrumented source code
76+
COPY --from=instrumented /instrumented /app
77+
3578
# Build the CLI
3679
RUN CGO_ENABLED=0 go build -o temporal-omes ./cmd
3780

@@ -40,22 +83,26 @@ RUN go install google.golang.org/protobuf/cmd/[email protected]
4083

4184
# Build kitchen-sink-gen (statically linked)
4285
RUN cd loadgen/kitchen-sink-gen && \
43-
echo "TARGETARCH: $TARGETARCH" && \
44-
ARCH=$(uname -m) && \
45-
echo "uname -m: $ARCH" && \
46-
if [ "$TARGETARCH" = "arm64" ] || [ "$ARCH" = "aarch64" ]; then \
86+
echo "TARGETARCH: $TARGETARCH" && \
87+
ARCH=$(uname -m) && \
88+
echo "uname -m: $ARCH" && \
89+
if [ "$TARGETARCH" = "arm64" ] || [ "$ARCH" = "aarch64" ]; then \
4790
RUST_TARGET=aarch64-unknown-linux-musl; \
48-
else \
91+
else \
4992
RUST_TARGET=x86_64-unknown-linux-musl; \
50-
fi && \
51-
echo "Building for rust target: $RUST_TARGET" && \
52-
RUSTFLAGS='-C target-feature=+crt-static' cargo build --release --target $RUST_TARGET
93+
fi && \
94+
echo "Building for rust target: $RUST_TARGET" && \
95+
RUSTFLAGS='-C target-feature=+crt-static' cargo build --release --target $RUST_TARGET
5396

5497
# Copy the CLI to a distroless "run" container
5598
FROM --platform=linux/$TARGETARCH gcr.io/distroless/static-debian11:nonroot
5699

57100
COPY --from=build /app/temporal-omes /app/temporal-omes
58101
COPY --from=build /app/loadgen/kitchen-sink-gen/target/*/release/kitchen-sink-gen /app/kitchen-sink-gen
59102

103+
# Copy instrumentation metadata
104+
COPY --from=instrumented /notifier /notifier
105+
COPY --from=instrumented /symbols /symbols
106+
60107
# Default entrypoint for CLI usage
61-
ENTRYPOINT ["/app/temporal-omes"]
108+
ENTRYPOINT ["/app/temporal-omes"]

0 commit comments

Comments
 (0)