Skip to content

Commit

Permalink
Add test-image zipkin-elasticsearch8
Browse files Browse the repository at this point in the history
  • Loading branch information
shakuzen committed Aug 28, 2023
1 parent a38c405 commit 3e7cfb6
Show file tree
Hide file tree
Showing 7 changed files with 182 additions and 1 deletion.
1 change: 1 addition & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ base layer `openzipkin/zipkin`, and setting up schema where relevant.
* [ghcr.io/openzipkin/zipkin-cassandra](test-images/zipkin-cassandra/README.md) - runs Cassandra initialized with Zipkin's schema
* [ghcr.io/openzipkin/zipkin-elasticsearch6](test-images/zipkin-elasticsearch6/README.md) - runs Elasticsearch 6.x
* [ghcr.io/openzipkin/zipkin-elasticsearch7](test-images/zipkin-elasticsearch7/README.md) - runs Elasticsearch 7.x
* [ghcr.io/openzipkin/zipkin-elasticsearch8](test-images/zipkin-elasticsearch8/README.md) - runs Elasticsearch 8.x
* [ghcr.io/openzipkin/zipkin-kafka](test-images/zipkin-kafka/README.md) - runs both Kafka+ZooKeeper
* [ghcr.io/openzipkin/zipkin-mysql](test-images/zipkin-mysql/README.md) - runs MySQL initialized with Zipkin's schema
* [ghcr.io/openzipkin/zipkin-ui](test-images/zipkin-ui/README.md) - serves the (Lens) UI directly with NGINX
Expand Down
74 changes: 74 additions & 0 deletions docker/test-images/zipkin-elasticsearch8/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#
# Copyright 2015-2023 The OpenZipkin Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
# in compliance with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
# or implied. See the License for the specific language governing permissions and limitations under
# the License.
#

# java_version is used for install and runtime layers of zipkin-elasticsearch8
#
# Use latest version here: https://github.com/orgs/openzipkin/packages/container/package/java
# This is defined in many places because Docker has no "env" script functionality unless you use
# docker-compose: When updating, update everywhere.
ARG java_version=17.0.7_p7

# We copy files from the context into a scratch container first to avoid a problem where docker and
# docker-compose don't share layer hashes https://github.com/docker/compose/issues/883 normally.
# COPY --from= works around the issue.
FROM scratch as scratch

COPY build-bin/docker/docker-healthcheck /docker-bin/
COPY docker/test-images/zipkin-elasticsearch8/start-elasticsearch /docker-bin/
COPY docker/test-images/zipkin-elasticsearch8/config/ /config/

FROM ghcr.io/openzipkin/java:${java_version} as install

WORKDIR /install

# Use latest 7.x version from https://www.elastic.co/downloads/past-releases#elasticsearch
# This is defined in many places because Docker has no "env" script functionality unless you use
# docker-compose: When updating, update everywhere.
ARG elasticsearch8_version=8.9.1

# Download only the OSS distribution (lacks X-Pack)
RUN \
# Connection resets are frequent in GitHub Actions workflows
wget --random-wait --tries=5 -qO- \
# We don't download bin scripts as we customize for reasons including BusyBox problems
https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-oss-${elasticsearch8_version}-no-jdk-linux-x86_64.tar.gz| tar xz \
--wildcards --strip=1 --exclude=*/bin && mkdir classes

COPY --from=scratch /config/ ./config/

FROM ghcr.io/openzipkin/java:${java_version}-jre as zipkin-elasticsearch8
LABEL org.opencontainers.image.description="Elasticsearch OSS distribution on OpenJDK and Alpine Linux"
ARG elasticsearch8_version=8.9.1
LABEL elasticsearch-version=$elasticsearch8_version

# Add HEALTHCHECK and ENTRYPOINT scripts into the default search path
COPY --from=scratch /docker-bin/* /usr/local/bin/
# We use start period of 30s to avoid marking the container unhealthy on slow or contended CI hosts
HEALTHCHECK --interval=1s --start-period=30s --timeout=5s CMD ["docker-healthcheck"]
ENTRYPOINT ["start-elasticsearch"]

# All content including binaries and logs write under WORKDIR
ARG USER=elasticsearch
WORKDIR /${USER}

# Ensure the process doesn't run as root
RUN adduser -g '' -h ${PWD} -D ${USER}
USER ${USER}

# Copy binaries and config we installed earlier
COPY --from=install --chown=${USER} /install .

# Use to set heap, trust store or other system properties.
ENV JAVA_OPTS="-Xms256m -Xmx256m -XX:+ExitOnOutOfMemoryError"
EXPOSE 9200
23 changes: 23 additions & 0 deletions docker/test-images/zipkin-elasticsearch8/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## zipkin-elasticsearch8 Docker image

The `zipkin-elasticsearch8` testing image runs Elasticsearch 8.x for [Elasticsearch storage](../../../zipkin-storage/elasticsearch)
integration.

To build `openzipkin/zipkin-elasticsearch8:test`, from the top-level of the repository, run:
```bash
$ DOCKER_FILE=docker/test-images/zipkin-elasticsearch8/Dockerfile build-bin/docker/docker_build openzipkin/zipkin-elasticsearch8:test
```

You can use the env variable `JAVA_OPTS` to change settings such as heap size for Elasticsearch.

#### Host setup
Elasticsearch is [strict](https://github.com/docker-library/docs/tree/master/elasticsearch#host-setup)
about virtual memory. You will need to adjust accordingly (especially if you notice Elasticsearch crash!)

```bash
# If docker is running on your host machine, adjust the kernel setting directly
$ sudo sysctl -w vm.max_map_count=262144

# If using docker-machine/Docker Toolbox/Boot2Docker, remotely adjust the same
$ docker-machine ssh default "sudo sysctl -w vm.max_map_count=262144"
```
19 changes: 19 additions & 0 deletions docker/test-images/zipkin-elasticsearch8/config/elasticsearch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#
# Copyright 2015-2020 The OpenZipkin Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
# in compliance with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
# or implied. See the License for the specific language governing permissions and limitations under
# the License.
#

network.host: 0.0.0.0
node.name: zipkin-elasticsearch
cluster.name: "docker-cluster"
cluster.initial_master_nodes:
- zipkin-elasticsearch
24 changes: 24 additions & 0 deletions docker/test-images/zipkin-elasticsearch8/config/log4j2.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# Copyright 2015-2020 The OpenZipkin Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
# in compliance with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
# or implied. See the License for the specific language governing permissions and limitations under
# the License.
#

status = error

appender.console.type = Console
appender.console.name = console
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] [%node_name]%marker %m%n

rootLogger.level = info
rootLogger.appenderRef.console.ref = console

40 changes: 40 additions & 0 deletions docker/test-images/zipkin-elasticsearch8/start-elasticsearch
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/sh
#
# Copyright 2015-2020 The OpenZipkin Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
# in compliance with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
# or implied. See the License for the specific language governing permissions and limitations under
# the License.
#

# ENTRYPOINT script that starts Elasticsearch
#
# This intentionally locates config using the current working directory, in order to consolidate
# Dockerfile instructions to WORKDIR
set -eu

# This file inlines what's done by the Elasticsearch script machinery, which doesn't work here due
# to our images using busybox (not bash). See #3044
#
# Notable settings:
# * lower heap size
# * tmpdir manual as https://github.com/elastic/elasticsearch/pull/31003 was closed won't fix
# * disable log4j JMX not just because we don't use it...
# * ES enables security manager https://github.com/elastic/elasticsearch/issues/21932#issuecomment-264435034

# Configure the Docker HEALTHCHECK
export HEALTHCHECK_PORT=9200
export HEALTHCHECK_PATH=/_cluster/health

# -cp 'classes:lib/*' allows layers to patch the image without packaging or overwriting jars
exec java -cp 'classes:lib/*' ${JAVA_OPTS} \
-Djava.io.tmpdir=/tmp \
-Dlog4j2.disable.jmx=true \
-Des.path.home=$PWD -Des.path.conf=$PWD/config \
org.elasticsearch.bootstrap.Elasticsearch "$@"
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
<assertj.version>3.18.1</assertj.version>
<awaitility.version>4.0.3</awaitility.version>
<hamcrest.version>1.3</hamcrest.version>
<testcontainers.version>1.15.1</testcontainers.version>
<testcontainers.version>1.19.0</testcontainers.version>
<okhttp.version>4.9.0</okhttp.version>
<okhttp5.version>5.0.0-alpha.11</okhttp5.version>
<kryo.version>5.0.3</kryo.version>
Expand Down

0 comments on commit 3e7cfb6

Please sign in to comment.