diff --git a/docker/README.md b/docker/README.md index 159b5475906..4db396fc118 100644 --- a/docker/README.md +++ b/docker/README.md @@ -28,6 +28,7 @@ base layer `openzipkin/zipkin`, and setting up schema where relevant. * [zipkin-elasticsearch6](storage/elasticsearch6/README.md) - runs Elasticsearch 6.x * [zipkin-elasticsearch7](storage/elasticsearch7/README.md) - runs Elasticsearch 7.x * [zipkin-kafka](collector/kafka/README.md) - runs both Kafka+ZooKeeper +* [zipkin-mysql](storage/mysql/README.md) - runs MySQL initialized with Zipkin's schema * [zipkin-ui](lens/README.md) - serves the (Lens) UI directly with NGINX ### Dockerfile migration diff --git a/docker/hooks/post_build b/docker/hooks/post_build index 6d08e350adb..8ef4c389a67 100755 --- a/docker/hooks/post_build +++ b/docker/hooks/post_build @@ -26,7 +26,7 @@ for tag in ${TAGS[@]:1}; do done # We also build testing images to correspond with the server version to keep schemas up to date -for path in collector/kafka storage/cassandra storage/elasticsearch6 storage/elasticsearch7; do +for path in collector/kafka storage/cassandra storage/elasticsearch6 storage/elasticsearch7 storage/mysql; do image=$(basename ${path}) echo Building ${image} docker build --build-arg version="$SOURCE_BRANCH" -f "docker/${path}/Dockerfile" -t "openzipkin/${image}:${TAGS[0]}" . diff --git a/docker/hooks/post_push b/docker/hooks/post_push index f716ee30e2b..c18152824cd 100755 --- a/docker/hooks/post_push +++ b/docker/hooks/post_push @@ -13,7 +13,7 @@ if [[ "$DOCKER_REPO" == "index.docker.io/openzipkin/zipkin" ]]; then docker push "openzipkin/zipkin-${collector}:$tag" done - for storage in cassandra elasticsearch6 elasticsearch7; do + for storage in cassandra elasticsearch6 elasticsearch7 mysql; do docker push "openzipkin/zipkin-${storage}:$tag" done done diff --git a/docker/storage/cassandra/Dockerfile b/docker/storage/cassandra/Dockerfile index c5f93f75b8c..d4ea261cbec 100644 --- a/docker/storage/cassandra/Dockerfile +++ b/docker/storage/cassandra/Dockerfile @@ -16,8 +16,6 @@ FROM openzipkin/jre-full:1.8.0_212 MAINTAINER OpenZipkin "http://zipkin.io/" -ENV ZIPKIN_VERSION 2.18.0 - ENV CASSANDRA_VERSION=3.11.4 \ JAVA=/usr/local/java/jre/bin/java \ JVM_OPTS="-Dcassandra -Djava.net.preferIPv4Stack=true" diff --git a/docker/storage/mysql/Dockerfile b/docker/storage/mysql/Dockerfile new file mode 100644 index 00000000000..e3856e78f8f --- /dev/null +++ b/docker/storage/mysql/Dockerfile @@ -0,0 +1,29 @@ +# +# Copyright 2015-2019 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. +# + +FROM alpine +LABEL MAINTAINER Zipkin "https://zipkin.io/" + +WORKDIR /mysql +ADD docker/storage/mysql/install.sh /mysql/install +ADD docker/storage/mysql/configure.sh /mysql/configure +ADD docker/storage/mysql/run.sh /mysql/run.sh +ADD zipkin-storage/mysql-v1/src/main/resources/mysql.sql /mysql/zipkin.sql + +RUN /mysql/install && \ + /mysql/configure + +CMD /mysql/run.sh + +EXPOSE 3306 diff --git a/docker/storage/mysql/README.md b/docker/storage/mysql/README.md new file mode 100644 index 00000000000..59d7200ce6d --- /dev/null +++ b/docker/storage/mysql/README.md @@ -0,0 +1,16 @@ +## zipkin-mysql Docker image + +The `zipkin-mysql` testing image runs MySQL 3.11.x initialized with Zipkin's schema for +[MySQL storage](../../../zipkin-storage/mysql-v1) integration. + +To build `openzipkin/zipkin-mysql`, from the top level of the repository, run: + +```bash +$ docker build -t openzipkin/zipkin-mysql:test -f docker/storage/mysql/Dockerfile . +``` + +When running with docker-machine, you can connect like so: + +```bash +$ mysql -h $(docker-machine ip) -u zipkin -pzipkin -D zipkin +``` diff --git a/docker/storage/mysql/configure.sh b/docker/storage/mysql/configure.sh new file mode 100755 index 00000000000..4f9fabfcb07 --- /dev/null +++ b/docker/storage/mysql/configure.sh @@ -0,0 +1,60 @@ +#!/bin/sh +# +# Copyright 2015-2019 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 MySQL client" +apk add --update --no-cache mysql-client +chown -R mysql /mysql + +echo "*** Starting MySQL" +mysqld --user=mysql --basedir=/usr/ --datadir=/mysql/data & + +timeout=300 +while [[ "$timeout" -gt 0 ]] && ! mysql --user=mysql --protocol=socket -uroot -e 'SELECT 1' >/dev/null 2>/dev/null; do + echo "Waiting ${timeout} seconds for mysql to come up" + sleep 2 + timeout=$(($timeout - 2)) +done + +echo "*** Installing Schema" +mysql --verbose --user=mysql --protocol=socket -uroot <<-EOSQL +USE mysql ; + +DELETE FROM mysql.user ; +DROP DATABASE IF EXISTS test ; + +CREATE DATABASE zipkin ; + +USE zipkin; +SOURCE /mysql/zipkin.sql ; + +GRANT ALL PRIVILEGES ON zipkin.* TO zipkin@'%' IDENTIFIED BY 'zipkin' WITH GRANT OPTION ; +FLUSH PRIVILEGES ; +EOSQL + +echo "*** Stopping MySQL" +pkill -f mysqld + + +echo "*** Enabling Networking" +cat >> /etc/my.cnf <<-"EOF" +[mysqld] +skip-networking=0 +skip-bind-address +EOF + +echo "*** Cleaning Up" +apk del mysql-client --purge diff --git a/docker/storage/mysql/install.sh b/docker/storage/mysql/install.sh new file mode 100755 index 00000000000..4aa91bf27da --- /dev/null +++ b/docker/storage/mysql/install.sh @@ -0,0 +1,22 @@ +#!/bin/sh +# +# Copyright 2015-2019 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 MySQL" +apk add --update --no-cache mysql curl +mysql_install_db --user=mysql --basedir=/usr/ --datadir=/mysql/data --force +mkdir -p /run/mysqld/ +chown -R mysql /mysql /run/mysqld/ diff --git a/docker/storage/mysql/run.sh b/docker/storage/mysql/run.sh new file mode 100755 index 00000000000..39b647bf907 --- /dev/null +++ b/docker/storage/mysql/run.sh @@ -0,0 +1,16 @@ +#!/bin/sh +# +# Copyright 2015-2019 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. +# + +/usr/bin/mysqld_safe --user=mysql --basedir=/usr/ --datadir=/mysql/data