Skip to content

Commit c4a5acc

Browse files
maxdaypurple4reina
andauthored
Fix cloud run build script (go 1.19) (#137)
* Adds AGENT_VERSION and the otlp build tag. * fix go 1.19 * fix go 1.19 --------- Co-authored-by: Rey Abolofia <[email protected]>
1 parent 42a22da commit c4a5acc

File tree

3 files changed

+9
-20
lines changed

3 files changed

+9
-20
lines changed

scripts/Dockerfile.alpine.build

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ ARG AGENT_VERSION
66
ARG CMD_PATH
77
ARG BUILD_TAGS
88

9-
RUN apk add --no-cache git make musl-dev go gcc
9+
RUN apk add --no-cache git make musl-dev gcc
10+
COPY --from=golang:1.19-alpine /usr/local/go/ /usr/lib/go
11+
1012
ENV GOROOT /usr/lib/go
1113
ENV GOPATH /go
1214
ENV PATH /go/bin:$PATH
@@ -28,18 +30,11 @@ WORKDIR /tmp/dd/datadog-agent/"${CMD_PATH}"
2830

2931
RUN --mount=type=cache,target=/go/pkg/mod \
3032
--mount=type=cache,target=/root/.cache/go-build \
31-
if [ -z "$AGENT_VERSION" ]; then \
32-
go build -ldflags="-w \
33+
/usr/lib/go/bin/go build -ldflags="-w \
3334
-X github.com/DataDog/datadog-agent/pkg/serverless/tags.currentExtensionVersion=$EXTENSION_VERSION" \
34-
-tags "${BUILD_TAGS}" -o datadog-agent; \
35-
else \
36-
go build -ldflags="-w \
37-
-X github.com/DataDog/datadog-agent/pkg/serverless/tags.currentExtensionVersion=$EXTENSION_VERSION \
38-
-X github.com/DataDog/datadog-agent/pkg/version.agentVersionDefault=$AGENT_VERSION" \
39-
-tags "${BUILD_TAGS}" -o datadog-agent; \
40-
fi
35+
-tags "${BUILD_TAGS}" -o datadog-agent;
4136

42-
RUN go tool nm datadog-agent | grep -w 'github.com/DataDog/datadog-agent/pkg/version.agentVersionDefault' || \
37+
RUN /usr/lib/go/bin/go tool nm datadog-agent | grep -w 'github.com/DataDog/datadog-agent/pkg/version.agentVersionDefault' || \
4338
(echo "agentVersionDefault variable doesn't exist" && exit 1)
4439

4540
# zip the extension

scripts/build_binary_and_layer_dockerized.sh

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,7 @@ else
2626
fi
2727

2828
if [ -z "$BUILD_TAGS" ]; then
29-
if [ -z "$CLOUD_RUN" ]; then
30-
BUILD_TAGS="serverless otlp"
31-
else
32-
BUILD_TAGS="serverless"
33-
fi
29+
BUILD_TAGS="serverless otlp"
3430
fi
3531

3632
AGENT_PATH="../datadog-agent"
@@ -86,10 +82,8 @@ function docker_build_zip {
8682
if [ "$CLOUD_RUN" == "true" ]; then
8783
echo "Building for cloud run (both arch + alpine)"
8884
docker_build_zip amd64
89-
docker_build_zip arm64
9085
BUILD_FILE=Dockerfile.alpine.build
9186
docker_build_zip amd64 -alpine
92-
docker_build_zip arm64 -alpine
9387
elif [ "$ARCHITECTURE" == "amd64" ]; then
9488
echo "Building for amd64 only"
9589
docker_build_zip amd64

scripts/build_cloud_run.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# This product includes software developed at Datadog (https://www.datadoghq.com/).
66
# Copyright 2021 Datadog, Inc.
77

8-
# Usage: VERSION=5 ARCHITECTURE=[amd64|arm64] ./scripts/build_cloud_run.sh
8+
# Usage: AGENT_VERSION=7.43.0 VERSION=5 ARCHITECTURE=[amd64|arm64] ./scripts/build_cloud_run.sh
99

1010
# Optional environment variables:
1111
# VERSION - Use a specific version number
@@ -16,4 +16,4 @@ set -e
1616
SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
1717
cd $SCRIPTS_DIR/..
1818

19-
VERSION=$VERSION ARCHITECTURE=$ARCHITECTURE CLOUD_RUN=true ./scripts/build_binary_and_layer_dockerized.sh
19+
AGENT_VERSION=$AGENT_VERSION VERSION=$VERSION ARCHITECTURE=$ARCHITECTURE CLOUD_RUN=true ./scripts/build_binary_and_layer_dockerized.sh

0 commit comments

Comments
 (0)