Skip to content

Commit 12a39d0

Browse files
committed
Add Oracle Linux image variants
The primary benefits of this are arm64 support (in 8.0) and smaller images (in 5.7 and 8.0). ```console $ docker images mysql REPO TAG IMAGE-ID SIZE mysql 5.6-debian 9e4a20b3bbbc 302MB mysql 5.6-oracle 929e36226e5f 347MB mysql 5.7-debian a4fdfd462add 448MB mysql 5.7-oracle 526647feecfa 338MB mysql 8.0-debian 30f937e841c8 541MB mysql 8.0-oracle 71ceccbba717 381MB ```
1 parent bc6e37a commit 12a39d0

9 files changed

+419
-47
lines changed
File renamed without changes.

5.6/Dockerfile.oracle

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
FROM oraclelinux:7-slim
2+
3+
RUN set -eux; \
4+
groupadd --system --gid 999 mysql; \
5+
useradd --system --uid 999 --gid 999 --home-dir /var/lib/mysql --no-create-home mysql; \
6+
\
7+
mkdir /var/lib/mysql /var/run/mysqld; \
8+
chown mysql:mysql /var/lib/mysql /var/run/mysqld; \
9+
# ensure that /var/run/mysqld (used for socket and lock files) is writable regardless of the UID our mysqld instance ends up having at runtime
10+
chmod 777 /var/run/mysqld; \
11+
\
12+
mkdir /docker-entrypoint-initdb.d
13+
14+
# add gosu for easy step-down from root
15+
# https://github.com/tianon/gosu/releases
16+
ENV GOSU_VERSION 1.12
17+
RUN set -eux; \
18+
# TODO find a better userspace architecture detection method than querying the kernel
19+
arch="$(uname -m)"; \
20+
case "$arch" in \
21+
aarch64) gosuArch='arm64' ;; \
22+
x86_64) gosuArch='amd64' ;; \
23+
*) echo >&2 "error: unsupported architecture: '$arch'"; exit 1 ;; \
24+
esac; \
25+
curl -fL -o /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$gosuArch.asc"; \
26+
curl -fL -o /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$gosuArch"; \
27+
export GNUPGHOME="$(mktemp -d)"; \
28+
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \
29+
gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \
30+
rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc; \
31+
chmod +x /usr/local/bin/gosu; \
32+
gosu --version; \
33+
gosu nobody true
34+
35+
RUN set -eux; \
36+
# https://dev.mysql.com/doc/refman/8.0/en/checking-gpg-signature.html
37+
# gpg: key 8C718D3B5072E1F5: public key "MySQL Release Engineering <[email protected]>" imported
38+
key='A4A9406876FCBD3C456770C88C718D3B5072E1F5'; \
39+
export GNUPGHOME="$(mktemp -d)"; \
40+
gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \
41+
gpg --batch --export --armor "$key" > /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql; \
42+
rm -rf "$GNUPGHOME"
43+
44+
ENV MYSQL_MAJOR 5.6
45+
ENV MYSQL_VERSION 5.6.48-2.el7
46+
# bashbrew-architectures: amd64
47+
48+
RUN set -eu; \
49+
{ \
50+
echo "[mysql${MYSQL_MAJOR//./}-server-minimal]"; \
51+
echo "name=MySQL $MYSQL_MAJOR Server Minimal"; \
52+
echo 'enabled=1'; \
53+
echo "baseurl=http://repo.mysql.com/yum/mysql-$MYSQL_MAJOR-community/docker/\$basearch/"; \
54+
echo 'gpgcheck=1'; \
55+
echo 'gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql'; \
56+
} | tee /etc/yum.repos.d/mysql-community-minimal.repo
57+
58+
RUN set -eux; \
59+
yum install -y "mysql-community-server-minimal-$MYSQL_VERSION"; \
60+
yum clean all; \
61+
# the "log-error" value in the MySQL 5.6 packages is set to a file (instead of being empty)
62+
sed -i '/^log-error=/d' /etc/my.cnf; \
63+
\
64+
mysqld --version; \
65+
mysql --version
66+
67+
ENV MYSQL_SHELL_VERSION 8.0.20-1.el7
68+
RUN set -eu; \
69+
. /etc/os-release; \
70+
{ \
71+
echo '[mysql-tools-community]'; \
72+
echo 'name=MySQL Tools Community'; \
73+
echo "baseurl=http://repo.mysql.com/yum/mysql-tools-community/el/${VERSION_ID%%[.-]*}/\$basearch/"; \
74+
echo 'enabled=1'; \
75+
echo 'gpgcheck=1'; \
76+
echo 'gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql'; \
77+
} | tee /etc/yum.repos.d/mysql-community-tools.repo
78+
RUN set -eux; \
79+
yum install -y "mysql-shell-$MYSQL_SHELL_VERSION"; \
80+
yum clean all; \
81+
\
82+
mysqlsh --version
83+
84+
VOLUME /var/lib/mysql
85+
COPY docker-entrypoint.sh /usr/local/bin/
86+
ENTRYPOINT ["docker-entrypoint.sh"]
87+
88+
EXPOSE 3306 33060
89+
CMD ["mysqld"]
File renamed without changes.

5.7/Dockerfile.oracle

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
FROM oraclelinux:7-slim
2+
3+
RUN set -eux; \
4+
groupadd --system --gid 999 mysql; \
5+
useradd --system --uid 999 --gid 999 --home-dir /var/lib/mysql --no-create-home mysql; \
6+
\
7+
mkdir /var/lib/mysql /var/run/mysqld; \
8+
chown mysql:mysql /var/lib/mysql /var/run/mysqld; \
9+
# ensure that /var/run/mysqld (used for socket and lock files) is writable regardless of the UID our mysqld instance ends up having at runtime
10+
chmod 777 /var/run/mysqld; \
11+
\
12+
mkdir /docker-entrypoint-initdb.d
13+
14+
# add gosu for easy step-down from root
15+
# https://github.com/tianon/gosu/releases
16+
ENV GOSU_VERSION 1.12
17+
RUN set -eux; \
18+
# TODO find a better userspace architecture detection method than querying the kernel
19+
arch="$(uname -m)"; \
20+
case "$arch" in \
21+
aarch64) gosuArch='arm64' ;; \
22+
x86_64) gosuArch='amd64' ;; \
23+
*) echo >&2 "error: unsupported architecture: '$arch'"; exit 1 ;; \
24+
esac; \
25+
curl -fL -o /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$gosuArch.asc"; \
26+
curl -fL -o /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$gosuArch"; \
27+
export GNUPGHOME="$(mktemp -d)"; \
28+
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \
29+
gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \
30+
rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc; \
31+
chmod +x /usr/local/bin/gosu; \
32+
gosu --version; \
33+
gosu nobody true
34+
35+
RUN set -eux; \
36+
# https://dev.mysql.com/doc/refman/8.0/en/checking-gpg-signature.html
37+
# gpg: key 8C718D3B5072E1F5: public key "MySQL Release Engineering <[email protected]>" imported
38+
key='A4A9406876FCBD3C456770C88C718D3B5072E1F5'; \
39+
export GNUPGHOME="$(mktemp -d)"; \
40+
gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \
41+
gpg --batch --export --armor "$key" > /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql; \
42+
rm -rf "$GNUPGHOME"
43+
44+
ENV MYSQL_MAJOR 5.7
45+
ENV MYSQL_VERSION 5.7.30-1.el7
46+
# bashbrew-architectures: amd64
47+
48+
RUN set -eu; \
49+
{ \
50+
echo "[mysql${MYSQL_MAJOR//./}-server-minimal]"; \
51+
echo "name=MySQL $MYSQL_MAJOR Server Minimal"; \
52+
echo 'enabled=1'; \
53+
echo "baseurl=http://repo.mysql.com/yum/mysql-$MYSQL_MAJOR-community/docker/\$basearch/"; \
54+
echo 'gpgcheck=1'; \
55+
echo 'gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql'; \
56+
} | tee /etc/yum.repos.d/mysql-community-minimal.repo
57+
58+
RUN set -eux; \
59+
yum install -y "mysql-community-server-minimal-$MYSQL_VERSION"; \
60+
yum clean all; \
61+
\
62+
mysqld --version; \
63+
mysql --version
64+
65+
ENV MYSQL_SHELL_VERSION 8.0.20-1.el7
66+
RUN set -eu; \
67+
. /etc/os-release; \
68+
{ \
69+
echo '[mysql-tools-community]'; \
70+
echo 'name=MySQL Tools Community'; \
71+
echo "baseurl=http://repo.mysql.com/yum/mysql-tools-community/el/${VERSION_ID%%[.-]*}/\$basearch/"; \
72+
echo 'enabled=1'; \
73+
echo 'gpgcheck=1'; \
74+
echo 'gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql'; \
75+
} | tee /etc/yum.repos.d/mysql-community-tools.repo
76+
RUN set -eux; \
77+
yum install -y "mysql-shell-$MYSQL_SHELL_VERSION"; \
78+
yum clean all; \
79+
\
80+
mysqlsh --version
81+
82+
VOLUME /var/lib/mysql
83+
COPY docker-entrypoint.sh /usr/local/bin/
84+
ENTRYPOINT ["docker-entrypoint.sh"]
85+
86+
EXPOSE 3306 33060
87+
CMD ["mysqld"]
File renamed without changes.

8.0/Dockerfile.oracle

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
FROM oraclelinux:7-slim
2+
3+
RUN set -eux; \
4+
groupadd --system --gid 999 mysql; \
5+
useradd --system --uid 999 --gid 999 --home-dir /var/lib/mysql --no-create-home mysql; \
6+
\
7+
mkdir /var/lib/mysql /var/run/mysqld; \
8+
chown mysql:mysql /var/lib/mysql /var/run/mysqld; \
9+
# ensure that /var/run/mysqld (used for socket and lock files) is writable regardless of the UID our mysqld instance ends up having at runtime
10+
chmod 777 /var/run/mysqld; \
11+
\
12+
mkdir /docker-entrypoint-initdb.d
13+
14+
# add gosu for easy step-down from root
15+
# https://github.com/tianon/gosu/releases
16+
ENV GOSU_VERSION 1.12
17+
RUN set -eux; \
18+
# TODO find a better userspace architecture detection method than querying the kernel
19+
arch="$(uname -m)"; \
20+
case "$arch" in \
21+
aarch64) gosuArch='arm64' ;; \
22+
x86_64) gosuArch='amd64' ;; \
23+
*) echo >&2 "error: unsupported architecture: '$arch'"; exit 1 ;; \
24+
esac; \
25+
curl -fL -o /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$gosuArch.asc"; \
26+
curl -fL -o /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$gosuArch"; \
27+
export GNUPGHOME="$(mktemp -d)"; \
28+
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4; \
29+
gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu; \
30+
rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc; \
31+
chmod +x /usr/local/bin/gosu; \
32+
gosu --version; \
33+
gosu nobody true
34+
35+
RUN set -eux; \
36+
# https://dev.mysql.com/doc/refman/8.0/en/checking-gpg-signature.html
37+
# gpg: key 8C718D3B5072E1F5: public key "MySQL Release Engineering <[email protected]>" imported
38+
key='A4A9406876FCBD3C456770C88C718D3B5072E1F5'; \
39+
export GNUPGHOME="$(mktemp -d)"; \
40+
gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys "$key"; \
41+
gpg --batch --export --armor "$key" > /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql; \
42+
rm -rf "$GNUPGHOME"
43+
44+
ENV MYSQL_MAJOR 8.0
45+
ENV MYSQL_VERSION 8.0.20-1.el7
46+
# bashbrew-architectures: amd64 arm64v8
47+
48+
RUN set -eu; \
49+
{ \
50+
echo "[mysql${MYSQL_MAJOR//./}-server-minimal]"; \
51+
echo "name=MySQL $MYSQL_MAJOR Server Minimal"; \
52+
echo 'enabled=1'; \
53+
echo "baseurl=http://repo.mysql.com/yum/mysql-$MYSQL_MAJOR-community/docker/\$basearch/"; \
54+
echo 'gpgcheck=1'; \
55+
echo 'gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql'; \
56+
} | tee /etc/yum.repos.d/mysql-community-minimal.repo
57+
58+
RUN set -eux; \
59+
yum install -y "mysql-community-server-minimal-$MYSQL_VERSION"; \
60+
yum clean all; \
61+
\
62+
mysqld --version; \
63+
mysql --version
64+
65+
ENV MYSQL_SHELL_VERSION 8.0.20-1.el7
66+
RUN set -eu; \
67+
. /etc/os-release; \
68+
{ \
69+
echo '[mysql-tools-community]'; \
70+
echo 'name=MySQL Tools Community'; \
71+
echo "baseurl=http://repo.mysql.com/yum/mysql-tools-community/el/${VERSION_ID%%[.-]*}/\$basearch/"; \
72+
echo 'enabled=1'; \
73+
echo 'gpgcheck=1'; \
74+
echo 'gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql'; \
75+
} | tee /etc/yum.repos.d/mysql-community-tools.repo
76+
RUN set -eux; \
77+
yum install -y "mysql-shell-$MYSQL_SHELL_VERSION"; \
78+
yum clean all; \
79+
\
80+
mysqlsh --version
81+
82+
VOLUME /var/lib/mysql
83+
COPY docker-entrypoint.sh /usr/local/bin/
84+
ENTRYPOINT ["docker-entrypoint.sh"]
85+
86+
EXPOSE 3306 33060
87+
CMD ["mysqld"]

generate-stackbrew-library.sh

Lines changed: 47 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ declare -A aliases=(
66
[8.0]='8 latest'
77
)
88

9+
defaultDefaultVariant='oracle'
10+
declare -A defaultVariants=(
11+
[5.6]='debian'
12+
[5.7]='debian'
13+
[8.0]='debian'
14+
)
15+
916
self="$(basename "$BASH_SOURCE")"
1017
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"
1118

@@ -23,17 +30,19 @@ fileCommit() {
2330
# get the most recent commit which modified "$1/Dockerfile" or any file COPY'd from "$1/Dockerfile"
2431
dirCommit() {
2532
local dir="$1"; shift
33+
local df="$1"; shift
2634
(
2735
cd "$dir"
28-
fileCommit \
29-
Dockerfile \
30-
$(git show HEAD:./Dockerfile | awk '
36+
local files; files="$(
37+
git show "HEAD:./$df" | awk '
3138
toupper($1) == "COPY" {
3239
for (i = 2; i < NF; i++) {
3340
print $i
3441
}
3542
}
36-
')
43+
'
44+
)"
45+
fileCommit "$df" $files
3746
)
3847
}
3948

@@ -53,24 +62,41 @@ join() {
5362
}
5463

5564
for version in "${versions[@]}"; do
56-
commit="$(dirCommit "$version")"
65+
defaultVariant="${defaultVariants[$version]:-$defaultDefaultVariant}"
66+
for variant in oracle debian; do
67+
df="Dockerfile.$variant"
68+
[ -f "$version/$df" ] || continue
5769

58-
fullVersion="$(git show "$commit":"$version/Dockerfile" | awk '$1 == "ENV" && $2 == "MYSQL_VERSION" { gsub(/-[0-9].*$/, "", $3); print $3; exit }')"
70+
commit="$(dirCommit "$version" "$df")"
5971

60-
versionAliases=()
61-
while [ "$fullVersion" != "$version" -a "${fullVersion%[.-]*}" != "$fullVersion" ]; do
62-
versionAliases+=( $fullVersion )
63-
fullVersion="${fullVersion%[.-]*}"
64-
done
65-
versionAliases+=(
66-
$version
67-
${aliases[$version]:-}
68-
)
72+
fullVersion="$(git show "$commit":"$version/$df" | awk '$1 == "ENV" && $2 == "MYSQL_VERSION" { gsub(/-[0-9].*$/, "", $3); print $3; exit }')"
6973

70-
echo
71-
cat <<-EOE
72-
Tags: $(join ', ' "${versionAliases[@]}")
73-
GitCommit: $commit
74-
Directory: $version
75-
EOE
74+
versionAliases=()
75+
while [ "$fullVersion" != "$version" -a "${fullVersion%[.-]*}" != "$fullVersion" ]; do
76+
versionAliases+=( $fullVersion )
77+
fullVersion="${fullVersion%[.-]*}"
78+
done
79+
versionAliases+=(
80+
$version
81+
${aliases[$version]:-}
82+
)
83+
84+
variantAliases=( "${versionAliases[@]/%/-$variant}" )
85+
variantAliases=( "${variantAliases[@]//latest-/}" )
86+
if [ "$variant" = "$defaultVariant" ]; then
87+
variantAliases=( "${versionAliases[@]}" "${variantAliases[@]}" )
88+
fi
89+
90+
# TODO if the list of architectures supported by MySQL ever is greater than that of the base image it's FROM, this list will need to be filtered
91+
variantArches="$(git show "$commit":"$version/$df" | grep -m1 'bashbrew-architectures:' | cut -d: -f2 || :)"
92+
93+
echo
94+
cat <<-EOE
95+
Tags: $(join ', ' "${variantAliases[@]}")
96+
GitCommit: $commit
97+
Directory: $version
98+
File: $df
99+
EOE
100+
[ -z "$variantArches" ] || echo "Architectures: $(join ', ' $variantArches)"
101+
done
76102
done

0 commit comments

Comments
 (0)