Skip to content

aligent/bitbucket-opensearch-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenSearch Docker Image for Bitbucket Pipelines

This Docker image extends the official OpenSearch image to support environment variable translation from snake_case to dot notation, making it compatible with Bitbucket Pipelines' environment variable constraints.

Features

  • Environment variable translation from snake_case to dot notation
  • Pre-installed plugins:
    • analysis-icu
    • analysis-phonetic

Docker Hub

Pre-built images are available on Docker Hub: aligent/bitbucket-opensearch

docker pull aligent/bitbucket-opensearch:latest
docker pull aligent/bitbucket-opensearch:2.12.0

Problem Solved

Bitbucket Pipelines services:

  • Cannot have custom commands or entry-points
  • Can only use environment variables with alphanumeric characters and underscores (no dots)

This image automatically translates environment variables prefixed with OPENSEARCH_SETTING_ from snake_case to OpenSearch's dot notation configuration format.

How It Works

Environment variables starting with OPENSEARCH_SETTING_ are automatically translated:

Environment Variable Translated Setting
OPENSEARCH_SETTING_CLUSTER_NAME cluster.name
OPENSEARCH_SETTING_NODE_NAME node.name
OPENSEARCH_SETTING_HTTP_PORT http.port
OPENSEARCH_SETTING_PLUGINS_SECURITY_DISABLED plugins.security.disabled

Special Case: Preserving Underscores

Use double underscores (__) to preserve a single underscore in the setting name:

Environment Variable Translated Setting
OPENSEARCH_SETTING_CLUSTER_ROUTING_ALLOCATION_DISK_WATERMARK__LOW cluster.routing.allocation.disk.watermark_low

Building the Image

docker build -t your-registry/opensearch-bitbucket:latest .

# Build a specific OpenSearch version
docker build --build-arg OPENSEARCH_VERSION=2.11.0 -t your-registry/opensearch-bitbucket:2.11.0 .

Usage in Bitbucket Pipelines

bitbucket-pipelines.yml Example

definitions:
  services:
    opensearch:
      image: aligent/bitbucket-opensearch:latest
      variables:
        discovery.type: single-node
        OPENSEARCH_INITIAL_ADMIN_PASSWORD: MyStrongPassword123!
        OPENSEARCH_SETTING_CLUSTER_NAME: my-cluster
        OPENSEARCH_SETTING_NODE_NAME: opensearch-node-1
        OPENSEARCH_SETTING_HTTP_PORT: 9200
        OPENSEARCH_SETTING_PLUGINS_SECURITY_DISABLED: true

pipelines:
  default:
    - step:
        name: Run Tests with OpenSearch
        services:
          - opensearch
        script:
          - echo "Waiting for OpenSearch to start..."
          - sleep 30
          - curl -s http://localhost:9200
          - # Run your tests here

Testing Locally

# Build the image
docker build -t opensearch-bitbucket:test .

# Run a test container
docker run -d \
    --name opensearch-test \
    -e "discovery.type=single-node" \
    -e "OPENSEARCH_INITIAL_ADMIN_PASSWORD=MyStrongPassword123!" \
    -e "OPENSEARCH_SETTING_CLUSTER_NAME=test-cluster" \
    -e "OPENSEARCH_SETTING_NODE_NAME=test-node" \
    -e "OPENSEARCH_SETTING_PLUGINS_SECURITY_DISABLED=true" \
    -p 9200:9200 \
    opensearch-bitbucket:test

# Verify it's working
curl http://localhost:9200

# Check the logs to see environment variable translation
docker logs opensearch-test 2>&1 | grep "Translated:"

# Cleanup
docker stop opensearch-test && docker rm opensearch-test

Docker Hub Automated Builds

This repository is configured for Docker Hub automated builds with support for multiple OpenSearch versions.

Available Tags

  • latest - Latest stable OpenSearch version (2.12.0)
  • 2.12.0, 2.12, 2 - OpenSearch 2.12.0
  • Version-specific tags for other OpenSearch releases

Build Configuration

The repository includes Docker Hub build hooks for:

  • hooks/build - Handles version-specific builds using build arguments
  • hooks/post_push - Creates additional semantic version tags (e.g., 2.12.0 → 2.12, 2)

To build a specific OpenSearch version locally:

docker build --build-arg OPENSEARCH_VERSION=2.11.0 -t opensearch-bitbucket:2.11.0 .

Repository Structure

  • Dockerfile - Extends the official OpenSearch image with build argument support for version flexibility
  • entrypoint.sh - Custom entrypoint script that handles environment variable translation from snake_case to dot notation
  • hooks/ - Docker Hub automated build hooks
    • build - Handles version-specific builds using build arguments
    • post_push - Creates additional semantic version tags (e.g., 2.12.0 → 2.12, 2)

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published