From 37f38429e657114b980515ea6438632a7aa3ae7a Mon Sep 17 00:00:00 2001 From: Denys Kondratenko Date: Wed, 8 May 2024 21:38:36 +0200 Subject: [PATCH] Add labels to the containers --- .github/workflows/build.yaml | 8 +++++--- .github/workflows/release.yaml | 7 ++++--- Dockerfile | 26 ++++++++++++++++++++++++++ Makefile | 20 ++++++++++++-------- 4 files changed, 47 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 9f047802..5a74c7ff 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -381,9 +381,11 @@ jobs: if [[ "${DOCKER_TOKEN}" != "" ]]; then export DOCKER_REGISTRY=${DOCKER_REGISTRY:-docker.io} echo ${DOCKER_TOKEN} | docker login -u ${DOCKER_USER} --password-stdin ${DOCKER_REGISTRY} - docker buildx build --progress=plain --platform=linux/amd64,linux/arm64 --tag=${DOCKER_REGISTRY}/${DOCKER_REPO}/${DOCKER_IMAGE}:${DOCKER_TAG} --target=image_short --pull --push . - docker buildx build --progress=plain --platform=linux/amd64,linux/arm64 --tag=${DOCKER_REGISTRY}/${DOCKER_REPO}/${DOCKER_IMAGE}:${DOCKER_TAG}-fips --target=image_fips --pull --push . - docker buildx build --progress=plain --platform=linux/amd64,linux/arm64 --tag=${DOCKER_REGISTRY}/${DOCKER_REPO}/${DOCKER_IMAGE}-full:${DOCKER_TAG} --target=image_full --pull --push . + export VERSION=$(git describe --always --tags --abbrev=0 2>/dev/null | sed 's/^v//;s/\([^-]*-g\)/c\1/;s/-/./g') + + docker buildx build --progress=plain --platform=linux/amd64,linux/arm64 --tag=${DOCKER_REGISTRY}/${DOCKER_REPO}/${DOCKER_IMAGE}:${DOCKER_TAG} --build-arg VERSION=$VERSION --target=image_short --pull --push . + docker buildx build --progress=plain --platform=linux/amd64,linux/arm64 --tag=${DOCKER_REGISTRY}/${DOCKER_REPO}/${DOCKER_IMAGE}:${DOCKER_TAG}-fips --build-arg VERSION=$VERSION --target=image_fips --pull --push . + docker buildx build --progress=plain --platform=linux/amd64,linux/arm64 --tag=${DOCKER_REGISTRY}/${DOCKER_REPO}/${DOCKER_IMAGE}-full:${DOCKER_TAG} --build-arg VERSION=$VERSION --target=image_full --pull --push . fi cleanup: diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 91c45f39..54ea808f 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -135,7 +135,8 @@ jobs: run: | export DOCKER_REGISTRY=${DOCKER_REGISTRY:-docker.io} echo ${DOCKER_TOKEN} | docker login -u ${DOCKER_USER} --password-stdin ${DOCKER_REGISTRY} + export VERSION=$(git describe --always --tags --abbrev=0 2>/dev/null | sed 's/^v//;s/\([^-]*-g\)/c\1/;s/-/./g') - docker buildx build --progress=plain --platform=linux/amd64,linux/arm64 --tag=${DOCKER_REGISTRY}/${DOCKER_REPO}/${DOCKER_IMAGE}:${DOCKER_TAG} --tag ${DOCKER_REGISTRY}/${DOCKER_REPO}/${DOCKER_IMAGE}:latest --target=image_short --pull --push . - docker buildx build --progress=plain --platform=linux/amd64,linux/arm64 --tag=${DOCKER_REGISTRY}/${DOCKER_REPO}/${DOCKER_IMAGE}:${DOCKER_TAG}-fips --tag ${DOCKER_REGISTRY}/${DOCKER_REPO}/${DOCKER_IMAGE}:latest-fips --target=image_fips --pull --push . - docker buildx build --progress=plain --platform=linux/amd64,linux/arm64 --tag=${DOCKER_REGISTRY}/${DOCKER_REPO}/${DOCKER_IMAGE}-full:${DOCKER_TAG} --tag ${DOCKER_REGISTRY}/${DOCKER_REPO}/${DOCKER_IMAGE}-full:latest --target=image_full --pull --push . + docker buildx build --progress=plain --platform=linux/amd64,linux/arm64 --tag=${DOCKER_REGISTRY}/${DOCKER_REPO}/${DOCKER_IMAGE}:${DOCKER_TAG} --tag ${DOCKER_REGISTRY}/${DOCKER_REPO}/${DOCKER_IMAGE}:latest --build-arg VERSION=$VERSION --target=image_short --pull --push . + docker buildx build --progress=plain --platform=linux/amd64,linux/arm64 --tag=${DOCKER_REGISTRY}/${DOCKER_REPO}/${DOCKER_IMAGE}:${DOCKER_TAG}-fips --tag ${DOCKER_REGISTRY}/${DOCKER_REPO}/${DOCKER_IMAGE}:latest-fips --build-arg VERSION=$VERSION --target=image_fips --pull --push . + docker buildx build --progress=plain --platform=linux/amd64,linux/arm64 --tag=${DOCKER_REGISTRY}/${DOCKER_REPO}/${DOCKER_IMAGE}-full:${DOCKER_TAG} --tag ${DOCKER_REGISTRY}/${DOCKER_REPO}/${DOCKER_IMAGE}-full:latest --build-arg VERSION=$VERSION --target=image_full --pull --push . diff --git a/Dockerfile b/Dockerfile index f4aa7cc8..37e98721 100644 --- a/Dockerfile +++ b/Dockerfile @@ -78,7 +78,16 @@ CMD /src/build/${TARGETPLATFORM}/clickhouse-backup-fips --help FROM alpine:3.19 AS image_short ARG TARGETPLATFORM +ARG VERSION=unknown MAINTAINER Eugene Klimov +LABEL "org.opencontainers.image.version"=${VERSION} +LABEL "org.opencontainers.image.vendor"="Altinity Inc." +LABEL "org.opencontainers.image.licenses"="MIT" +LABEL "org.opencontainers.image.title"="Altinity Backup for ClickHouse" +LABEL "org.opencontainers.image.description"="A tool for easy ClickHouse backup and restore with support for many cloud and non-cloud storage types." +LABEL "org.opencontainers.image.source"="https://github.com/Altinity/clickhouse-backup" +LABEL "org.opencontainers.image.documentation"="https://github.com/Altinity/clickhouse-backup/blob/master/Manual.md" + RUN addgroup -S -g 101 clickhouse \ && adduser -S -h /var/lib/clickhouse -s /bin/bash -G clickhouse -g "ClickHouse server" -u 101 clickhouse RUN apk update && apk add --no-cache ca-certificates tzdata bash curl && update-ca-certificates @@ -94,6 +103,15 @@ CMD [ "/bin/clickhouse-backup", "--help" ] FROM image_short AS image_fips ARG TARGETPLATFORM +ARG VERSION=unknown +LABEL "org.opencontainers.image.version"=${VERSION} +LABEL "org.opencontainers.image.vendor"="Altinity Inc." +LABEL "org.opencontainers.image.licenses"="MIT" +LABEL "org.opencontainers.image.title"="Altinity Backup for ClickHouse" +LABEL "org.opencontainers.image.description"="A tool for easy ClickHouse backup and restore with support for many cloud and non-cloud storage types." +LABEL "org.opencontainers.image.source"="https://github.com/Altinity/clickhouse-backup" +LABEL "org.opencontainers.image.documentation"="https://github.com/Altinity/clickhouse-backup/blob/master/Manual.md" + MAINTAINER Eugene Klimov COPY build/${TARGETPLATFORM}/clickhouse-backup-fips /bin/clickhouse-backup RUN chmod +x /bin/clickhouse-backup @@ -102,7 +120,15 @@ RUN chmod +x /bin/clickhouse-backup FROM ${CLICKHOUSE_IMAGE}:${CLICKHOUSE_VERSION} AS image_full ARG TARGETPLATFORM +ARG VERSION=unknown MAINTAINER Eugene Klimov +LABEL "org.opencontainers.image.version"=${VERSION} +LABEL "org.opencontainers.image.vendor"="Altinity Inc." +LABEL "org.opencontainers.image.licenses"="MIT" +LABEL "org.opencontainers.image.title"="Altinity Backup for ClickHouse" +LABEL "org.opencontainers.image.description"="A tool for easy ClickHouse backup and restore with support for many cloud and non-cloud storage types." +LABEL "org.opencontainers.image.source"="https://github.com/Altinity/clickhouse-backup" +LABEL "org.opencontainers.image.documentation"="https://github.com/Altinity/clickhouse-backup/blob/master/Manual.md" RUN apt-get update && apt-get install -y gpg xxd bsdmainutils parallel && wget -qO- https://kopia.io/signing-key | gpg --dearmor -o /usr/share/keyrings/kopia-keyring.gpg && \ echo "deb [signed-by=/usr/share/keyrings/kopia-keyring.gpg] https://packages.kopia.io/apt/ stable main" > /etc/apt/sources.list.d/kopia.list && \ diff --git a/Makefile b/Makefile index 263f96a5..52d51bbf 100644 --- a/Makefile +++ b/Makefile @@ -134,31 +134,35 @@ $(NAME)/$(NAME)-race-fips: # run `docker buildx create --use` first time build-race-docker: - bash -xce 'docker buildx build --build-arg CLICKHOUSE_VERSION=$${CLICKHOUSE_VERSION:-latest} --build-arg CLICKHOUSE_IMAGE=$${CLICKHOUSE_IMAGE:-clickhouse/clickhouse-server} --tag $(NAME):build-race --target make-build-race --progress plain --load . && \ + bash -xce 'docker buildx build --build-arg CLICKHOUSE_VERSION=$${CLICKHOUSE_VERSION:-latest} --build-arg CLICKHOUSE_IMAGE=$${CLICKHOUSE_IMAGE:-clickhouse/clickhouse-server} --build-arg VERSION=$(VERSION) \ + --tag $(NAME):build-race --target make-build-race --progress plain --load . && \ mkdir -pv ./$(NAME) && \ DOCKER_ID=$$(docker create $(NAME):build-race) && \ - docker cp -q $${DOCKER_ID}:/src/$(NAME)/$(NAME)-race ./$(NAME)/ && \ + docker cp $${DOCKER_ID}:/src/$(NAME)/$(NAME)-race ./$(NAME)/ && \ docker rm -f "$${DOCKER_ID}" && \ cp -fl ./$(NAME)/$(NAME)-race ./$(NAME)/$(NAME)-race-docker' build-race-fips-docker: - bash -xce 'docker buildx build --build-arg CLICKHOUSE_VERSION=$${CLICKHOUSE_VERSION:-latest} --build-arg CLICKHOUSE_IMAGE=$${CLICKHOUSE_IMAGE:-clickhouse/clickhouse-server} --tag $(NAME):build-race-fips --target make-build-race-fips --progress plain --load . && \ + bash -xce 'docker buildx build --build-arg CLICKHOUSE_VERSION=$${CLICKHOUSE_VERSION:-latest} --build-arg CLICKHOUSE_IMAGE=$${CLICKHOUSE_IMAGE:-clickhouse/clickhouse-server} --build-arg VERSION=$(VERSION) \ + --tag $(NAME):build-race-fips --target make-build-race-fips --progress plain --load . && \ mkdir -pv ./$(NAME) && \ DOCKER_ID=$$(docker create $(NAME):build-race-fips) && \ - docker cp -q $${DOCKER_ID}:/src/$(NAME)/$(NAME)-race-fips ./$(NAME)/ && \ + docker cp $${DOCKER_ID}:/src/$(NAME)/$(NAME)-race-fips ./$(NAME)/ && \ docker rm -f "$${DOCKER_ID}" && \ cp -fl ./$(NAME)/$(NAME)-race-fips ./$(NAME)/$(NAME)-race-fips-docker' build-docker: - bash -xce 'docker buildx build --build-arg CLICKHOUSE_VERSION=$${CLICKHOUSE_VERSION:-latest} --build-arg CLICKHOUSE_IMAGE=$${CLICKHOUSE_IMAGE:-clickhouse/clickhouse-server} --tag $(NAME):build-docker --target make-build-docker --progress plain --load . && \ + bash -xce 'docker buildx build --build-arg CLICKHOUSE_VERSION=$${CLICKHOUSE_VERSION:-latest} --build-arg CLICKHOUSE_IMAGE=$${CLICKHOUSE_IMAGE:-clickhouse/clickhouse-server} --build-arg VERSION=$(VERSION) \ + --tag $(NAME):build-docker --target make-build-docker --progress plain --load . && \ mkdir -pv ./build && \ DOCKER_ID=$$(docker create $(NAME):build-docker) && \ - docker cp -q $${DOCKER_ID}:/src/build/ ./build/ && \ + docker cp $${DOCKER_ID}:/src/build/ ./build/ && \ docker rm -f "$${DOCKER_ID}"' build-fips-docker: - bash -xce 'docker buildx build --build-arg CLICKHOUSE_VERSION=$${CLICKHOUSE_VERSION:-latest} --build-arg CLICKHOUSE_IMAGE=$${CLICKHOUSE_IMAGE:-clickhouse/clickhouse-server} --tag $(NAME):build-docker-fips --target make-build-fips --progress plain --load . && \ + bash -xce 'docker buildx build --build-arg CLICKHOUSE_VERSION=$${CLICKHOUSE_VERSION:-latest} --build-arg CLICKHOUSE_IMAGE=$${CLICKHOUSE_IMAGE:-clickhouse/clickhouse-server} --build-arg VERSION=$(VERSION) \ + --tag $(NAME):build-docker-fips --target make-build-fips --progress plain --load . && \ mkdir -pv ./build && \ DOCKER_ID=$$(docker create $(NAME):build-docker) && \ - docker cp -q $${DOCKER_ID}:/src/build/ ./build/ && \ + docker cp $${DOCKER_ID}:/src/build/ ./build/ && \ docker rm -f "$${DOCKER_ID}"'