Skip to content

Commit

Permalink
Adds container name parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
picandocodigo committed Oct 18, 2024
1 parent 57e7504 commit e5bdd9c
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 5 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/elasticsearch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion elasticsearch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions elasticsearch/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -50,3 +54,4 @@ runs:
ELASTICSEARCH_PASSWORD: ${{ inputs.elasticsearch_password }}
WAIT: ${{ inputs.wait }}
NETWORK_NAME: ${{ inputs.network-name }}
CONTAINER_NAME: ${{ inputs.container-name }}
9 changes: 5 additions & 4 deletions elasticsearch/run-elasticsearch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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}
Expand All @@ -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}
Expand Down

0 comments on commit e5bdd9c

Please sign in to comment.