-
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.
Adds MySQL Docker container build (#2854)
- Loading branch information
1 parent
b5f0d17
commit b2445f5
Showing
9 changed files
with
146 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
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,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 | ||
``` |
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,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 |
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-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/ |
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,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 |