-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dave Barnum
committed
Oct 16, 2016
1 parent
a9df67d
commit 369b5fc
Showing
2 changed files
with
39 additions
and
9 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 |
---|---|---|
|
@@ -3,20 +3,21 @@ MAINTAINER [email protected] | |
|
||
RUN apt-get update && apt-get upgrade -y \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
COPY ["scripts/", "/docker-entrypoint-initdb.d/"] | ||
COPY ["bin/initialize.sh", "bin/preflight.sh", "bin/persistence-cleanup.sh", "/usr/local/bin/"] | ||
RUN chmod 755 /usr/local/bin/persistence-cleanup.sh; \ | ||
|
||
COPY ["scripts/", "/docker-entrypoint-initdb.d/"] | ||
COPY ["bin/initialize.sh", "bin/preflight.sh", "bin/docker-healthcheck", "bin/persistence-cleanup.sh", "/usr/local/bin/"] | ||
RUN chmod 755 /usr/local/bin/docker-healthcheck; \ | ||
chmod 755 /usr/local/bin/persistence-cleanup.sh; \ | ||
chmod 755 /usr/local/bin/initialize.sh; \ | ||
chmod 755 /usr/local/bin/preflight.sh; \ | ||
chmod 755 /usr/local/bin/preflight.sh; \ | ||
sed -i '/bin\/bash/a /usr/local/bin/initialize.sh' /usr/local/bin/docker-entrypoint.sh; \ | ||
sed -i '/exec "$@"/i /usr/local/bin/preflight.sh' /usr/local/bin/docker-entrypoint.sh | ||
sed -i '/exec "$@"/i /usr/local/bin/preflight.sh' /usr/local/bin/docker-entrypoint.sh | ||
|
||
# we need to touch and chown config files, since we cant write as mysql user | ||
RUN touch /etc/mysql/conf.d/galera.cnf \ | ||
touch /etc/mysql/conf.d/cust.cnf \ | ||
&& chown mysql.mysql /etc/mysql/conf.d/galera.cnf \ | ||
&& chown mysql.mysql /etc/mysql/conf.d/cust.cnf \ | ||
&& chown mysql.mysql /etc/mysql/conf.d/cust.cnf \ | ||
&& chown mysql.mysql /docker-entrypoint-initdb.d/*.sql | ||
|
||
# we expose all Cluster related Ports | ||
|
@@ -30,6 +31,8 @@ EXPOSE 3306 4444 4567 4568 | |
ENV GALERA_USER=galera \ | ||
GALERA_PASS=galerapass \ | ||
MAXSCALE_USER=maxscale \ | ||
MAXSCALE_PASS=maxscalepass \ | ||
MAXSCALE_PASS=maxscalepass \ | ||
CLUSTER_NAME=docker_cluster \ | ||
MYSQL_ALLOW_EMPTY_PASSWORD=1 | ||
MYSQL_ALLOW_EMPTY_PASSWORD=1 | ||
|
||
HEALTHCHECK CMD ["docker-healthcheck"] |
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,27 @@ | ||
#!/bin/bash | ||
set -eo pipefail | ||
|
||
if [ "$MYSQL_RANDOM_ROOT_PASSWORD" ] && [ -z "$MYSQL_USER" ] && [ -z "$MYSQL_PASSWORD" ]; then | ||
# there's no way we can guess what the random MySQL password was | ||
echo >&2 'healthcheck error: cannot determine random root password (and MYSQL_USER and MYSQL_PASSWORD were not set)' | ||
exit 0 | ||
fi | ||
|
||
host="$(hostname --ip-address || echo '127.0.0.1')" | ||
user="${MYSQL_USER:-root}" | ||
export MYSQL_PWD="${MYSQL_PASSWORD:-$MYSQL_ROOT_PASSWORD}" | ||
|
||
args=( | ||
# force mysql to not use the local "mysqld.sock" (test "external" connectibility) | ||
-h"$host" | ||
-u"$user" | ||
--silent | ||
) | ||
|
||
if select="$(echo 'SELECT 1' | mysql "${args[@]}")" && [ "$select" = '1' ]; then | ||
exit 0 | ||
fi | ||
|
||
# If the probe returns 2 ("starting") when the container has already moved out of the "starting" state then it is treated as "unhealthy" instead. | ||
# https://github.com/docker/docker/blob/dcc65376bac8e73bb5930fce4cddc2350bb7baa2/docs/reference/builder.md#healthcheck | ||
exit 2 |