diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index af74fcf..97da565 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -40,12 +40,6 @@ jobs: cd elasticsearch-init make release -# TODO: Add support for custom build image with necessary plugins installed -# - name: Build elasticsearch -# run: | -# cd elasticsearch -# make release - - name: Build elasticsearch-dashboard-init run: | cd elasticsearch-dashboard-init diff --git a/elasticsearch-dashboard-init/Dockerfile b/elasticsearch-dashboard-init/Dockerfile index 4cd3f31..0f9316d 100644 --- a/elasticsearch-dashboard-init/Dockerfile +++ b/elasticsearch-dashboard-init/Dockerfile @@ -1,27 +1,23 @@ -FROM debian:bullseye as builder - -# ref: https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope -ARG TARGETOS -ARG TARGETARCH - -ENV DEBIAN_FRONTEND noninteractive -ENV DEBCONF_NONINTERACTIVE_SEEN true +FROM golang:1.21 AS yq RUN set -x \ && apt-get update \ - && apt-get install -y --no-install-recommends apt-transport-https ca-certificates curl unzip + && apt-get install -y --no-install-recommends apt-transport-https ca-certificates +## build yq binary from ac-3.3.4 branch which has updated go dependencies RUN set -x \ - && curl -fsSL -o yq https://github.com/mikefarah/yq/releases/download/3.3.0/yq_${TARGETOS}_${TARGETARCH} \ - && chmod 755 yq + && git clone https://github.com/gomodules/yq.git \ + && cd yq \ + && git checkout ac-3.3.4 \ + && CGO_ENABLED=0 go build -v -o /yq yq.go FROM {ELASTICSEARCH_DASHBOARD_IMAGE} as elasticsearch_dashboard -FROM alpine:3.13.1 +FROM alpine:3.18.5 RUN apk add --no-cache bash COPY scripts/dashboard-config-merger.sh /usr/local/bin/dashboard-config-merger.sh -COPY --from=builder /yq /usr/bin/yq +COPY --from=yq /yq /usr/bin/yq COPY --from=elasticsearch_dashboard /usr/share/opensearch-dashboards/config /opensearch-dashboards/default-config RUN chmod -c 755 /usr/local/bin/dashboard-config-merger.sh diff --git a/elasticsearch-init/Dockerfile b/elasticsearch-init/Dockerfile index 1c1ff23..09ab675 100644 --- a/elasticsearch-init/Dockerfile +++ b/elasticsearch-init/Dockerfile @@ -1,26 +1,23 @@ -FROM debian:bullseye as builder - -# ref: https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope -ARG TARGETOS -ARG TARGETARCH - -ENV DEBIAN_FRONTEND noninteractive -ENV DEBCONF_NONINTERACTIVE_SEEN true +FROM golang:1.21 AS yq RUN set -x \ && apt-get update \ - && apt-get install -y --no-install-recommends apt-transport-https ca-certificates curl unzip + && apt-get install -y --no-install-recommends apt-transport-https ca-certificates +## build yq binary from ac-3.3.4 branch which has updated go dependencies RUN set -x \ - && curl -fsSL -o yq https://github.com/mikefarah/yq/releases/download/3.3.0/yq_${TARGETOS}_${TARGETARCH} \ - && chmod 755 yq + && git clone https://github.com/gomodules/yq.git \ + && cd yq \ + && git checkout ac-3.3.4 \ + && CGO_ENABLED=0 go build -v -o /yq yq.go FROM {ELASTICSEARCH_IMAGE} as elasticsearch -FROM alpine:3.13.1 + +FROM alpine:3.18.5 RUN apk add --no-cache bash COPY scripts/config-merger.sh /usr/local/bin/config-merger.sh -COPY --from=builder /yq /usr/bin/yq +COPY --from=yq /yq /usr/bin/yq COPY --from=elasticsearch /usr/share/opensearch/config /elasticsearch/default-config COPY --from=elasticsearch /usr/share/opensearch/config/opensearch-security /elasticsearch/default-securityconfig diff --git a/elasticsearch/Dockerfile b/elasticsearch/Dockerfile deleted file mode 100644 index bc96bd1..0000000 --- a/elasticsearch/Dockerfile +++ /dev/null @@ -1,31 +0,0 @@ -FROM debian:bullseye as builder - -# ref: https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope -ARG TARGETOS -ARG TARGETARCH - -ENV DEBIAN_FRONTEND noninteractive -ENV DEBCONF_NONINTERACTIVE_SEEN true - -RUN set -x \ - && apt-get update \ - && apt-get install -y --no-install-recommends apt-transport-https ca-certificates curl unzip - -RUN set -x \ - && curl -fsSL -o yq https://github.com/mikefarah/yq/releases/download/3.3.0/yq_${TARGETOS}_${TARGETARCH} \ - && chmod 755 yq - -FROM {ELASTICSEARCH_IMAGE} as elasticsearch - -RUN IFS=',' read -ra PLUGINS <<< "{ELASTICSEARCH_PLUGINS}"; for PLUGIN in "${PLUGINS[@]}"; do /usr/share/elasticsearch/bin/elasticsearch-plugin install --batch $PLUGIN ;done; -RUN /usr/share/elasticsearch/bin/elasticsearch-plugin list - -COPY scripts/config-merger.sh /usr/local/bin/config-merger.sh -COPY scripts/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh -COPY --from=builder /yq /usr/bin/yq -RUN mkdir -p /elasticsearch/default-config -RUN cp -r /usr/share/elasticsearch/config/* /elasticsearch/default-config/ -RUN chown 1000:0 -R /elasticsearch/default-config - -RUN chmod -c 755 /usr/local/bin/config-merger.sh -RUN chmod -c 755 /usr/local/bin/docker-entrypoint.sh \ No newline at end of file diff --git a/elasticsearch/Makefile b/elasticsearch/Makefile deleted file mode 100644 index b8fbc4a..0000000 --- a/elasticsearch/Makefile +++ /dev/null @@ -1,82 +0,0 @@ -SHELL=/bin/bash -o pipefail - -REGISTRY ?= ghcr.io/kubedb -BIN ?= elasticsearch -IMAGE := $(REGISTRY)/$(BIN) -TAG ?= $(shell git describe --exact-match --abbrev=0 2>/dev/null || echo "") - -DOCKER_PLATFORMS := linux/amd64 linux/arm64 -PLATFORM ?= $(firstword $(DOCKER_PLATFORMS)) -VERSION = $(TAG)_$(subst /,_,$(PLATFORM)) - -DB_REGISTRY ?= opensearchproject -DB_BIN ?= opensearch -DB_TAG ?= 2.8.0 -DB_IMAGE ?= $(shell if [ ! -z $(DB_REGISTRY) ]; then echo $(DB_REGISTRY)/; fi)$(DB_BIN):$(DB_TAG) -ES_PLUGINS ?= repository-s3, repository-azure, repository-hdfs, repository-gcs - -BUILD_DIRS := bin - -$(BUILD_DIRS): - @mkdir -p $@ - -container-%: - @$(MAKE) container \ - --no-print-directory \ - PLATFORM=$(subst _,/,$*) - -push-%: - @$(MAKE) push \ - --no-print-directory \ - PLATFORM=$(subst _,/,$*) - -all-container: $(addprefix container-, $(subst /,_,$(DOCKER_PLATFORMS))) - -all-push: $(addprefix push-, $(subst /,_,$(DOCKER_PLATFORMS))) - -.PHONY: container -container: $(BUILD_DIRS) - @echo "container: $(IMAGE):$(VERSION)" - @rm -rf bin/.dockerfile; \ - sed \ - -e 's|{ELASTICSEARCH_IMAGE}|$(DB_IMAGE)|g' \ - -e 's|{ELASTICSEARCH_PLUGINS}|$(ES_PLUGINS)|g' \ - Dockerfile > bin/.dockerfile; \ - # ref: https://superuser.com/a/842705 - tar -czh . | docker buildx build --platform $(PLATFORM) --load --pull -t $(IMAGE):$(VERSION) -f bin/.dockerfile - - @echo - -push: container - @docker push $(IMAGE):$(VERSION) - @echo "pushed: $(IMAGE):$(VERSION)" - @echo - -.PHONY: docker-manifest -docker-manifest: - docker manifest create -a $(IMAGE):$(TAG) $(foreach PLATFORM,$(DOCKER_PLATFORMS),$(IMAGE):$(TAG)_$(subst /,_,$(PLATFORM))) - docker manifest push $(IMAGE):$(TAG) - -.PHONY: release -release: - @$(MAKE) all-push docker-manifest --no-print-directory - -.PHONY: version -version: - @echo ::set-output name=version::$(VERSION) - -.PHONY: fmt -fmt: - @find ./.. -path ./vendor -prune -o -name '*.sh' -exec shfmt -l -w -ci -i 4 {} \; - -.PHONY: verify -verify: fmt - @if !(git diff --exit-code HEAD); then \ - echo "files are out of date, run make fmt"; exit 1; \ - fi - -.PHONY: ci -ci: verify - -.PHONY: entrypoint-script -entrypoint-script: - @ wget -O scripts/docker-entrypoint.sh https://raw.githubusercontent.com/elastic/elasticsearch/v${DB_TAG}/distribution/docker/src/docker/bin/docker-entrypoint.sh \ No newline at end of file diff --git a/elasticsearch/scripts b/elasticsearch/scripts deleted file mode 120000 index a339954..0000000 --- a/elasticsearch/scripts +++ /dev/null @@ -1 +0,0 @@ -../scripts \ No newline at end of file