Skip to content

Commit

Permalink
fixup: Extend module path support to instrumentation
Browse files Browse the repository at this point in the history
  • Loading branch information
marun committed Aug 28, 2024
1 parent 51e54a5 commit 782c6ae
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
15 changes: 10 additions & 5 deletions tests/antithesis/Dockerfile.builder-instrumented
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,19 @@ FROM docker.io/antithesishq/go-instrumentor AS instrumentor
FROM golang:$GO_VERSION-bullseye

WORKDIR /build
# Copy and download dependencies using go mod
COPY go.mod .
COPY go.sum .
RUN go mod download

# Copy the code into the container
COPY . .

# Providing a non-empty MODULE_PATH supports the case where the target module is
# not at the root of the repo but its go.mod references other modules in the repo
# (including the root).
ARG MODULE_PATH=.

# Download dependencies for the specified go module if a path was provided,
# otherwise download dependencies for the current directory.
RUN cd $MODULE_PATH && go mod download

# Ensure pre-existing builds are not available for inclusion in the final image
RUN [ -d ./build ] && rm -rf ./build/* || true

Expand All @@ -38,7 +43,7 @@ RUN cp -r .git /opt/tmp/
RUN /opt/antithesis/bin/goinstrumentor \
-stderrthreshold=INFO \
-antithesis /opt/antithesis/instrumentation \
. \
$MODULE_PATH \
/instrumented

WORKDIR /instrumented/customer
Expand Down
10 changes: 4 additions & 6 deletions tests/antithesis/Dockerfile.builder-uninstrumented
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@ WORKDIR /build
# Copy the code into the container
COPY . .

# Download dependencies of the main go module
RUN go mod download

# Providing a non-empty MODULE_PATH supports the case where the target module is
# not at the root of the repo but its go.mod references other modules in the repo
# (including the root).
ARG MODULE_PATH
ARG MODULE_PATH=.

# Download dependencies for the specified go module if a path was provided
RUN [ -n $MODULE_PATH ] && (cd $MODULE_PATH && go mod download) || true
# Download dependencies for the specified go module if a path was provided,
# otherwise download dependencies for the current directory.
RUN cd $MODULE_PATH && go mod download

# Ensure pre-existing builds are not available for inclusion in the final image
RUN [ -d ./build ] && rm -rf ./build/* || true

0 comments on commit 782c6ae

Please sign in to comment.