Skip to content

Commit

Permalink
simplify docker-compose.yml (#763)
Browse files Browse the repository at this point in the history
* simplify docker-compose.yml

Signed-off-by: YANGDB <[email protected]>

* update docs regarding security

Signed-off-by: YANGDB <[email protected]>

* update docs security doc and restrictions

Signed-off-by: YANGDB <[email protected]>

---------

Signed-off-by: YANGDB <[email protected]>
  • Loading branch information
YANG-DB authored Jul 28, 2023
1 parent f9f1579 commit 3ca83f8
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 52 deletions.
6 changes: 2 additions & 4 deletions .env
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# version for opensearch & opensearch-dashboards docker image
VERSION=2.6.0
# auth details - change according to your system
USER=admin
PASSWORD=admin
VERSION=2.9.0

14 changes: 10 additions & 4 deletions Using-Docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ First the plugin must be build using the `yarn build` command.

Once this build was completed - the expected zip location of the plugin is `./build/observabilityDashboards-?.?.?.zip` where as the `?.?.?` represents the version of this dashboard plugin.

> Note that the plugin version must correspond to the OpenSearch-Dashboards version - this information appears [here](opensearch_dashboards.json)
> Note: that the plugin version must correspond to the OpenSearch-Dashboards version - this information appears [here](opensearch_dashboards.json)
>
Once the build is completed, make sure to overide the [Dockerfile](Dockerfile) target zip file with the exact name
Expand All @@ -16,17 +16,22 @@ RUN /usr/share/opensearch-dashboards/bin/opensearch-dashboards-plugin install fi
```

## Docker imageVersion
The docker images used by this file are all referencing the [.env](.env) environment file that contains the version and user/password fields that need to be changed to match your own system.
The docker images used by this file are all referencing the [.env](.env) environment file that contains the version that needed to be changed to match your own system.

## Run the docker image build
To build the docker image use the next command:
> `docker build --build-arg VERSION=$(grep VERSION .env | cut -d '=' -f2) -t your_image_name .`
## Run the docker compose
The [docker-compose](docker-compose.yml) file represents a simple assembly of an OpenSearch cluster with two nodes and an opensearch dashboard that has the updated image with the latest changes in this plugin.
> This is a test only docker compose that should not be used for production purpose - for such use cases please review this [link](https://opensearch.org/docs/latest/install-and-configure/install-opensearch/docker/)
### Option 1 (All from docker)
run `docker compose up -d` to start the services and once the service is up and running you can start testing the changes.

### Option 2 (Combined Docker & Dashboard)
run `docker compose up -d opensearch` to only run the OpenSearch engine - in this case the dashboard has to be run manualy using `yarn start --no-base-path` command in the root dashboards path `./OpenSearch-Dashboards/`

> Note that the OpenSearch version also must correspond to the OpenSearch-Dashboards version
## Accessing the Dashboard
Expand All @@ -37,5 +42,6 @@ The dashboard service uses port `localhost:5601` for access and this was already
```
## Security Notice
The default User:Password for this demo test is embedded within the [.env](.env) environment file - pay attention not to use this configuration in a production or any environment that may contain
confident or personal information without first changing the security definition for accessing the servers.
There is no security plugin and authentication definitions for this development test demo - pay attention not to use this configuration in a production or any environment that may contain
confident or personal information without first changing the security definition for accessing the servers - for production use cases please review this [link](https://opensearch.org/docs/latest/install-and-configure/install-opensearch/docker/)
67 changes: 23 additions & 44 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0


version: '3.9'
x-default-logging: &logging
driver: "json-file"
Expand All @@ -10,64 +8,46 @@ x-default-logging: &logging
max-file: "2"

volumes:
opensearch-data1:
opensearch-data2:
opensearch-data:

networks:
default:
name: opensearch-dashboards-demo
driver: bridge

services:
# OpenSearch store - node1
opensearch-node1: # This is also the hostname of the container within the Docker network (i.e. https://opensearch-node1/)
image: opensearchproject/opensearch:${VERSION} # Specifying the latest available image - modify if you want a specific version
container_name: opensearch-node1
environment:
- cluster.name=opensearch-cluster # Name the cluster
- node.name=opensearch-node1 # Name the node that will run in this container
- discovery.seed_hosts=opensearch-node1,opensearch-node2 # Nodes to look for when discovering the cluster
- cluster.initial_cluster_manager_nodes=opensearch-node1,opensearch-node2 # Nodes eligible to serve as cluster manager
- bootstrap.memory_lock=true # Disable JVM heap memory swapping
- "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" # Set min and max JVM heap sizes to at least 50% of system RAM
ulimits:
memlock:
soft: -1 # Set memlock to unlimited (no soft or hard limit)
hard: -1
nofile:
soft: 65536 # Maximum number of open files for the opensearch user - set to at least 65536
hard: 65536
volumes:
- opensearch-data1:/usr/share/opensearch/data # Creates volume called opensearch-data1 and mounts it to the container
healthcheck:
test: ["CMD", "curl", "-f", "https://opensearch-node1:9200/_cluster/health?wait_for_status=yellow", "-ku ${USER}:${PASSWORD}"]
interval: 5s
timeout: 25s
retries: 4
ports:
- "9200:9200"
- "9600:9600"

# OpenSearch store - node2
opensearch-node2:
image: opensearchproject/opensearch:${VERSION} # This should be the same image used for opensearch-node1 to avoid issues
container_name: opensearch-node2
# OpenSearch store - node (not for production - no security - only for test purpose )
opensearch:
image: opensearchstaging/opensearch:${VERSION}
container_name: opensearch
environment:
- cluster.name=opensearch-cluster
- node.name=opensearch-node2
- discovery.seed_hosts=opensearch-node1,opensearch-node2
- cluster.initial_cluster_manager_nodes=opensearch-node1,opensearch-node2
- node.name=opensearch
- discovery.seed_hosts=opensearch
- cluster.initial_cluster_manager_nodes=opensearch
- bootstrap.memory_lock=true
- "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m"
- "DISABLE_INSTALL_DEMO_CONFIG=true"
- "DISABLE_SECURITY_PLUGIN=true"
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536
soft: 65536 # Maximum number of open files for the opensearch user - set to at least 65536
hard: 65536
volumes:
- opensearch-data2:/usr/share/opensearch/data
- opensearch-data:/usr/share/opensearch/data # Creates volume called opensearch-data1 and mounts it to the container
ports:
- 9200:9200
- 9600:9600
expose:
- "9200"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9200/_cluster/health?wait_for_status=yellow"]
interval: 20s
timeout: 10s
retries: 10

# OpenSearch store - dashboard
opensearch-dashboards:
Expand All @@ -85,6 +65,5 @@ services:
environment:
OPENSEARCH_HOSTS: '["https://opensearch-node1:9200","https://opensearch-node2:9200"]' # Define the OpenSearch nodes that OpenSearch Dashboards will query
depends_on:
- opensearch-node1
- opensearch-node2
- opensearch

0 comments on commit 3ca83f8

Please sign in to comment.