https://github.com/aligent/bitbucket-opensearch-docker
https://github.com/aligent/bitbucket-opensearch-docker
Last synced: 4 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/aligent/bitbucket-opensearch-docker
- Owner: aligent
- License: mit
- Created: 2025-08-18T00:20:14.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-08-18T06:28:30.000Z (10 months ago)
- Last Synced: 2026-01-29T21:27:03.995Z (5 months ago)
- Language: Shell
- Size: 6.84 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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`
```bash
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
```bash
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
```yaml
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
```bash
# 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:
```bash
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](LICENSE) file for details.