-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docker: adds zipkin-rabbitmq test image (#3626)
Signed-off-by: Adrian Cole <[email protected]>
- Loading branch information
1 parent
25dfdbd
commit 01929cb
Showing
12 changed files
with
226 additions
and
21 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
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
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,40 @@ | ||
# | ||
# 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. | ||
# | ||
|
||
# This file uses the version 2 docker-compose file format, described here: | ||
# https://docs.docker.com/compose/compose-file/#version-2 | ||
# | ||
# It extends the default configuration from docker-compose.yml to add a test | ||
# rabbitmq server, which is used as a span transport. | ||
|
||
version: '2.4' | ||
|
||
services: | ||
rabbitmq: | ||
image: ghcr.io/openzipkin/zipkin-rabbitmq:${TAG:-latest} | ||
container_name: rabbitmq | ||
# Uncomment to expose the AMQP port for testing | ||
# ports: | ||
# - 5672:5672 | ||
|
||
zipkin: | ||
extends: | ||
file: docker-compose.yml | ||
service: zipkin | ||
# slim doesn't include Kafka support, so switch to the larger image | ||
image: ghcr.io/openzipkin/zipkin:${TAG:-latest} | ||
environment: | ||
- RABBIT_ADDRESSES=rabbitmq:5672 | ||
depends_on: | ||
- rabbitmq |
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,59 @@ | ||
# | ||
# 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. | ||
# | ||
|
||
# Use latest version here: https://github.com/orgs/openzipkin/packages/container/package/alpine | ||
# This is defined in many places because Docker has no "env" script functionality unless you use | ||
# docker-compose: When updating, update everywhere. | ||
ARG alpine_version=3.19.0 | ||
|
||
# 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 | ||
|
||
WORKDIR /docker-bin | ||
COPY build-bin/docker/docker-healthcheck /docker-bin/ | ||
COPY docker/test-images/zipkin-rabbitmq/start-rabbitmq /docker-bin/ | ||
COPY docker/test-images/zipkin-rabbitmq/install.sh /install/ | ||
|
||
FROM ghcr.io/openzipkin/alpine:${alpine_version} as zipkin-rabbitmq | ||
LABEL org.opencontainers.image.description="RabbitMQ on Alpine Linux" | ||
|
||
# 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-rabbitmq"] | ||
|
||
# Use latest from https://pkgs.alpinelinux.org/packages?name=rabbitmq-server | ||
ARG rabbitmq_version=3.12.8 | ||
LABEL rabbitmq-version=$rabbitmq_version | ||
ENV RABBITMQ_SERVER_VERSION=$rabbitmq_version | ||
# Use latest from https://pkgs.alpinelinux.org/packages?name=rabbitmq-c-utils | ||
ARG rabbitmq_c_utils_version=0.13.0 | ||
ENV RABBITMQ_C_UTILS_VERSION=$rabbitmq_c_utils_version | ||
|
||
COPY --from=scratch /install/install.sh /tmp/install/ | ||
|
||
ARG USER=rabbitmq | ||
# We don't set USER because rabbitmq-server needs to start as root. | ||
RUN adduser -g '' -h ${PWD} -D ${USER} && \ | ||
(cd /tmp/install && ./install.sh) && rm -rf /tmp/install | ||
|
||
# Usually, we read env set from pid 1 to get docker-healthcheck parameters. | ||
# However, rabbitmq-server has to start as root even if permissions are dropped | ||
# later. So, we expose it in the Dockerfile instead. | ||
ENV HEALTHCHECK_PORT=5672 | ||
ENV HEALTHCHECK_KIND=tcp | ||
EXPOSE 5672 |
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,12 @@ | ||
## zipkin-rabbitmq Docker image | ||
|
||
The `zipkin-rabbitmq` testing image runs `rabbitmq-server` for the | ||
[RabbitMQ collector](../../../zipkin-collector/rabbitmq) integration. | ||
|
||
For convenience, this includes the "guest" user and a default queue named | ||
"zipkin". To add more queues, exec `amqp-declare-queue` in a running container. | ||
|
||
To build `openzipkin/zipkin-rabbitmq:test`, from the top-level of the repository, run: | ||
```bash | ||
$ DOCKER_FILE=docker/test-images/zipkin-rabbitmq/Dockerfile build-bin/docker/docker_build openzipkin/zipkin-rabbitmq:test | ||
``` |
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,46 @@ | ||
#!/bin/sh | ||
# | ||
# 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. | ||
# | ||
|
||
set -eux | ||
|
||
echo "*** Installing RabbitMQ" | ||
apk add --update --no-cache rabbitmq-server=~${RABBITMQ_SERVER_VERSION} rabbitmq-c-utils=~${RABBITMQ_C_UTILS_VERSION} | ||
|
||
echo "*** Ensuring guest can access RabbitMQ from any hostname" | ||
mkdir -p /etc/rabbitmq/ | ||
echo "loopback_users.guest = false" >> /etc/rabbitmq/rabbitmq.conf | ||
chown -R rabbitmq /var/lib/rabbitmq /etc/rabbitmq | ||
|
||
echo "*** Starting RabbitMQ" | ||
rabbitmq-server & | ||
temp_rabbitmq_pid=$! | ||
|
||
# Excessively long timeout to avoid having to create an ENV variable, decide its name, etc. | ||
timeout=180 | ||
echo "Will wait up to ${timeout} seconds for RabbitMQ to come up before configuring" | ||
while [ "$timeout" -gt 0 ] && kill -0 ${temp_rabbitmq_pid} && ! rabbitmqctl status > /dev/null 2>&1; do | ||
sleep 1 | ||
timeout=$(($timeout - 1)) | ||
done | ||
|
||
echo "*** Adding zipkin queue" | ||
amqp-declare-queue -q zipkin | ||
|
||
echo "*** Stopping RabbitMQ" | ||
kill ${temp_rabbitmq_pid} | ||
wait | ||
|
||
echo "*** Cleaning Up" | ||
rm /var/log/rabbitmq/* |
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,22 @@ | ||
#!/bin/sh | ||
# | ||
# 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. | ||
# | ||
|
||
# ENTRYPOINT script that starts RabbitMQ | ||
# | ||
# This intentionally locates config using the current working directory, in order to consolidate | ||
# Dockerfile instructions to WORKDIR | ||
set -eu | ||
|
||
exec rabbitmq-server "$@" |
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