This repository has been archived by the owner on Sep 10, 2024. It is now read-only.
forked from elastic/kibana
-
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 containerized development env for Kibana
- Loading branch information
Showing
3 changed files
with
128 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Containerized development environment for Kibana | ||
|
||
Kibana development moves quickly and has specific NodeJS requirements, which can | ||
change depending on the current branch or commit. This makes developing a plugin | ||
challenging for local development. | ||
|
||
We created a containerized environment to encapsulate the necessary dependencies | ||
and reduce issues, especially when switching between Kibana versions. | ||
|
||
## Assumptions | ||
|
||
By default, this setup assumes that you are running Elasticsearch via the | ||
`apm-integration-testing` repo. However, you can override this as described | ||
below. | ||
|
||
## Usage | ||
|
||
You will first need to build the Docker image for the Kibana environment: | ||
|
||
``` | ||
make build | ||
``` | ||
|
||
This will create a Docker image with the tag `kibana-dev:8.1.x`. | ||
|
||
If you wish to change the image version, you can run this instead: | ||
|
||
``` | ||
make build KIBANA_VERSION=8.2 | ||
``` | ||
|
||
Next, you can start the container using this (assumes Docker image is | ||
`kibana-dev:8.1.x` and Elasticsearch is running on the `apm-integration-testing` | ||
Docker network): | ||
|
||
``` | ||
make run | ||
``` | ||
|
||
If your Elasticsearch instance is not running via Docker, you can run this: | ||
|
||
``` | ||
make run-networkless | ||
``` | ||
|
||
## Configuration | ||
|
||
* `KIBANA_VERSION` | ||
|
||
This is the version of the Docker image. This can be used to build separate | ||
images for different Kibana versions. | ||
|
||
* `NETWORK` | ||
|
||
This is the Docker network to use so that Kibana can connect to a local running | ||
instance of Elasticsearch. | ||
|
||
* `PORT` | ||
|
||
This is the exposed port for the Kibana instance. This is useful if you have | ||
conflicts with another running instance. |
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,48 @@ | ||
FROM ubuntu:21.10 | ||
|
||
RUN rm /bin/sh && ln -s /bin/bash /bin/sh | ||
|
||
# Install base dependencies | ||
RUN apt-get update | ||
|
||
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y tzdata | ||
|
||
RUN apt-get install -y -q --no-install-recommends \ | ||
apt-transport-https \ | ||
build-essential \ | ||
ca-certificates \ | ||
curl \ | ||
git \ | ||
libssl-dev \ | ||
python3 \ | ||
wget \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN useradd -ms /bin/bash -d /kibana kibana | ||
|
||
# Install and setup nvm and node | ||
USER kibana | ||
|
||
ARG NODE_VERSION | ||
|
||
ENV NVM_VERSION v0.39.1 | ||
ENV NVM_DIR /kibana/nvm | ||
|
||
RUN mkdir $NVM_DIR \ | ||
&& cd $NVM_DIR \ | ||
&& curl https://raw.githubusercontent.com/nvm-sh/nvm/$NVM_VERSION/install.sh | bash \ | ||
&& . ./nvm.sh \ | ||
&& nvm install $NODE_VERSION \ | ||
&& nvm alias default $NODE_VERSION \ | ||
&& nvm use default | ||
|
||
ENV NODE_PATH $NVM_DIR/versions/node/v$NODE_VERSION/lib/node_modules | ||
ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH | ||
|
||
# Install yarn | ||
USER kibana | ||
WORKDIR /kibana | ||
RUN npm install -g yarn | ||
|
||
WORKDIR /kibana/src | ||
CMD ["bash"] |
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,19 @@ | ||
NODE_VERSION = $(shell cat .node-version) | ||
|
||
KIBANA_VERSION ?= 8.1.x | ||
NETWORK ?= apm-integration-testing | ||
PORT ?= 5601 | ||
|
||
DOCKER_IMAGE = kibana-dev:${KIBANA_VERSION} | ||
DOCKER_RUN_ARGS = --rm -p ${PORT}:5601 -p 9229-9231:9229-9231/tcp -v $(shell pwd):/kibana/src -it ${DOCKER_IMAGE} | ||
|
||
.PHONY: build run run-networkless | ||
|
||
build: | ||
docker build --build-arg NODE_VERSION="${NODE_VERSION}" -t ${DOCKER_IMAGE} . | ||
|
||
run: | ||
docker run --network ${NETWORK} ${DOCKER_RUN_ARGS} | ||
|
||
run-networkless: | ||
docker run ${DOCKER_RUN_ARGS} |