Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

Commit eb25ce7

Browse files
committed
Merge pull request #16 from lunika/percona-5.7
introduce version 5.7
2 parents 3c59ec2 + c02a9c6 commit eb25ce7

File tree

4 files changed

+156
-2
lines changed

4 files changed

+156
-2
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ services: docker
44
env:
55
- VERSION=5.6
66
- VERSION=5.5
7+
- VERSION=5.7
78

89
install:
910
- git clone https://github.com/docker-library/official-images.git ~/official-images

5.7/Dockerfile

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# vim:set ft=dockerfile:
2+
FROM debian:jessie
3+
4+
# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
5+
RUN groupadd -r mysql && useradd -r -g mysql mysql
6+
7+
# install "pwgen" for randomizing passwords
8+
RUN apt-get update && apt-get install -y pwgen && rm -rf /var/lib/apt/lists/*
9+
10+
RUN mkdir /docker-entrypoint-initdb.d
11+
12+
RUN apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys 430BDF5C56E7C94E848EE60C1C4CBDCDCD2EFD2A
13+
14+
RUN echo 'deb http://repo.percona.com/apt jessie main' > /etc/apt/sources.list.d/percona.list
15+
16+
ENV PERCONA_MAJOR 5.7
17+
ENV PERCONA_VERSION 5.7.10-3-1.jessie
18+
19+
# the "/var/lib/mysql" stuff here is because the mysql-server postinst doesn't have an explicit way to disable the mysql_install_db codepath besides having a database already "configured" (ie, stuff in /var/lib/mysql/mysql)
20+
# also, we set debconf keys to make APT a little quieter
21+
RUN { \
22+
echo percona-server-server-$PERCONA_MAJOR percona-server-server/root_password password 'unused'; \
23+
echo percona-server-server-$PERCONA_MAJOR percona-server-server/root_password_again password 'unused'; \
24+
} | debconf-set-selections \
25+
&& apt-get update \
26+
&& apt-get install -y \
27+
percona-server-server-$PERCONA_MAJOR=$PERCONA_VERSION \
28+
&& rm -rf /var/lib/apt/lists/* \
29+
&& rm -rf /var/lib/mysql \
30+
&& mkdir /var/lib/mysql
31+
32+
# comment out a few problematic configuration values
33+
# don't reverse lookup hostnames, they are usually another container
34+
RUN sed -Ei 's/^(bind-address|log)/#&/' /etc/mysql/my.cnf \
35+
&& echo 'skip-host-cache\nskip-name-resolve' | awk '{ print } $1 == "[mysqld]" && c == 0 { c = 1; system("cat") }' /etc/mysql/my.cnf > /tmp/my.cnf \
36+
&& mv /tmp/my.cnf /etc/mysql/my.cnf
37+
38+
VOLUME ["/var/lib/mysql", "/var/log/mysql"]
39+
40+
COPY docker-entrypoint.sh /
41+
42+
ENTRYPOINT ["/docker-entrypoint.sh"]
43+
44+
EXPOSE 3306
45+
CMD ["mysqld"]

5.7/docker-entrypoint.sh

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
#!/bin/bash
2+
set -eo pipefail
3+
4+
# if command starts with an option, prepend mysqld
5+
if [ "${1:0:1}" = '-' ]; then
6+
set -- mysqld "$@"
7+
fi
8+
9+
if [ "$1" = 'mysqld' ]; then
10+
# Get config
11+
DATADIR="$("$@" --verbose --help --log-bin-index=`mktemp -u` 2>/dev/null | awk '$1 == "datadir" { print $2; exit }')"
12+
13+
if [ ! -d "$DATADIR/mysql" ]; then
14+
if [ -z "$MYSQL_ROOT_PASSWORD" -a -z "$MYSQL_ALLOW_EMPTY_PASSWORD" -a -z "$MYSQL_RANDOM_ROOT_PASSWORD" ]; then
15+
echo >&2 'error: database is uninitialized and password option is not specified '
16+
echo >&2 ' You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD'
17+
exit 1
18+
fi
19+
20+
mkdir -p "$DATADIR"
21+
chown -R mysql:mysql "$DATADIR"
22+
23+
echo 'Initializing database'
24+
"$@" --initialize-insecure
25+
echo 'Database initialized'
26+
27+
"$@" --skip-networking &
28+
pid="$!"
29+
30+
mysql=( mysql --protocol=socket -uroot )
31+
32+
for i in {30..0}; do
33+
if echo 'SELECT 1' | "${mysql[@]}" &> /dev/null; then
34+
break
35+
fi
36+
echo 'MySQL init process in progress...'
37+
sleep 1
38+
done
39+
if [ "$i" = 0 ]; then
40+
echo >&2 'MySQL init process failed.'
41+
exit 1
42+
fi
43+
44+
if [ -z "$MYSQL_INITDB_SKIP_TZINFO" ]; then
45+
# sed is for https://bugs.mysql.com/bug.php?id=20545
46+
mysql_tzinfo_to_sql /usr/share/zoneinfo | sed 's/Local time zone must be set--see zic manual page/FCTY/' | "${mysql[@]}" mysql
47+
fi
48+
49+
if [ ! -z "$MYSQL_RANDOM_ROOT_PASSWORD" ]; then
50+
MYSQL_ROOT_PASSWORD="$(pwgen -1 32)"
51+
echo "GENERATED ROOT PASSWORD: $MYSQL_ROOT_PASSWORD"
52+
fi
53+
"${mysql[@]}" <<-EOSQL
54+
-- What's done in this file shouldn't be replicated
55+
-- or products like mysql-fabric won't work
56+
SET @@SESSION.SQL_LOG_BIN=0;
57+
58+
DELETE FROM mysql.user ;
59+
CREATE USER 'root'@'%' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}' ;
60+
GRANT ALL ON *.* TO 'root'@'%' WITH GRANT OPTION ;
61+
DROP DATABASE IF EXISTS test ;
62+
FLUSH PRIVILEGES ;
63+
EOSQL
64+
65+
if [ ! -z "$MYSQL_ROOT_PASSWORD" ]; then
66+
mysql+=( -p"${MYSQL_ROOT_PASSWORD}" )
67+
fi
68+
69+
if [ "$MYSQL_DATABASE" ]; then
70+
echo "CREATE DATABASE IF NOT EXISTS \`$MYSQL_DATABASE\` ;" | "${mysql[@]}"
71+
mysql+=( "$MYSQL_DATABASE" )
72+
fi
73+
74+
if [ "$MYSQL_USER" -a "$MYSQL_PASSWORD" ]; then
75+
echo "CREATE USER '$MYSQL_USER'@'%' IDENTIFIED BY '$MYSQL_PASSWORD' ;" | "${mysql[@]}"
76+
77+
if [ "$MYSQL_DATABASE" ]; then
78+
echo "GRANT ALL ON \`$MYSQL_DATABASE\`.* TO '$MYSQL_USER'@'%' ;" | "${mysql[@]}"
79+
fi
80+
81+
echo 'FLUSH PRIVILEGES ;' | "${mysql[@]}"
82+
fi
83+
84+
echo
85+
for f in /docker-entrypoint-initdb.d/*; do
86+
case "$f" in
87+
*.sh) echo "$0: running $f"; . "$f" ;;
88+
*.sql) echo "$0: running $f"; "${mysql[@]}" < "$f"; echo ;;
89+
*.sql.gz) echo "$0: running $f"; gunzip -c "$f" | "${mysql[@]}"; echo ;;
90+
*) echo "$0: ignoring $f" ;;
91+
esac
92+
echo
93+
done
94+
95+
if ! kill -s TERM "$pid" || ! wait "$pid"; then
96+
echo >&2 'MySQL init process failed.'
97+
exit 1
98+
fi
99+
100+
echo
101+
echo 'MySQL init process done. Ready for start up.'
102+
echo
103+
fi
104+
105+
chown -R mysql:mysql "$DATADIR"
106+
fi
107+
108+
exec "$@"

generate-stackbrew-library.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ set -e
33

44
declare -A aliases
55
aliases=(
6-
[5.6]='5 latest'
6+
[5.7]='5 latest'
77
)
88

99
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
@@ -18,7 +18,7 @@ for version in "${versions[@]}"; do
1818
commit="$(cd "$version" && git log -1 --format='format:%H' -- Dockerfile $(awk 'toupper($1) == "COPY" { for (i = 2; i < NF; i++) { print $i } }' Dockerfile))"
1919
fullVersion="$(grep -m1 'ENV PERCONA_VERSION ' "$version/Dockerfile" | cut -d' ' -f3 | cut -d- -f1)"
2020
versionAliases=( $fullVersion $version ${aliases[$version]} )
21-
21+
2222
echo
2323
for va in "${versionAliases[@]}"; do
2424
echo "$va: ${url}@${commit} $version"

0 commit comments

Comments
 (0)