@@ -20,7 +20,6 @@ set -eu
20
20
_SELF=$( dirname $0 )
21
21
source " ${_SELF} /../common.sh"
22
22
23
-
24
23
# annotate create temp markdown file if not exists
25
24
# this file will be later used to annotate the build
26
25
# it appends to the file the message passed as argument
@@ -33,37 +32,39 @@ write_annotation() {
33
32
cat $BUILDKITE_ANNOTATE_FILE | buildkite-agent annotate --style info
34
33
}
35
34
35
+ BUILD_VERSION=" $( jq -r ' .version' .package-version) "
36
+ DOCKER_TAG=" git-${VERSION} "
36
37
PRIVATE_REPO=" docker.elastic.co/observability-ci/ecp-elastic-agent-service"
37
- SNAPSHOT_DRA_URL=https://snapshots.elastic.co/latest/master.json
38
+ PRIVATE_IMAGE= " ${PRIVATE_REPO} : ${DOCKER_TAG} "
38
39
39
- DRA_RESULT=$( curl -s -X GET " $SNAPSHOT_DRA_URL " )
40
- echo " $DRA_RESULT "
41
- BUILD_ID=$( echo " $DRA_RESULT " | jq ' .build_id' | tr -d ' "' )
42
- BUILD_VERSION=$( echo " $DRA_RESULT " | jq ' .version' | tr -d ' "' )
40
+ # download the amd64 and arm64 builds of the image from the previous steps
41
+ buildkite-agent artifact download " build/distributions/**" . --step " packaging-service-container-amd64"
42
+ buildkite-agent artifact download " build/distributions/**" . --step " packaging-service-container-arm64"
43
43
44
- MANIFEST_URL=" https://snapshots.elastic.co/$BUILD_ID /agent-package/agent-artifacts-$BUILD_VERSION .json"
45
- GIT_COMMIT=$( curl -s -X GET " $MANIFEST_URL " | jq ' .projects["elastic-agent-core"]["commit_hash"]' | tr -d ' "' )
46
- GIT_SHORT_COMMIT=$( echo " $GIT_COMMIT " | cut -c1-12)
44
+ # AMD64
45
+ docker load -i ./build/distributions/elastic-agent-service-$DOCKER_TAG -$BUILD_VERSION -linux-amd64.docker.tar.gz
46
+ docker image tag " elastic-agent-service:$DOCKER_TAG " " $PRIVATE_IMAGE "
47
+ docker push " $PRIVATE_IMAGE "
48
+ AMD64_DIGEST=$( docker image inspect --format " {{index .RepoDigests 0}}" " $PRIVATE_IMAGE " )
47
49
48
- DOCKER_TAG=" git-${GIT_SHORT_COMMIT} "
49
- PRIVATE_IMAGE=" ${PRIVATE_REPO} :${DOCKER_TAG} "
50
+ # ARM64 (overwrites AMD64 tags)
51
+ docker load -i ./build/distributions/elastic-agent-service-$DOCKER_TAG -$BUILD_VERSION -linux-arm64.docker.tar.gz
52
+ docker image tag " elastic-agent-service:$DOCKER_TAG " " $PRIVATE_IMAGE "
53
+ docker push " $PRIVATE_IMAGE "
54
+ ARM64_DIGEST=$( docker image inspect --format " {{index .RepoDigests 0}}" " $PRIVATE_IMAGE " )
50
55
51
- # TODO: let's avoid accessing vault directly but use the vault plugin itself
52
- # https://github.com/elastic/vault-docker-login-buildkite-plugin does not support
53
- # the `skopeo` command by default but looks for the current installed tools in the runner
54
- # Let's contribute in a follow-up PR to support `skopeo` as well.
55
- DOCKER_REGISTRY_SECRET_PATH=" kv/ci-shared/platform-ingest/docker_registry_prod"
56
- DOCKER_REGISTRY=" docker.elastic.co"
57
- DOCKER_USERNAME_SECRET=$( retry 5 vault kv get -field user " ${DOCKER_REGISTRY_SECRET_PATH} " )
58
- DOCKER_PASSWORD_SECRET=$( retry 5 vault kv get -field password " ${DOCKER_REGISTRY_SECRET_PATH} " )
59
- skopeo login --username " ${DOCKER_USERNAME_SECRET} " --password " ${DOCKER_PASSWORD_SECRET} " " ${DOCKER_REGISTRY} "
60
- skopeo copy --all " docker://docker.elastic.co/cloud-release/elastic-agent-service:$BUILD_ID -SNAPSHOT" " docker://$PRIVATE_IMAGE "
56
+ # at this point the $PRIVATE_IMAGE is pointing to only the arm64 based image, we need the image to
57
+ # be a multi-architecture based image so we create an image from the digests and tag it the same and
58
+ # push it to the registry (aka. make the tag now a multi-architecture based image)
59
+ docker buildx imagetools create -t " $PRIVATE_IMAGE " \
60
+ " $AMD64_DIGEST " \
61
+ " $ARM64_DIGEST "
62
+ docker push " $PRIVATE_IMAGE "
61
63
62
64
annotate " * Image: $PRIVATE_IMAGE "
63
- annotate " * Short commit: $GIT_SHORT_COMMIT "
64
- annotate " * Commit: https://github.com/elastic/elastic-agent/commit/$GIT_COMMIT "
65
- annotate " * Manifest: $MANIFEST_URL "
65
+ annotate " * Short commit: $VERSION "
66
+ annotate " * Commit: https://github.com/elastic/elastic-agent/commit/$VERSION "
66
67
67
- buildkite-agent meta-data set " git-short-commit" " $GIT_SHORT_COMMIT "
68
+ buildkite-agent meta-data set " git-short-commit" " $VERSION "
68
69
69
70
write_annotation
0 commit comments