Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
thbkrkr committed Sep 20, 2023
1 parent 4ba163b commit fad7150
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 13 deletions.
8 changes: 3 additions & 5 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@ steps:

- label: "publish-image"
commands:
# TODO: setup vault access
#- .buildkite/registry-login.sh
#- make build-push-image
#- make build-image
#- drivah build --push .
- drivah build .
agents:
image: "docker.elastic.co/ci-agent-images/drivah:0.24.2"
image: "docker.elastic.co/ci-agent-images/drivah:0.24.3"
cpu: "4"
memory: "4G"
ephemeralStorage: "20G"
ephemeralStorage: "20G"
4 changes: 4 additions & 0 deletions .buildkite/registry-login.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/bash

# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License 2.0;
# you may not use this file except in compliance with the Elastic License 2.0.

set -eu

username=$(vault read -field=username "$DOCKER_REGISTRY_VAULT_PATH")
Expand Down
1 change: 0 additions & 1 deletion .dockerignore

This file was deleted.

29 changes: 24 additions & 5 deletions build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,36 @@ ARG SHA1
ARG SNAPSHOT

WORKDIR /go/src/github.com/elastic/eck-diagnostics
COPY . ./

RUN ls
RUN make build-binary
COPY go.mod go.mod
COPY go.sum go.sum

RUN --mount=type=ssh go mod download

COPY build build
COPY cmd cmd
COPY internal internal
COPY Makefile Makefile

RUN make build-binary generate-notice.txt

#
# package binaries in a lighter final image
#
FROM alpine:3.18

COPY --from=builder /go/src/github.com/elastic/eck-diagnostics/NOTICE.txt /NOTICE.txt
ARG IMAGE_TAG
ENV IMAGE_TAG=$IMAGE_TAG

RUN apk add --no-cache bash curl

COPY build/scripts /usr/local/bin

COPY --from=builder /go/src/github.com/elastic/eck-diagnostics/artefacts /artefacts
COPY --from=builder /go/src/github.com/elastic/eck-diagnostics/NOTICE.txt /NOTICE.txt

RUN addgroup -S 65536 && adduser -S 65536 -G 65536
USER 65536:65536
WORKDIR /tmp

ENTRYPOINT ["ls", "-1", "/artefacts"]
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
7 changes: 5 additions & 2 deletions build/drivah.toml.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,22 @@ VERSION="${VERSION:-$(cat "$ROOT/VERSION")}"
tag() {
tag="$VERSION-SNAPSHOT"
if [[ "${BUILDKITE_TAG:-}" != "" ]]; then
SNAPSHOT=""
SNAPSHOT="false"
tag="$VERSION"
fi
echo "$tag"
}

IMAGE_TAG="$(tag)"

cat <<EOF
[container.image]
names = ["docker.elastic.co/eck/eck-diagnostics"]
tags = ["latest", "$SHA1", "$(tag)"]
tags = ["latest", "${SHA1}", "${IMAGE_TAG}"]
build_context = ".."
[container.image.build_args]
IMAGE_TAG = "${IMAGE_TAG}"
VERSION = "${VERSION}"
SHA1 = "${SHA1}"
SNAPSHOT = "${SNAPSHOT}"
Expand Down
19 changes: 19 additions & 0 deletions build/scripts/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh

# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License 2.0;
# you may not use this file except in compliance with the Elastic License 2.0.

set -eu

help() {
echo '
Copy the eck-diagnostics binary in the current directory from the container image using:
docker run --rm docker.elastic.co/eck/eck-diagnostics:'"$IMAGE_TAG"' get | sh'
}

case "${1:-}" in
get) sed "s/{{IMAGE_TAG}}/$IMAGE_TAG/" /usr/local/bin/get.sh ;;
*) help ;;
esac
22 changes: 22 additions & 0 deletions build/scripts/get.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh
#
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License 2.0;
# you may not use this file except in compliance with the Elastic License 2.0.
#

# Script to copy the eck-diagnostics binary in the current directory from the container image.
# It is intended to be displayed on stdout and piped into sh.

set -eu

os=$(uname | tr '[:upper:]' '[:lower:]')
arch=$(uname -m | sed -e "s|x86_|amd|" -e "s|aarch|arm|")

docker run --rm -v $(pwd):/tmp --entrypoint cp "docker.elastic.co/eck/eck-diagnostics:{{IMAGE_TAG}}" \
-f "/artefacts/eck-diagnostics-${os}-${arch}" /tmp/eck-diagnostics

echo "eck-diagnostics-${os}-${arch} binary copied in local ✅"
echo
echo "./eck-diagnostics -v"
./eck-diagnostics -v

0 comments on commit fad7150

Please sign in to comment.