Skip to content

Commit

Permalink
Display correct Agent version in Alpine builds (#422)
Browse files Browse the repository at this point in the history
Set `datadog-agent/pkg/version.agentVersionDefault` to the `$AGENT_VERSION` env var in the Alpine build script.
  • Loading branch information
nhulston authored Oct 22, 2024
1 parent 03bb1ec commit 890e779
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .gitlab/scripts/check_layer_size.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ if [ -z "$LAYER_FILE" ]; then
exit 1
fi

MAX_LAYER_COMPRESSED_SIZE_KB=$(expr 18 \* 1024) # 17 MB, amd64 is 17, while arm64 is 15
MAX_LAYER_COMPRESSED_SIZE_KB=$(expr 19 \* 1024) # 19 MB, amd64 is 19, while arm64 is 15
MAX_LAYER_UNCOMPRESSED_SIZE_KB=$(expr 49 \* 1024) # 49 MB, amd is 49, while arm64 is 48

LAYERS_DIR=".layers"
Expand Down
13 changes: 10 additions & 3 deletions scripts/Dockerfile.alpine.build
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,16 @@ WORKDIR /tmp/dd/datadog-agent/"${CMD_PATH}"

RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
/usr/lib/go/bin/go build -ldflags="-w \
-X github.com/DataDog/datadog-agent/pkg/serverless/tags.currentExtensionVersion=$EXTENSION_VERSION" \
-tags "${BUILD_TAGS}" -o datadog-agent;
if [ -z "$AGENT_VERSION" ]; then \
/usr/lib/go/bin/go build -ldflags="-w \
-X github.com/DataDog/datadog-agent/pkg/serverless/tags.currentExtensionVersion=$EXTENSION_VERSION" \
-tags "${BUILD_TAGS}" -o datadog-agent; \
else \
/usr/lib/go/bin/go build -ldflags="-w \
-X github.com/DataDog/datadog-agent/pkg/serverless/tags.currentExtensionVersion=$EXTENSION_VERSION \
-X github.com/DataDog/datadog-agent/pkg/version.agentVersionDefault=$AGENT_VERSION" \
-tags "${BUILD_TAGS}" -o datadog-agent; \
fi

RUN /usr/lib/go/bin/go tool nm datadog-agent | grep -w 'github.com/DataDog/datadog-agent/pkg/version.agentVersionDefault' || \
(echo "agentVersionDefault variable doesn't exist" && exit 1)
Expand Down
14 changes: 7 additions & 7 deletions scripts/Dockerfile.build
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ WORKDIR /tmp/dd/datadog-agent/"${CMD_PATH}"
RUN --mount=type=cache,target=/root/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
if [ -z "$AGENT_VERSION" ]; then \
/usr/local/go/bin/go build -ldflags="-w \
-X github.com/DataDog/datadog-agent/pkg/serverless/tags.currentExtensionVersion=$EXTENSION_VERSION" \
-tags "${BUILD_TAGS}" -o datadog-agent; \
/usr/local/go/bin/go build -ldflags="-w \
-X github.com/DataDog/datadog-agent/pkg/serverless/tags.currentExtensionVersion=$EXTENSION_VERSION" \
-tags "${BUILD_TAGS}" -o datadog-agent; \
else \
/usr/local/go/bin/go build -ldflags="-w \
-X github.com/DataDog/datadog-agent/pkg/serverless/tags.currentExtensionVersion=$EXTENSION_VERSION \
-X github.com/DataDog/datadog-agent/pkg/version.agentVersionDefault=$AGENT_VERSION" \
-tags "${BUILD_TAGS}" -o datadog-agent; \
/usr/local/go/bin/go build -ldflags="-w \
-X github.com/DataDog/datadog-agent/pkg/serverless/tags.currentExtensionVersion=$EXTENSION_VERSION \
-X github.com/DataDog/datadog-agent/pkg/version.agentVersionDefault=$AGENT_VERSION" \
-tags "${BUILD_TAGS}" -o datadog-agent; \
fi

RUN /usr/local/go/bin/go tool nm datadog-agent | grep -w 'github.com/DataDog/datadog-agent/pkg/version.agentVersionDefault' || \
Expand Down

0 comments on commit 890e779

Please sign in to comment.