forked from opensearch-project/OpenSearch-Dashboards
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add docker dev set up instruction (opensearch-project#3444)
* docker dev set up folder Signed-off-by: abbyhu2000 <[email protected]> * add curl commands to set up and copy the files Signed-off-by: abbyhu2000 <[email protected]> * changelog changes Signed-off-by: abbyhu2000 <[email protected]> * addressing comments Signed-off-by: abbyhu2000 <[email protected]> * add docker link to the developer guide Signed-off-by: abbyhu2000 <[email protected]> * Add notes on docker desktop Signed-off-by: abbyhu2000 <[email protected]> * publish the docker image to docker hub Signed-off-by: abbyhu2000 <[email protected]> * add docker exec as another option Signed-off-by: abbyhu2000 <[email protected]> --------- Signed-off-by: abbyhu2000 <[email protected]>
- Loading branch information
1 parent
525b033
commit 7b18e06
Showing
7 changed files
with
152 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env bash | ||
|
||
{ # this ensures the entire script is downloaded # | ||
|
||
osd_docker_dev_install_dir(){ | ||
printf "opensearch-dashboards-docker-dev" | ||
} | ||
|
||
osd_download(){ | ||
curl --fail --compressed -q "$@" | ||
} | ||
|
||
osd_do_copy_dev_docker_files(){ | ||
local INSTALL_DIR | ||
INSTALL_DIR="$(osd_docker_dev_install_dir)" | ||
local ENTRYPOINT_SRC | ||
ENTRYPOINT_SRC="https://raw.githubusercontent.com/opensearch-project/OpenSearch-Dashboards/main/docs/docker-dev/entrypoint.sh" | ||
local DOCKER_COMPOSE_SRC | ||
DOCKER_COMPOSE_SRC="https://raw.githubusercontent.com/opensearch-project/OpenSearch-Dashboards/main/docs/docker-dev/docker-compose.yml" | ||
|
||
mkdir -p "$INSTALL_DIR" | ||
osd_download -s "$ENTRYPOINT_SRC" -o "./$INSTALL_DIR/entrypoint.sh" | ||
osd_download -s "$DOCKER_COMPOSE_SRC" -o "./$INSTALL_DIR/docker-compose.yml" | ||
} | ||
|
||
osd_do_copy_dev_docker_files | ||
|
||
} # this ensures the entire script is downloaded # |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
version: '3' | ||
services: | ||
opensearch-node: | ||
image: opensearchproject/opensearch:latest | ||
container_name: opensearch-node | ||
environment: | ||
- cluster.name=opensearch-cluster # Name the cluster | ||
- node.name=opensearch-node # Name the node that will run in this container | ||
- discovery.seed_hosts=opensearch-node # Nodes to look for when discovering the cluster | ||
- cluster.initial_cluster_manager_nodes=opensearch-node # Nodes eligibile 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 | ||
- "DISABLE_INSTALL_DEMO_CONFIG=true" # Prevents execution of bundled demo script which installs demo certificates and security configurations to OpenSearch | ||
- "DISABLE_SECURITY_PLUGIN=true" # Disables security plugin | ||
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-data:/usr/share/opensearch/data # Creates volume called opensearch-data1 and mounts it to the container | ||
ports: | ||
- 9200:9200 # REST API | ||
- 9600:9600 # Performance Analyzer | ||
networks: | ||
- opensearch-net # All of the containers will join the same Docker bridge network | ||
dev-env: | ||
image: abbyhu/opensearch-dashboards-dev:latest | ||
container_name: dev-env | ||
ports: | ||
- 5601:5601 | ||
- 5603:5603 | ||
stdin_open: true | ||
tty: true | ||
expose: | ||
- "5601" | ||
- "5603" | ||
environment: | ||
- 'OPENSEARCH_HOSTS=["http://opensearch-node:9200"]' | ||
- 'SERVER_HOST="0.0.0.0"' | ||
- 'REPO_URL=${REPO_URL}' | ||
volumes: | ||
- osd-dev:/home/osd-dev | ||
- ./entrypoint.sh:/entrypoint.sh | ||
networks: | ||
- opensearch-net | ||
entrypoint: | ||
- /bin/bash | ||
- /entrypoint.sh | ||
volumes: | ||
opensearch-data: | ||
osd-dev: | ||
networks: | ||
opensearch-net: | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Docker Development Environment Setup | ||
The following instructions demonstrate how to set up a development environment for OpenSearch Dashboards using Docker. It utilizes tools such as `Docker` and `VS Code`, and users should be familiar with the basic usages of them. Users will be able to develop and run the application inside VS Code without additional configurations. | ||
|
||
1. Install [Docker](https://docs.docker.com/get-docker/) if not already installed. | ||
* Make sure that Docker daemon is running. (For windows and macos,you need to have [Docker Desktop](https://docs.docker.com/desktop/), or its alternatives, such as [Finch](https://github.com/runfinch/finch)) | ||
|
||
2. In the terminal, run the command below. | ||
* This should create a folder named `opensearch-dashboards-docker-dev` and it should contain two files: `docker-compose.yml` and `entrypoint.sh`. | ||
* Here is the link to the installer script: `https://raw.githubusercontent.com/opensearch-project/OpenSearch-Dashboards/main/dev-tools/install-docker-dev.sh` if needed. | ||
|
||
```bash | ||
curl -o- https://raw.githubusercontent.com/opensearch-project/OpenSearch-Dashboards/main/dev-tools/install-docker-dev.sh | bash | ||
``` | ||
|
||
3. Open VS Code or [install it](https://code.visualstudio.com/download), if it's not already installed. | ||
* Make sure VS Code has the extensions `Dev Containers` and `Docker` installed. If not, go to `Extensions` tab, search and install them. | ||
|
||
4. Under the Discover tab, click `Open Folder`, and open the `opensearch-dashboards-docker-dev` folder that we just created. | ||
|
||
5. Open the `opensearch-dashboards-docker-dev` folder in VS Code integrated terminal, set environment variable for the fork repository URL by running the command below. | ||
* If fork repo has not been created: Go to [OpenSearch Dashboards github page](https://github.com/opensearch-project/OpenSearch-Dashboards) and under fork, select create a new fork, and then copy the https link of the fork url and use it in the above command. The command needs to be re-run every time it re-start the docker compose file in a new terminal. | ||
```bash | ||
export REPO_URL=[insert your fork repo url here] | ||
``` | ||
|
||
6. Run the `docker-compose.yml` file in the background by typing: | ||
```bash | ||
docker compose up -d --build | ||
``` | ||
|
||
7. Under the `Docker` tab in VS Code, verify that there are two containers running: `opensearchproject/opensearch:latest` and `abbyhu/opensearch-dashboards-dev:latest`. | ||
* This can also be verified by using the command line: | ||
```bash | ||
docker ps | ||
``` | ||
|
||
8. Right-click `abbyhu/opensearch-dashboards-dev:latest`, and select `Attach Visual Studio Code`. | ||
* This will ssh into the container and you will be able to view and edit the files using VS Code as the code editor. | ||
* If you do not wish to use VS Code as the code editor, the alternative way of ssh into the container is by using the command below: | ||
```bash | ||
docker exec -it dev-env /bin/bash | ||
``` | ||
9. For the new VS Code window, if it is not showing the repository code, then select `Open Folder`. Then open `/workspace-docker/OpenSearch-Dashboards`. | ||
10. In the terminal, start the OpenSearch Dashboards application by typing: | ||
```bash | ||
yarn start:docker | ||
``` | ||
11. Now that OpenSearch Dashboards is running, you should be able to see a log line similar to `[info][server][OpenSearchDashboards][http] http server running at http://0.0.0.0:5603/dog`. | ||
* The last three letters `dog` are randomly generated every time we start dashboards. | ||
12. Wait for the optimizer to run, which takes about 100s - 200s. Once the optimizer is finished running, it will show a line such as `[success][@osd/optimizer] 48 bundles compiled successfully after 204.9 sec, watching for changes`. | ||
13. Then paste the link into a chrome browser and view dashboard running in browser, but change ‘0.0.0.0’ to ‘localhost’. So here the link should be `http://localhost:5603/dog`. | ||
* Files are constantly watched, so when you make code changes, OpenSearch Dashboards will rebuild and restart automatically. Refresh the link in the browser and the new changes should be applied. | ||
14. `Git` is already configured in the `entrypoint.sh` file, and the remote is already tracking the fork repository. You can start contributing by creating your branch off the main, and commit your first PR! |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
echo $REPO_URL | ||
git remote set-url origin $REPO_URL | ||
git fetch | ||
tail -f /dev/null |
This file contains 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