diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f4877e7..5ee4da8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -37,11 +37,6 @@ jobs: cd elasticsearch-init make release - - name: Build elasticsearch - run: | - cd elasticsearch - make release - - name: Build elasticsearch-dashboard-init run: | cd elasticsearch-dashboard-init diff --git a/elasticsearch/Dockerfile b/elasticsearch/Dockerfile deleted file mode 100644 index eb188b7..0000000 --- a/elasticsearch/Dockerfile +++ /dev/null @@ -1,41 +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 - -SHELL ["/bin/bash", "-c"] - -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 - -# If you need to run as root, -# you should change the user to root at the beginning of your Dockerfile then change back to the correct user with another USER instruction - -USER root - -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 - -USER elasticsearch \ No newline at end of file diff --git a/elasticsearch/Makefile b/elasticsearch/Makefile deleted file mode 100644 index ae7bca3..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 ?= -DB_BIN ?= elasticsearch -DB_TAG ?= 8.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 diff --git a/scripts/docker-entrypoint.sh b/scripts/docker-entrypoint.sh deleted file mode 100755 index 254ac50..0000000 --- a/scripts/docker-entrypoint.sh +++ /dev/null @@ -1,102 +0,0 @@ -#!/bin/bash -set -e - -# Files created by Elasticsearch should always be group writable too -umask 0002 - -run_as_other_user_if_needed() { - if [[ "$(id -u)" == "0" ]]; then - # If running as root, drop to specified UID and run command - exec chroot --userspec=1000:0 / "${@}" - else - # Either we are running in Openshift with random uid and are a member of the root group - # or with a custom --user - exec "${@}" - fi -} - -# Allow user specify custom CMD, maybe bin/elasticsearch itself -# for example to directly specify `-E` style parameters for elasticsearch on k8s -# or simply to run /bin/bash to check the image -if [[ "$1" != "eswrapper" ]]; then - if [[ "$(id -u)" == "0" && $(basename "$1") == "elasticsearch" ]]; then - # centos:7 chroot doesn't have the `--skip-chdir` option and - # changes our CWD. - # Rewrite CMD args to replace $1 with `elasticsearch` explicitly, - # so that we are backwards compatible with the docs - # from the previous Elasticsearch versions<6 - # and configuration option D: - # https://www.elastic.co/guide/en/elasticsearch/reference/5.6/docker.html#_d_override_the_image_8217_s_default_ulink_url_https_docs_docker_com_engine_reference_run_cmd_default_command_or_options_cmd_ulink - # Without this, user could specify `elasticsearch -E x.y=z` but - # `bin/elasticsearch -E x.y=z` would not work. - set -- "elasticsearch" "${@:2}" - # Use chroot to switch to UID 1000 / GID 0 - exec chroot --userspec=1000:0 / "$@" - else - # User probably wants to run something else, like /bin/bash, with another uid forced (Openshift?) - exec "$@" - fi -fi - -# Allow environment variables to be set by creating a file with the -# contents, and setting an environment variable with the suffix _FILE to -# point to it. This can be used to provide secrets to a container, without -# the values being specified explicitly when running the container. -# -# This is also sourced in elasticsearch-env, and is only needed here -# as well because we use ELASTIC_PASSWORD below. Sourcing this script -# is idempotent. -source /usr/share/elasticsearch/bin/elasticsearch-env-from-file - -if [[ -f bin/elasticsearch-users ]]; then - # Check for the ELASTIC_PASSWORD environment variable to set the - # bootstrap password for Security. - # - # This is only required for the first node in a cluster with Security - # enabled, but we have no way of knowing which node we are yet. We'll just - # honor the variable if it's present. - if [[ -n "$ELASTIC_PASSWORD" ]]; then - [[ -f /usr/share/elasticsearch/config/elasticsearch.keystore ]] || (run_as_other_user_if_needed elasticsearch-keystore create) - if ! (run_as_other_user_if_needed elasticsearch-keystore has-passwd --silent); then - # keystore is unencrypted - if ! (run_as_other_user_if_needed elasticsearch-keystore list | grep -q '^bootstrap.password$'); then - (run_as_other_user_if_needed echo "$ELASTIC_PASSWORD" | elasticsearch-keystore add -x 'bootstrap.password') - fi - else - # keystore requires password - if ! (run_as_other_user_if_needed echo "$KEYSTORE_PASSWORD" | - elasticsearch-keystore list | grep -q '^bootstrap.password$'); then - COMMANDS="$(printf "%s\n%s" "$KEYSTORE_PASSWORD" "$ELASTIC_PASSWORD")" - (run_as_other_user_if_needed echo "$COMMANDS" | elasticsearch-keystore add 'bootstrap.password') - fi - fi - fi -fi - -if [[ "$(id -u)" == "0" ]]; then - # If requested and running as root, mutate the ownership of bind-mounts - if [[ -n "$TAKE_FILE_OWNERSHIP" ]]; then - chown -R 1000:0 /usr/share/elasticsearch/{data,logs} - fi -fi - -if [[ -n "$ES_LOG_STYLE" ]]; then - case "$ES_LOG_STYLE" in - console) - # This is the default. Nothing to do. - ;; - file) - # Overwrite the default config with the stack config. Do this as a - # copy, not a move, in case the container is restarted. - cp -f /usr/share/elasticsearch/config/log4j2.file.properties /usr/share/elasticsearch/config/log4j2.properties - ;; - *) - echo "ERROR: ES_LOG_STYLE set to [$ES_LOG_STYLE]. Expected [console] or [file]" >&2 - exit 1 - ;; - esac -fi - -# Signal forwarding and child reaping is handled by `tini`, which is the -# actual entrypoint of the container -run_as_other_user_if_needed /usr/share/elasticsearch/bin/elasticsearch <<<"$KEYSTORE_PASSWORD"