Last active
April 10, 2025 12:50
-
-
Save dtaivpp/c587d99a2cab441eba0314534ae87c86 to your computer and use it in GitHub Desktop.
This is a shell script for setting up a single node cluster for OpenSearch. This is something you can use in local development. It creates a secret password that is random every time.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# 1. To run this script curl it locally: | |
# curl https://gist.githubusercontent.com/dtaivpp/c587d99a2cab441eba0314534ae87c86/raw -o opensearch-compose-bootstrap.sh | |
# 2. Change it to be executable: | |
# chmod +x opensearch-compose-generate.sh | |
# 3. Run it: | |
# ./opensearch-compose-generate.sh | |
# | |
# This will create: | |
# - docker-compose.yml file for OpenSearch | |
# - .env file with the OpenSearch password | |
# | |
# 4. Docker compose up to start an OpenSearch instance. | |
# docker compose up -d | |
# Check if env file exists and if not create and fill it. | |
if [[ ! -e .env ]]; then | |
echo "OPENSEARCH_PASSWORD=`openssl rand -base64 20`" >> .env | |
fi | |
if [[ ! -e docker-compose.yml ]]; then | |
echo """ | |
services: | |
opensearch: | |
image: opensearchproject/opensearch:\${OPENSEARCH_VERSION:-latest} | |
container_name: opensearch | |
environment: | |
discovery.type: single-node | |
node.name: opensearch | |
OPENSEARCH_JAVA_OPTS: -Xms512m -Xmx512m | |
OPENSEARCH_INITIAL_ADMIN_PASSWORD: \${OPENSEARCH_PASSWORD} | |
volumes: | |
- opensearch-data:/usr/share/opensearch/data | |
ports: | |
- 9200:9200 | |
- 9600:9600 | |
networks: | |
- opensearch-net | |
opensearch-dashboards: | |
image: opensearchproject/opensearch-dashboards:\${OPENSEARCH_DASHBOARDS_VERSION:-latest} | |
container_name: opensearch-dashboards | |
ports: | |
- 5601:5601 | |
expose: | |
- "5601" | |
environment: | |
OPENSEARCH_HOSTS: '[\"https://opensearch:9200\"]' | |
networks: | |
- opensearch-net | |
depends_on: | |
- opensearch | |
volumes: | |
opensearch-data: | |
networks: | |
opensearch-net: | |
driver: bridge | |
""" >> docker-compose.yml | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment