From e5bdd9c5e6a4eb53d7fd97f719a278ed6b884cf1 Mon Sep 17 00:00:00 2001 From: Fernando Briano Date: Fri, 18 Oct 2024 15:26:05 +0100 Subject: [PATCH] Adds container name parameter --- .github/workflows/elasticsearch.yml | 26 ++++++++++++++++++++++++++ elasticsearch/README.md | 3 ++- elasticsearch/action.yml | 5 +++++ elasticsearch/run-elasticsearch.sh | 9 +++++---- 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/.github/workflows/elasticsearch.yml b/.github/workflows/elasticsearch.yml index 8ffbba5..f29db0a 100644 --- a/.github/workflows/elasticsearch.yml +++ b/.github/workflows/elasticsearch.yml @@ -222,3 +222,29 @@ jobs: - name: Elasticsearch is reachable run: | curl --verbose --show-error http://localhost:9200 + + run-with-custom-container-name: + name: Start Elasticsearch with custom container name + runs-on: ubuntu-latest + strategy: + matrix: + elasticsearch: ["9.0.0-SNAPSHOT"] + steps: + - name: Checkout + uses: actions/checkout@v1 + - name: Configure sysctl limits + run: | + sudo swapoff -a + sudo sysctl -w vm.swappiness=1 + sudo sysctl -w fs.file-max=262144 + sudo sysctl -w vm.max_map_count=262144 + - name: Start Elasticsearch + uses: ./elasticsearch + with: + security-enabled: false + stack-version: ${{ matrix.elasticsearch }} + container-name: 'elasticsearch' + + - name: Elasticsearch is reachable + run: | + curl --verbose --show-error http://localhost:9200 diff --git a/elasticsearch/README.md b/elasticsearch/README.md index 607d5ff..51ca1ea 100644 --- a/elasticsearch/README.md +++ b/elasticsearch/README.md @@ -22,7 +22,8 @@ ___ | `elasticsearch_password` | No | changeme | The password for the user elastic in your cluster | | `wait` | No | 10 | Number of seconds to wait after launch. | | `plugins` | No | | Any plugins you want to include | -| `network` | No | elastic | Custom name for the network created by Docker | +| `network-name` | No | elastic | Custom name for the network created by Docker | +| `container-name` | No | elastic | Custom name for the network created by Docker | ## Usage diff --git a/elasticsearch/action.yml b/elasticsearch/action.yml index c7d4930..8219269 100644 --- a/elasticsearch/action.yml +++ b/elasticsearch/action.yml @@ -37,6 +37,10 @@ inputs: description: 'Name of the network to create with docker' required: false default: elastic + container-name: + description: 'Name for the container' + required: false + default: es runs: using: 'docker' @@ -50,3 +54,4 @@ runs: ELASTICSEARCH_PASSWORD: ${{ inputs.elasticsearch_password }} WAIT: ${{ inputs.wait }} NETWORK_NAME: ${{ inputs.network-name }} + CONTAINER_NAME: ${{ inputs.container-name }} diff --git a/elasticsearch/run-elasticsearch.sh b/elasticsearch/run-elasticsearch.sh index 8f04c89..f18d196 100755 --- a/elasticsearch/run-elasticsearch.sh +++ b/elasticsearch/run-elasticsearch.sh @@ -9,6 +9,7 @@ fi MAJOR_VERSION=`echo ${STACK_VERSION} | cut -c 1` NETWORK_NAME=${NETWORK_NAME:-elastic} +CONTAINER_NAME=${CONTAINER_NAME:-es} docker network inspect $NETWORK_NAME >/dev/null 2>&1 || docker network create $NETWORK_NAME @@ -54,7 +55,7 @@ do --publish "${port_com}:${port_com}" \ --detach \ --network=$NETWORK_NAME \ - --name="es${node}" \ + --name="${CONTAINER_NAME}${node}" \ -v /es/plugins/:/usr/share/elasticsearch/plugins/ \ docker.elastic.co/elasticsearch/elasticsearch:${STACK_VERSION} elif [ "x${MAJOR_VERSION}" == 'x7' ]; then @@ -76,7 +77,7 @@ do --publish "${port}:${port}" \ --detach \ --network=$NETWORK_NAME \ - --name="es${node}" \ + --name="${CONTAINER_NAME}${node}" \ -v /es/plugins/:/usr/share/elasticsearch/plugins/ \ docker.elastic.co/elasticsearch/elasticsearch:${STACK_VERSION} elif [ "x${MAJOR_VERSION}" == 'x8' ] || [ "x${MAJOR_VERSION}" == 'x9' ]; then @@ -99,7 +100,7 @@ do --ulimit memlock=-1:-1 \ --publish "${port}:${port}" \ --network=$NETWORK_NAME \ - --name="es${node}" \ + --name="${CONTAINER_NAME}${node}" \ --detach \ -v /es/plugins/:/usr/share/elasticsearch/plugins/ \ docker.elastic.co/elasticsearch/elasticsearch:${STACK_VERSION} @@ -121,7 +122,7 @@ do --ulimit memlock=-1:-1 \ --publish "${port}:${port}" \ --network=$NETWORK_NAME \ - --name="es${node}" \ + --name="${CONTAINER_NAME}${node}" \ --detach \ -v /es/plugins/:/usr/share/elasticsearch/plugins/ \ docker.elastic.co/elasticsearch/elasticsearch:${STACK_VERSION}