From 9eb6b3ac3fa8fa03b769f3b58689b73c773afaf1 Mon Sep 17 00:00:00 2001 From: Garrison Davis Date: Thu, 18 Aug 2022 13:52:04 -0600 Subject: [PATCH] Fix idk package_docker_all CI job (#2196) Before, we were building docker images for IDK for each of the four linux/darwin amd64/arm64 platfrom/arch combinations, which didn't make sense. If we want to later build docker images for linux/arm64, we can add that later. I also cleaned up the Dockerfile for IDK to minimize creation of excess layers (by &&-ing RUN commands), and made apt quieter to cut back some of the noise. --- .gitlab/.gitlab-ci.yml | 11 ++--------- Makefile | 16 ++++++++++++++++ idk/Dockerfile | 29 +++++++++++++++++++---------- 3 files changed, 37 insertions(+), 19 deletions(-) diff --git a/.gitlab/.gitlab-ci.yml b/.gitlab/.gitlab-ci.yml index 79b9e2018..793e933d4 100644 --- a/.gitlab/.gitlab-ci.yml +++ b/.gitlab/.gitlab-ci.yml @@ -638,16 +638,9 @@ idk package_docker_all: rules: - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH && ($CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "schedule" || $CI_PIPELINE_SOURCE == "web")' script: - - cd ./idk/ - - make docker GOOS="linux" GOARCH="amd64" - - make docker GOOS="linux" GOARCH="arm64" - - make docker GOOS="darwin" GOARCH="amd64" - - make docker GOOS="darwin" GOARCH="arm64" + - make docker-idk GOOS="linux" GOARCH="amd64" - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - - make docker-tag-push GOOS="linux" GOARCH="amd64" - - make docker-tag-push GOOS="linux" GOARCH="arm64" - - make docker-tag-push GOOS="darwin" GOARCH="amd64" - - make docker-tag-push GOOS="darwin" GOARCH="arm64" + - make docker-idk-tag-push GOOS="linux" GOARCH="amd64" needs: - job: idk build_all - job: idk build_linux_arm64 diff --git a/Makefile b/Makefile index 9f02a1e1b..22093c6ae 100644 --- a/Makefile +++ b/Makefile @@ -251,6 +251,22 @@ docker-tag-push: vendor docker push $(DOCKER_TARGET) @echo Pushed docker image: $(DOCKER_TARGET) +# These commands (docker-idk and docker-idk-tag-push) +# are designed to be used in CI. +# docker-idk builds idk docker images and tags them - intended for use in CI. +docker-idk: vendor + docker build \ + -f idk/Dockerfile \ + --build-arg GO_VERSION=$(GO_VERSION) \ + --build-arg MAKE_FLAGS="GOOS=$(GOOS) GOARCH=$(GOARCH) BUILD_CGO=$(BUILD_CGO)" \ + --tag registry.gitlab.com/molecula/featurebase/idk:$(VERSION_ID) . + @echo Created docker image: registry.gitlab.com/molecula/featurebase/idk:$(VERSION_ID) +# docker-idk-tag-push pushes tagged docker images to the GitLab container +# registry - intended for use in CI. +docker-idk-tag-push: + docker push registry.gitlab.com/molecula/featurebase/idk:$(VERSION_ID) + @echo Pushed docker image: registry.gitlab.com/molecula/featurebase/idk:$(VERSION_ID) + # Install diagnostic pilosa-keydump tool. Allows viewing the keys in a transaction-engine directory. pilosa-keydump: $(GO) install -tags='$(BUILD_TAGS)' -ldflags $(LDFLAGS) $(FLAGS) ./cmd/pilosa-keydump diff --git a/idk/Dockerfile b/idk/Dockerfile index 266b2dd1b..32a100734 100644 --- a/idk/Dockerfile +++ b/idk/Dockerfile @@ -3,13 +3,19 @@ ARG GO_VERSION=1.17.8 FROM golang:1.17.8-stretch as builder WORKDIR / -RUN ["apt-get","update","-y"] -RUN ["apt-get","install","-y","git","unixodbc","unixodbc-dev","netcat", "build-essential","musl-tools"] +RUN apt-get update -y -qq && apt-get install -y -qq \ + build-essential \ + git \ + musl-tools \ + netcat \ + unixodbc \ + unixodbc-dev \ + && rm -rf /var/lib/apt/lists/* RUN ["git", "clone", "https://github.com/edenhill/librdkafka.git"] WORKDIR /librdkafka -RUN ["./configure", "--prefix", "/usr"] -RUN ["make"] -RUN ["make", "install"] +RUN ./configure --prefix /usr && \ + make && \ + make install WORKDIR /featurebase @@ -24,12 +30,15 @@ RUN make build GO_BUILD_FLAGS="-mod=vendor ${GO_BUILD_FLAGS}" ${MAKE_FLAGS} FROM ubuntu:20.04 as runner -RUN ["apt-get","update","-y"] -RUN ["apt-get","install","-y","unixodbc-dev","netcat","ca-certificates", "musl-tools"] +RUN apt-get update -y -qq && apt-get install -y -qq \ + ca-certificates \ + musl-tools \ + netcat \ + unixodbc-dev \ + && rm -rf /var/lib/apt/lists/* -COPY --from=builder /idk/bin/* /usr/local/bin/ - -COPY /docker-sasl/ssl_keys /etc/kafka/secrets +COPY --from=builder /featurebase/idk/bin/* /usr/local/bin/ +COPY ./idk/docker-sasl/ssl_keys /etc/kafka/secrets # Verify that the linker can find everything. FROM runner as linkcheck