-
Notifications
You must be signed in to change notification settings - Fork 16
chore: [SVLS-6279] refactor the build pipelines #552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
apiarian-datadog
merged 52 commits into
main
from
aleksandr.pasechnik/svls-6279-refactor-gitlab-build-pipelines
Feb 18, 2025
Merged
Changes from all commits
Commits
Show all changes
52 commits
Select commit
Hold shift + click to select a range
6dee3a5
chore: fork and simplify the gitlab pipelines
apiarian-datadog 07ac616
chore: gitlab-ci.yml needs to be hidden
apiarian-datadog 828a698
chore: a bit clearer pipeline steps
apiarian-datadog 78d7152
chore: docs suggest we do not need to manually pass in the variables
apiarian-datadog 74e563a
chore: check that we are using the agent branch as expected
apiarian-datadog 0a1a423
chore: we should not alias the variables
apiarian-datadog 30735b9
pull the lint and fmt and clippy checks into an initial stage
apiarian-datadog 55e98d2
chore: clarify that our checks are in cargo
apiarian-datadog 02c94d1
chore: add a bit of documenttion for our datadog_wrapper script
apiarian-datadog bffd627
chore: try to start using flavors instead of architectures
apiarian-datadog 8017a4a
chore: config needs to know about the flavors
apiarian-datadog a5620f3
chore: if in the template, not the job
apiarian-datadog 13db576
chore: move the rest of the code checks into the flavors loop
apiarian-datadog 95d194c
chore: separate out the compile stage for go
apiarian-datadog 2a575d2
chore: speed up builds by skipping checks for now
apiarian-datadog 33f0c78
Revert "chore: speed up builds by skipping checks for now"
apiarian-datadog 83abe10
chore: fix another typo
apiarian-datadog ab9cc90
chore: fix scratch cmd path
apiarian-datadog 16bb63a
chore: drop the serverless-init bits for go agent compilation in gitlab
apiarian-datadog 0edab6c
chore: do we need to say dockerfile experimental if that tag was last…
apiarian-datadog 78ea098
chore: missed a few bits
apiarian-datadog a43c9e9
chore: fix lint and correct alpine flag check
apiarian-datadog 3c4b9f1
chore: also compile bottlecap
apiarian-datadog 597b311
chore: build the layers
apiarian-datadog 21a143d
chore: building the layer probably does not need ALPINE stuff
apiarian-datadog 6ca47d7
chore: fix typo
apiarian-datadog aba4411
chore: use the new layer builders instead of the old ones
apiarian-datadog d530262
chore: move layer check into the flavor loop
apiarian-datadog 33bb3e1
chore: move layer publish into the flavors loop
apiarian-datadog a133afc
chore: add an easy-to-use sanbox job
apiarian-datadog 0465f9c
chore: move cargo deps around
apiarian-datadog cf23570
chore: publis private images with flavors
apiarian-datadog 1840f9b
chore: layers for all
apiarian-datadog c6f67b1
chore: move layer signing under flavors
apiarian-datadog 3682a33
chore: bring back mutli-arch primate image builds
apiarian-datadog 280e9c4
chore: move build and publish public images in the loop too
apiarian-datadog 4d2b8be
separate sandbox from publish for convenience
apiarian-datadog 41f53d6
chore: clean up all the extra files
apiarian-datadog d0061ff
chore: missed a bit
apiarian-datadog ca02731
chore: rename stages
apiarian-datadog 62e13a4
chore: bring back some dockerfiles i accidentally deleted
apiarian-datadog 64029a6
chore: we only need layer size checks for prod deploys
apiarian-datadog 7b68904
bring back the variables
apiarian-datadog 722a068
Revert "bring back the variables"
apiarian-datadog b1a7f65
chore: do we need to forward pipeline variablles?
apiarian-datadog 0cda5dc
chore: add a note about the important forwarding flag
apiarian-datadog 5a813e3
chore: prevent actual gitlab pushes
apiarian-datadog 26e1c6a
Revert "chore: prevent actual gitlab pushes"
apiarian-datadog cc2ee94
chore: logical sorting and better naming
apiarian-datadog 5fcf2bc
chore: mark the existing scripts as potentially dangerous for now
apiarian-datadog 7673d54
Revert "chore: mark the existing scripts as potentially dangerous for…
apiarian-datadog 44310e2
chore: rename sanbox layer publish
apiarian-datadog File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| flavors: | ||
| - name: amd64 | ||
| arch: amd64 | ||
| alpine: 0 | ||
| needs_code_checks: true | ||
| needs_layer_publish: true | ||
| suffix: amd64 | ||
|
|
||
| - name: arm64 | ||
| arch: arm64 | ||
| alpine: 0 | ||
| needs_code_checks: true | ||
| needs_layer_publish: true | ||
| suffix: arm64 | ||
|
|
||
| - name: amd64, alpine | ||
| arch: amd64 | ||
| alpine: 1 | ||
| needs_code_checks: false | ||
| needs_layer_publish: false | ||
| suffix: amd64-alpine | ||
|
|
||
| - name: arm64, alpine | ||
| arch: arm64 | ||
| alpine: 1 | ||
| needs_code_checks: false | ||
| needs_layer_publish: false | ||
| suffix: arm64-alpine | ||
|
|
||
| # Unfortunately our mutli-arch images don't fit nicely into the flavors | ||
| # structure above. | ||
| multi_arch_image_flavors: | ||
| - name: basic | ||
| alpine: 0 | ||
| platform: linux/amd64,linux/arm64 | ||
| dependency_names: [amd64, arm64] | ||
| suffix: "" | ||
|
|
||
| - name: alpine | ||
| alpine: 1 | ||
| platform: linux/amd64,linux/arm64 | ||
| dependency_names: ["amd64, alpine", "arm64, alpine"] | ||
| suffix: "-alpine" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| FROM alpine:3.16 AS compiler | ||
| ARG PLATFORM | ||
| RUN apk add --no-cache curl gcc musl-dev make unzip bash autoconf automake libtool g++ | ||
|
|
||
| SHELL ["/bin/bash", "-c"] | ||
|
|
||
| # Install Protocol Buffers, from package instead of manually | ||
| RUN apk add --no-cache protoc | ||
|
|
||
| # Install Rust Toolchain | ||
| RUN curl https://sh.rustup.rs -sSf | \ | ||
| sh -s -- --profile minimal --default-toolchain stable-$PLATFORM-unknown-linux-musl -y | ||
| ENV PATH=/root/.cargo/bin:$PATH | ||
| RUN rustup component add rust-src --toolchain stable-$PLATFORM-unknown-linux-musl | ||
|
|
||
| # Build Bottlecap | ||
| RUN mkdir -p /tmp/dd | ||
| COPY ./bottlecap/src /tmp/dd/bottlecap/src | ||
| COPY ./bottlecap/Cargo.toml /tmp/dd/bottlecap/Cargo.toml | ||
| COPY ./bottlecap/Cargo.lock /tmp/dd/bottlecap/Cargo.lock | ||
| # Added `-C link-arg=-lgcc` for alpine. | ||
| ENV RUSTFLAGS="-C panic=abort -C link-arg=-lgcc" | ||
| WORKDIR /tmp/dd/bottlecap | ||
| RUN --mount=type=cache,target=/root/.cargo/registry cargo +stable build --release --target $PLATFORM-unknown-linux-musl | ||
| RUN cp /tmp/dd/bottlecap/target/$PLATFORM-unknown-linux-musl/release/bottlecap /tmp/dd/bottlecap/bottlecap | ||
|
|
||
| # keep the smallest possible docker image | ||
| FROM scratch | ||
| COPY --from=compiler /tmp/dd/bottlecap/bottlecap / | ||
| ENTRYPOINT ["/bottlecap"] | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| FROM public.ecr.aws/lambda/provided:al2 AS compiler | ||
| ARG PLATFORM | ||
| RUN yum install -y curl gcc gcc-c++ make unzip | ||
|
|
||
| # Install Protocol Buffers compiler by hand, since AL2 does not have a recent enough version. | ||
| COPY ./scripts/install-protoc.sh / | ||
| RUN chmod +x /install-protoc.sh && /install-protoc.sh | ||
| RUN curl https://sh.rustup.rs -sSf | \ | ||
| sh -s -- --profile minimal --default-toolchain stable-$PLATFORM-unknown-linux-gnu -y | ||
| ENV PATH=/root/.cargo/bin:$PATH | ||
| RUN rustup component add rust-src --toolchain stable-$PLATFORM-unknown-linux-gnu | ||
| RUN mkdir -p /tmp/dd | ||
| COPY ./bottlecap/src /tmp/dd/bottlecap/src | ||
| COPY ./bottlecap/Cargo.toml /tmp/dd/bottlecap/Cargo.toml | ||
| COPY ./bottlecap/Cargo.lock /tmp/dd/bottlecap/Cargo.lock | ||
| ENV RUSTFLAGS="-C panic=abort" | ||
| WORKDIR /tmp/dd/bottlecap | ||
| RUN --mount=type=cache,target=/usr/local/cargo/registry cargo +stable build --release --target $PLATFORM-unknown-linux-gnu | ||
| RUN cp /tmp/dd/bottlecap/target/$PLATFORM-unknown-linux-gnu/release/bottlecap /tmp/dd/bottlecap/bottlecap | ||
|
|
||
| # keep the smallest possible docker image | ||
| FROM scratch | ||
| COPY --from=compiler /tmp/dd/bottlecap/bottlecap / | ||
| ENTRYPOINT ["/bottlecap"] | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| FROM ubuntu:22.04 as compresser | ||
| ARG DATADOG_WRAPPER=datadog_wrapper | ||
| ARG SUFFIX | ||
|
|
||
| RUN apt-get update | ||
| RUN apt-get install -y zip binutils upx | ||
apiarian-datadog marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| COPY .binaries/datadog-agent-$SUFFIX /datadog-agent-go | ||
| RUN strip /datadog-agent-go | ||
| RUN upx -1 /datadog-agent-go | ||
|
|
||
| RUN mkdir /extensions | ||
| WORKDIR /extensions | ||
|
|
||
| COPY .binaries/bottlecap-$SUFFIX /extensions/datadog-agent | ||
|
|
||
| COPY ./scripts/$DATADOG_WRAPPER /$DATADOG_WRAPPER | ||
| RUN chmod +x /$DATADOG_WRAPPER | ||
|
|
||
| RUN zip -r datadog_extension.zip /extensions /$DATADOG_WRAPPER /datadog-agent-go | ||
|
|
||
| # keep the smallest possible docker image | ||
| FROM scratch | ||
| COPY --from=compresser /extensions/datadog_extension.zip / | ||
| ENTRYPOINT ["/datadog_extension.zip"] | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| FROM scratch | ||
| ARG TARGETARCH | ||
| COPY .layers/datadog_extension-$TARGETARCH/extensions/datadog-agent opt/extensions/datadog-agent | ||
| COPY .layers/datadog_extension-$TARGETARCH/datadog-agent-go opt/datadog-agent-go | ||
| COPY --chmod=0755 scripts/datadog_wrapper opt/datadog_wrapper |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| FROM scratch | ||
| ARG TARGETARCH | ||
| COPY .layers/datadog_extension-$TARGETARCH-alpine/extensions/datadog-agent opt/extensions/datadog-agent | ||
| COPY .layers/datadog_extension-$TARGETARCH-alpine/datadog-agent-go opt/datadog-agent-go | ||
| COPY --chmod=0755 scripts/datadog_wrapper opt/datadog_wrapper |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| FROM alpine:3.16 AS compiler | ||
| ARG EXTENSION_VERSION | ||
| ARG AGENT_VERSION | ||
| ARG BUILD_TAGS | ||
|
|
||
| RUN apk add --no-cache git make musl-dev gcc | ||
| COPY --from=golang:1.23.6-alpine /usr/local/go/ /usr/lib/go | ||
|
|
||
| ENV GOROOT=/usr/lib/go | ||
| ENV GOPATH=/go | ||
| ENV PATH=/go/bin:$PATH | ||
|
|
||
| RUN mkdir -p ${GOPATH}/src ${GOPATH}/bin | ||
| RUN mkdir -p /tmp/dd/datadog-agent | ||
|
|
||
| # cache dependencies | ||
| COPY ./scripts/.cache/go.mod /tmp/dd/datadog-agent | ||
| COPY ./scripts/.cache/go.sum /tmp/dd/datadog-agent | ||
| WORKDIR /tmp/dd/datadog-agent | ||
|
|
||
| # copy source files (/tgz gets unzip automatically by Docker) | ||
| ADD ./scripts/.src/datadog-agent.tgz /tmp/dd | ||
|
|
||
| # build the extension | ||
| WORKDIR /tmp/dd/datadog-agent/cmd/serverless | ||
| # add the current version number to the tags package before compilation | ||
|
|
||
| RUN --mount=type=cache,target=/go/pkg/mod \ | ||
| --mount=type=cache,target=/root/.cache/go-build \ | ||
| if [ -z "$AGENT_VERSION" ]; then \ | ||
| /usr/lib/go/bin/go build -ldflags="-w -extldflags '-static' \ | ||
| -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 -extldflags '-static' \ | ||
| -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) | ||
|
|
||
| RUN strip datadog-agent | ||
|
|
||
| # keep the smallest possible docker image | ||
| FROM scratch | ||
| COPY --from=compiler /tmp/dd/datadog-agent/cmd/serverless/datadog-agent / | ||
| ENTRYPOINT ["/datadog-agent"] | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| FROM public.ecr.aws/lambda/provided:al2 AS compiler | ||
| ARG EXTENSION_VERSION | ||
| ARG AGENT_VERSION | ||
| ARG BUILD_TAGS | ||
| RUN mkdir -p /tmp/dd/datadog-agent | ||
|
|
||
| RUN yum install -y wget tar gzip gcc | ||
| RUN arch="$(uname -m)"; \ | ||
| if [ "${arch}" = 'aarch64' ]; then \ | ||
| arch='arm64'; \ | ||
| fi; \ | ||
| if [ "${arch}" = 'x86_64' ]; then \ | ||
| arch='amd64'; \ | ||
| fi; \ | ||
| wget -O go1.23.6.linux-${arch}.tar.gz https://go.dev/dl/go1.23.6.linux-${arch}.tar.gz; \ | ||
| tar -C /usr/local -xzf go1.23.6.linux-${arch}.tar.gz | ||
|
|
||
| # cache dependencies | ||
| COPY ./scripts/.cache/go.mod /tmp/dd/datadog-agent | ||
| COPY ./scripts/.cache/go.sum /tmp/dd/datadog-agent | ||
| WORKDIR /tmp/dd/datadog-agent | ||
|
|
||
| # copy source files (/tgz gets unzip automatically by Docker) | ||
| ADD ./scripts/.src/datadog-agent.tgz /tmp/dd | ||
|
|
||
| # build the extension | ||
| WORKDIR /tmp/dd/datadog-agent/cmd/serverless | ||
| # add the current version number to the tags package before compilation | ||
|
|
||
| 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; \ | ||
| 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; \ | ||
| fi | ||
|
|
||
| RUN /usr/local/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) | ||
|
|
||
| RUN strip datadog-agent | ||
|
|
||
| # keep the smallest possible docker imag | ||
| FROM scratch | ||
| COPY --from=compiler /tmp/dd/datadog-agent/cmd/serverless/datadog-agent / | ||
| ENTRYPOINT ["/datadog-agent"] | ||
|
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.