Skip to content

Commit

Permalink
Use base image
Browse files Browse the repository at this point in the history
  • Loading branch information
AliDatadog committed Feb 27, 2025
1 parent ecc10be commit b222a58
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
19 changes: 17 additions & 2 deletions .gitlab/container_build/docker_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
- DOCKER_LOGIN=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $DOCKER_REGISTRY_RO user) || exit $?
- $CI_PROJECT_DIR/tools/ci/fetch_secret.sh $DOCKER_REGISTRY_RO token | docker login --username "$DOCKER_LOGIN" --password-stdin "$DOCKER_REGISTRY_URL"
- EXIT="${PIPESTATUS[0]}"; if [ $EXIT -ne 0 ]; then echo "Unable to locate credentials needs gitlab runner restart"; exit $EXIT; fi
- AGENT_BASE_IMAGE_TAG=registry.ddbuild.io/datadog/agent-base-image:v${CI_PIPELINE_ID}-${CI_COMMIT_SHORT_SHA}-base-image-$ARCH
# Build image, use target none label to avoid replication
- docker buildx build --no-cache --push --pull --platform linux/$ARCH --build-arg CIBUILD=true --build-arg GENERAL_ARTIFACTS_CACHE_BUCKET_URL=${GENERAL_ARTIFACTS_CACHE_BUCKET_URL} $BUILD_ARG --build-arg DD_GIT_REPOSITORY_URL=https://github.com/DataDog/datadog-agent --build-arg DD_GIT_COMMIT_SHA=${CI_COMMIT_SHA} --file $BUILD_CONTEXT/Dockerfile --tag ${TARGET_TAG} --label "org.opencontainers.image.created=$(date --rfc-3339=seconds)" --label "org.opencontainers.image.authors=Datadog <[email protected]>" --label "org.opencontainers.image.source=https://github.com/DataDog/datadog-agent" --label "org.opencontainers.image.version=$(inv agent.version)" --label "org.opencontainers.image.revision=${CI_COMMIT_SHA}" --label "org.opencontainers.image.vendor=Datadog, Inc." --label "target=none" $BUILD_CONTEXT
- docker buildx build --no-cache --push --pull --platform linux/$ARCH --build-arg AGENT_BASE_IMAGE_TAG=${AGENT_BASE_IMAGE_TAG} --build-arg CIBUILD=true --build-arg GENERAL_ARTIFACTS_CACHE_BUCKET_URL=${GENERAL_ARTIFACTS_CACHE_BUCKET_URL} $BUILD_ARG --build-arg DD_GIT_REPOSITORY_URL=https://github.com/DataDog/datadog-agent --build-arg DD_GIT_COMMIT_SHA=${CI_COMMIT_SHA} --file $BUILD_CONTEXT/Dockerfile --tag ${TARGET_TAG} --label "org.opencontainers.image.created=$(date --rfc-3339=seconds)" --label "org.opencontainers.image.authors=Datadog <[email protected]>" --label "org.opencontainers.image.source=https://github.com/DataDog/datadog-agent" --label "org.opencontainers.image.version=$(inv agent.version)" --label "org.opencontainers.image.revision=${CI_COMMIT_SHA}" --label "org.opencontainers.image.vendor=Datadog, Inc." --label "target=none" $BUILD_CONTEXT
- FLATTEN_IMAGE=${FLATTEN_IMAGE:-true}
# Squash image if FLATTEN_IMAGE is true
- |
Expand Down Expand Up @@ -200,6 +201,19 @@ docker_build_ot_agent7_arm64:
TAG_SUFFIX: -7-ot-beta
BUILD_ARG: --target test --build-arg DD_AGENT_ARTIFACT=datadog-ot-agent-7*-arm64.tar.xz

# agent base image for standalone images
docker_build_base_image:
extends: [.docker_build_job_definition_amd64, .docker_build_artifact]
rules:
- !reference [.except_mergequeue]
- when: on_success
needs:
variables:
IMAGE: registry.ddbuild.io/ci/datadog-agent/agent-base-image
BUILD_CONTEXT: Dockerfiles/base-image
BUILD_ARG: --target release
TAG_SUFFIX: -base-image

# standalone otel-agent
docker_build_ot_agent_standalone:
extends: [.docker_build_job_definition_amd64, .docker_build_artifact]
Expand All @@ -208,11 +222,12 @@ docker_build_ot_agent_standalone:
- when: on_success
needs:
- job: datadog-ot-agent-7-x64
- job: docker_build_base_image
variables:
IMAGE: registry.ddbuild.io/ci/datadog-agent/otel-agent
BUILD_CONTEXT: Dockerfiles/otel-agent
FLATTEN_IMAGE: false
BUILD_ARG: --target production
BUILD_ARG: --target release
TAG_SUFFIX: -7

docker_build_ot_agent_standalone_arm64:
Expand Down
5 changes: 2 additions & 3 deletions Dockerfiles/otel-agent/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# Use the Ubuntu Slim AMD64 base image
ARG BASE_IMAGE_UBUNTU_VERSION=24.04
ARG BASE_IMAGE_UBUNTU_NAME=noble
ARG BASE_IMAGE_AGENT=registry.ddbuild.io/datadog/base-image-agent
ARG BASE_IMAGE_AGENT_VERSION
ARG AGENT_BASE_IMAGE_TAG

LABEL org.opencontainers.image.title="Otel Agent"
# ------------------------------
Expand Down Expand Up @@ -87,7 +86,7 @@ RUN . venv/bin/activate && invoke otel-agent.build
# Inject the otel-agent in the base image
# ------------------------------

FROM ${BASE_IMAGE_AGENT}:${BASE_IMAGE_AGENT_VERSION} as release
FROM ${AGENT_BASE_IMAGE_TAG} as release

# Copy the built OTel agent from the builder stage
COPY --from=builder /workspace/datadog-agent/bin/otel-agent/otel-agent /opt/datadog-agent/embedded/bin/otel-agent
Expand Down

0 comments on commit b222a58

Please sign in to comment.