Skip to content

Commit 4949016

Browse files
committed
cleanup Dockerfile
1 parent 195e3fa commit 4949016

8 files changed

Lines changed: 46 additions & 87 deletions

File tree

8.0/Dockerfile.c9s

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,15 @@ LABEL summary="${SUMMARY}" \
3131
io.openshift.tags="database,${NAME},${NAME}${MYSQL_SHORT_VERSION},${NAME}-${MYSQL_SHORT_VERSION}" \
3232
com.redhat.component="${NAME}-${MYSQL_SHORT_VERSION}-container" \
3333
name="sclorg/${NAME}-${MYSQL_SHORT_VERSION}-c9s" \
34-
version="1" \
34+
version="${MYSQL_VERSION}" \
3535
com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#rhel" \
3636
usage="podman run -d -e MYSQL_USER=user -e MYSQL_PASSWORD=pass -e MYSQL_DATABASE=db -p 3306:3306 quay.io/sclorg/${NAME}-${MYSQL_SHORT_VERSION}-c9s:c9s" \
3737
maintainer="SoftwareCollections.org <sclorg@redhat.com>"
3838

3939
EXPOSE 3306
4040

41-
# This image must forever use UID 27 for mysql user so our volumes are
42-
# safe in the future. This should *never* change, the last test is there
43-
# to make sure of that.
41+
# This image must forever use UID 27 for mysql user so our volumes are safe in the future. This should *never* change.
42+
# Instead of relying on the DB server package, we will do the setup ourselves before any package is installed
4443
RUN INSTALL_PKGS="policycoreutils rsync tar gettext hostname groff-base ${NAME}-server" && \
4544
yum install -y --setopt=tsflags=nodocs ${INSTALL_PKGS} && \
4645
rpm -V ${INSTALL_PKGS} && \

8.0/Dockerfile.rhel8

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,36 @@ FROM ubi8/s2i-core
1010
# * $MYSQL_DATABASE - Name of the database to create
1111
# * $MYSQL_ROOT_PASSWORD (Optional) - Password for the 'root' MySQL account
1212

13+
# Standalone ENV call so these values can be re-used in the other ENV calls
1314
ENV MYSQL_VERSION=8.0 \
14-
APP_DATA=/opt/app-root/src \
15-
HOME=/var/lib/mysql
15+
MYSQL_SHORT_VERSION=80
1616

17-
ENV SUMMARY="MySQL 8.0 SQL database server" \
17+
ENV APP_DATA=/opt/app-root/src \
18+
HOME=/var/lib/mysql \
19+
NAME=mysql \
20+
SUMMARY="MySQL ${MYSQL_VERSION} SQL database server" \
1821
DESCRIPTION="MySQL is a multi-user, multi-threaded SQL database server. The container \
1922
image provides a containerized packaging of the MySQL mysqld daemon and client application. \
2023
The mysqld server daemon accepts connections from clients and provides access to content from \
2124
MySQL databases on behalf of the clients."
2225

23-
LABEL summary="$SUMMARY" \
24-
description="$DESCRIPTION" \
25-
io.k8s.description="$DESCRIPTION" \
26-
io.k8s.display-name="MySQL 8.0" \
26+
LABEL summary="${SUMMARY}" \
27+
description="${DESCRIPTION}" \
28+
io.k8s.description="${DESCRIPTION}" \
29+
io.k8s.display-name="MySQL ${MYSQL_VERSION}" \
2730
io.openshift.expose-services="3306:mysql" \
28-
io.openshift.tags="database,mysql,mysql80,mysql-80" \
29-
com.redhat.component="mysql-80-container" \
31+
io.openshift.tags="database,${NAME},${NAME}${MYSQL_SHORT_VERSION},${NAME}-${MYSQL_SHORT_VERSION}" \
32+
com.redhat.component="${NAME}-${MYSQL_SHORT_VERSION}-container" \
3033
name="rhel8/mysql-80" \
31-
version="1" \
34+
version="${MYSQL_VERSION}" \
3235
com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#rhel" \
3336
usage="podman run -d -e MYSQL_USER=user -e MYSQL_PASSWORD=pass -e MYSQL_DATABASE=db -p 3306:3306 rhel8/mysql-80" \
3437
maintainer="SoftwareCollections.org <sclorg@redhat.com>"
3538

3639
EXPOSE 3306
3740

38-
# This image must forever use UID 27 for mysql user so our volumes are
39-
# safe in the future. This should *never* change, the last test is there
40-
# to make sure of that.
41+
# This image must forever use UID 27 for mysql user so our volumes are safe in the future. This should *never* change.
42+
# Instead of relying on the DB server package, we will do the setup ourselves before any package is installed
4143
RUN yum -y module enable mysql:$MYSQL_VERSION && \
4244
INSTALL_PKGS="policycoreutils rsync tar gettext hostname groff-base mysql-server" && \
4345
yum install -y --setopt=tsflags=nodocs $INSTALL_PKGS && \
@@ -50,14 +52,14 @@ RUN yum -y module enable mysql:$MYSQL_VERSION && \
5052
ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/mysql \
5153
MYSQL_PREFIX=/usr
5254

53-
COPY 8.0/root-common /
54-
COPY 8.0/s2i-common/bin/ $STI_SCRIPTS_PATH
55-
COPY 8.0/root /
55+
COPY ${MYSQL_VERSION}/root-common /
56+
COPY ${MYSQL_VERSION}/s2i-common/bin/ ${STI_SCRIPTS_PATH}
57+
COPY ${MYSQL_VERSION}/root /
5658

5759
# Hard links are not supported in Testing Farm approach during sync to guest
5860
# operation system. Therefore tests are failing on error
5961
# /usr/libexec/s2i/run no such file or directory
60-
RUN ln -s /bin/run-mysqld $STI_SCRIPTS_PATH/run
62+
RUN ln -s /bin/run-mysqld ${STI_SCRIPTS_PATH}/run
6163

6264
# this is needed due to issues with squash
6365
# when this directory gets rm'd by the container-setup
@@ -66,7 +68,7 @@ RUN ln -s /bin/run-mysqld $STI_SCRIPTS_PATH/run
6668
RUN rm -rf /etc/my.cnf.d/* && \
6769
/usr/libexec/container-setup && \
6870
rpm-file-permissions && \
69-
/usr/libexec/mysqld -V | grep -qe "$MYSQL_VERSION\." && echo "Found VERSION $MYSQL_VERSION"
71+
/usr/libexec/mysqld -V | grep -qe "${MYSQL_VERSION}\." && echo "Found VERSION ${MYSQL_VERSION}"
7072

7173
USER 27
7274

8.0/Dockerfile.rhel9

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,15 @@ LABEL summary="${SUMMARY}" \
3131
io.openshift.tags="database,${NAME},${NAME}${MYSQL_SHORT_VERSION},${NAME}-${MYSQL_SHORT_VERSION}" \
3232
com.redhat.component="${NAME}-${MYSQL_SHORT_VERSION}-container" \
3333
name="rhel9/${NAME}-${MYSQL_SHORT_VERSION}" \
34-
version="1" \
34+
version="${MYSQL_VERSION}" \
3535
com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#rhel" \
3636
usage="podman run -d -e MYSQL_USER=user -e MYSQL_PASSWORD=pass -e MYSQL_DATABASE=db -p 3306:3306 rhel9/${NAME}-${MYSQL_SHORT_VERSION}" \
3737
maintainer="SoftwareCollections.org <sclorg@redhat.com>"
3838

3939
EXPOSE 3306
4040

41-
# This image must forever use UID 27 for mysql user so our volumes are
42-
# safe in the future. This should *never* change, the last test is there
43-
# to make sure of that.
41+
# This image must forever use UID 27 for mysql user so our volumes are safe in the future. This should *never* change.
42+
# Instead of relying on the DB server package, we will do the setup ourselves before any package is installed
4443
RUN INSTALL_PKGS="policycoreutils rsync tar gettext hostname bind9.18-utils groff-base ${NAME}-server" && \
4544
yum install -y --setopt=tsflags=nodocs ${INSTALL_PKGS} && \
4645
rpm -V ${INSTALL_PKGS} && \

8.4/Dockerfile.c10s

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,15 @@ LABEL summary="${SUMMARY}" \
3131
io.openshift.tags="database,${NAME},${NAME}${MYSQL_SHORT_VERSION},${NAME}-${MYSQL_SHORT_VERSION}" \
3232
com.redhat.component="${NAME}-${MYSQL_SHORT_VERSION}-container" \
3333
name="sclorg/${NAME}-${MYSQL_SHORT_VERSION}-c10s" \
34-
version="1" \
34+
version="${MYSQL_VERSION}" \
3535
com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#rhel" \
3636
usage="podman run -d -e MYSQL_USER=user -e MYSQL_PASSWORD=pass -e MYSQL_DATABASE=db -p 3306:3306 quay.io/sclorg/${NAME}-${MYSQL_SHORT_VERSION}-c10s:c10s" \
3737
maintainer="SoftwareCollections.org <sclorg@redhat.com>"
3838

3939
EXPOSE 3306
4040

41-
# This image must forever use UID 27 for mysql user so our volumes are
42-
# safe in the future. This should *never* change, the last test is there
43-
# to make sure of that.
41+
# This image must forever use UID 27 for mysql user so our volumes are safe in the future. This should *never* change.
42+
# Instead of relying on the DB server package, we will do the setup ourselves before any package is installed
4443
RUN INSTALL_PKGS="policycoreutils rsync tar gettext hostname groff-base procps-ng" && \
4544
dnf install -y --setopt=tsflags=nodocs ${INSTALL_PKGS} ${NAME}${MYSQL_VERSION}-server && \
4645
dnf -y clean all --enablerepo='*' && \

8.4/Dockerfile.c9s

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,15 @@ LABEL summary="${SUMMARY}" \
3131
io.openshift.tags="database,${NAME},${NAME}${MYSQL_SHORT_VERSION},${NAME}-${MYSQL_SHORT_VERSION}" \
3232
com.redhat.component="${NAME}-${MYSQL_SHORT_VERSION}-container" \
3333
name="sclorg/${NAME}-${MYSQL_SHORT_VERSION}-c9s" \
34-
version="1" \
34+
version="${MYSQL_VERSION}" \
3535
com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#rhel" \
3636
usage="podman run -d -e MYSQL_USER=user -e MYSQL_PASSWORD=pass -e MYSQL_DATABASE=db -p 3306:3306 quay.io/sclorg/${NAME}-${MYSQL_SHORT_VERSION}-c9s:c9s" \
3737
maintainer="SoftwareCollections.org <sclorg@redhat.com>"
3838

3939
EXPOSE 3306
4040

41-
# This image must forever use UID 27 for mysql user so our volumes are
42-
# safe in the future. This should *never* change, the last test is there
43-
# to make sure of that.
41+
# This image must forever use UID 27 for mysql user so our volumes are safe in the future. This should *never* change.
42+
# Instead of relying on the DB server package, we will do the setup ourselves before any package is installed
4443
RUN yum -y module enable ${NAME}:${MYSQL_VERSION} && \
4544
INSTALL_PKGS="policycoreutils rsync tar gettext hostname groff-base ${NAME}-server" && \
4645
dnf install -y --setopt=tsflags=nodocs ${INSTALL_PKGS} && \

8.4/Dockerfile.rhel10

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ LABEL summary="${SUMMARY}" \
3131
io.openshift.tags="database,${NAME},${NAME}${MYSQL_SHORT_VERSION},${NAME}-${MYSQL_SHORT_VERSION}" \
3232
com.redhat.component="${NAME}-${MYSQL_SHORT_VERSION}-container" \
3333
name="rhel10/${NAME}-${MYSQL_SHORT_VERSION}" \
34+
version="${MYSQL_VERSION}" \
3435
com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#rhel" \
3536
usage="podman run -d -e MYSQL_USER=user -e MYSQL_PASSWORD=pass -e MYSQL_DATABASE=db -p 3306:3306 rhel10/${NAME}-${MYSQL_SHORT_VERSION}" \
3637
maintainer="SoftwareCollections.org <sclorg@redhat.com>"
3738

3839
EXPOSE 3306
3940

40-
# This image must forever use UID 27 for mysql user so our volumes are
41-
# safe in the future. This should *never* change, the last test is there
42-
# to make sure of that.
41+
# This image must forever use UID 27 for mysql user so our volumes are safe in the future. This should *never* change.
42+
# Instead of relying on the DB server package, we will do the setup ourselves before any package is installed
4343
RUN INSTALL_PKGS="policycoreutils rsync tar gettext hostname groff-base procps-ng" && \
4444
dnf install -y --setopt=tsflags=nodocs ${INSTALL_PKGS} ${NAME}${MYSQL_VERSION}-server && \
4545
dnf -y clean all --enablerepo='*' && \

8.4/Dockerfile.rhel9

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,15 @@ LABEL summary="${SUMMARY}" \
3131
io.openshift.tags="database,${NAME},${NAME}${MYSQL_SHORT_VERSION},${NAME}-${MYSQL_SHORT_VERSION}" \
3232
com.redhat.component="${NAME}-${MYSQL_SHORT_VERSION}-container" \
3333
name="rhel9/${NAME}-${MYSQL_SHORT_VERSION}" \
34-
version="1" \
34+
version="${MYSQL_VERSION}" \
3535
com.redhat.license_terms="https://www.redhat.com/en/about/red-hat-end-user-license-agreements#rhel" \
3636
usage="podman run -d -e MYSQL_USER=user -e MYSQL_PASSWORD=pass -e MYSQL_DATABASE=db -p 3306:3306 rhel9/${NAME}-${MYSQL_SHORT_VERSION}" \
3737
maintainer="SoftwareCollections.org <sclorg@redhat.com>"
3838

3939
EXPOSE 3306
4040

41-
# This image must forever use UID 27 for mysql user so our volumes are
42-
# safe in the future. This should *never* change, the last test is there
43-
# to make sure of that.
41+
# This image must forever use UID 27 for mysql user so our volumes are safe in the future. This should *never* change.
42+
# Instead of relying on the DB server package, we will do the setup ourselves before any package is installed
4443
RUN yum -y module enable ${NAME}:${MYSQL_VERSION} && \
4544
INSTALL_PKGS="policycoreutils rsync tar gettext hostname bind9.18-utils groff-base ${NAME}-server" && \
4645
dnf install -y --setopt=tsflags=nodocs ${INSTALL_PKGS} && \

src/Dockerfile

Lines changed: 8 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,7 @@ FROM {{ spec.s2i_base }}
1010
# * $MYSQL_DATABASE - Name of the database to create
1111
# * $MYSQL_ROOT_PASSWORD (Optional) - Password for the 'root' MySQL account
1212

13-
{% if spec.prod == 'rhel8' and spec.version == '8.0' %}ENV MYSQL_VERSION={{ spec.version }} \
14-
APP_DATA=/opt/app-root/src \
15-
HOME=/var/lib/mysql
16-
17-
ENV SUMMARY="MySQL {{ spec.version }} SQL database server" \
18-
DESCRIPTION="MySQL is a multi-user, multi-threaded SQL database server. The container \
19-
image provides a containerized packaging of the MySQL mysqld daemon and client application. \
20-
The mysqld server daemon accepts connections from clients and provides access to content from \
21-
MySQL databases on behalf of the clients."
22-
23-
LABEL summary="$SUMMARY" \
24-
description="$DESCRIPTION" \
25-
io.k8s.description="$DESCRIPTION" \
26-
io.k8s.display-name="MySQL {{ spec.version }}" \
27-
io.openshift.expose-services="3306:mysql" \
28-
io.openshift.tags="database,mysql,mysql{{ spec.short }},mysql-{{ spec.short }}" \
29-
com.redhat.component="mysql-{{ spec.short }}-container" \
30-
name="{{ spec.img_name }}" \
31-
version="1" \
32-
{% if spec.license_terms %} com.redhat.license_terms="{{ spec.license_terms }}" \
33-
{% endif %} usage="podman run -d -e MYSQL_USER=user -e MYSQL_PASSWORD=pass -e MYSQL_DATABASE=db -p 3306:3306 {{ spec.img_name }}" \
34-
maintainer="SoftwareCollections.org <sclorg@redhat.com>"
35-
{% else %}# Standalone ENV call so these values can be re-used in the other ENV calls
13+
# Standalone ENV call so these values can be re-used in the other ENV calls
3614
ENV MYSQL_VERSION={{ spec.version }} \
3715
MYSQL_SHORT_VERSION={{ spec.short }}
3816

@@ -53,21 +31,16 @@ LABEL summary="${SUMMARY}" \
5331
io.openshift.tags="database,${NAME},${NAME}${MYSQL_SHORT_VERSION}{% if spec.prod == 'fedora' and spec.version == '8.0' %},rh-${NAME}${MYSQL_SHORT_VERSION}{% elif spec.prod != 'fedora' %},${NAME}-${MYSQL_SHORT_VERSION}{% endif %}" \
5432
com.redhat.component="{% if spec.prod == 'rhel8' or spec.prod == 'rhel9' or spec.prod == 'rhel10' or spec.prod == 'c9s' or spec.prod == 'c10s' %}${NAME}-${MYSQL_SHORT_VERSION}-container{% else %}${NAME}{% endif %}" \
5533
name="{{ spec.img_name }}" \
56-
{% if spec.prod == 'fedora' %} version="${MYSQL_VERSION}" \
57-
{% elif spec.prod != 'rhel10' %} version="1" \
58-
{% endif %}{% if spec.license_terms %} com.redhat.license_terms="{{ spec.license_terms }}" \
34+
version="${MYSQL_VERSION}" \
35+
{% if spec.license_terms %} com.redhat.license_terms="{{ spec.license_terms }}" \
5936
{% endif %} usage="{% if spec.prod == 'c9s' or spec.prod == 'c10s' %}podman run -d -e MYSQL_USER=user -e MYSQL_PASSWORD=pass -e MYSQL_DATABASE=db -p 3306:3306 quay.io/{{ spec.img_name }}:{{ spec.prod }}{% elif spec.prod == 'fedora' %}docker run -d -e MYSQL_USER=user -e MYSQL_PASSWORD=pass -e MYSQL_DATABASE=db -p 3306:3306 quay.io/{{ spec.img_name }}{% else %}podman run -d -e MYSQL_USER=user -e MYSQL_PASSWORD=pass -e MYSQL_DATABASE=db -p 3306:3306 {{ spec.img_name }}{% endif %}" \
6037
maintainer="SoftwareCollections.org <sclorg@redhat.com>"
61-
{% endif %}
6238

6339
EXPOSE 3306
6440

65-
{% if spec.prod == 'fedora' %}# This image must forever use UID 27 for mysql user so our volumes are safe in the future. This should *never* change.
41+
# This image must forever use UID 27 for mysql user so our volumes are safe in the future. This should *never* change.
6642
# Instead of relying on the DB server package, we will do the setup ourselves before any package is installed
67-
{% else %}# This image must forever use UID 27 for mysql user so our volumes are
68-
# safe in the future. This should *never* change, the last test is there
69-
# to make sure of that.
70-
{% endif %}{% if spec.prod == 'fedora' %}RUN /usr/sbin/groupadd -g 27 -o -r mysql && \
43+
{% if spec.prod == 'fedora' %}RUN /usr/sbin/groupadd -g 27 -o -r mysql && \
7144
/usr/sbin/useradd -M -N -g mysql -o -r -d ${HOME} -s /sbin/nologin -c "MySQL Server" -u 27 mysql && \
7245
test "$(id mysql)" = "uid=27(mysql) gid=27(mysql) groups=27(mysql)" && \
7346
INSTALL_PKGS="{{ spec.pkgs }}" && \
@@ -112,34 +85,23 @@ EXPOSE 3306
11285
ENV CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/mysql \
11386
MYSQL_PREFIX=/usr
11487

115-
{% if spec.prod == 'rhel8' and spec.version == '8.0' %}COPY {{ spec.version }}/root-common /
116-
COPY {{ spec.version }}/s2i-common/bin/ $STI_SCRIPTS_PATH
117-
COPY {{ spec.version }}/root /
118-
{% else %}COPY ${MYSQL_VERSION}/root-common /
88+
COPY ${MYSQL_VERSION}/root-common /
11989
COPY ${MYSQL_VERSION}/s2i-common/bin/ ${STI_SCRIPTS_PATH}
12090
COPY ${MYSQL_VERSION}/root /
121-
{% endif %}
12291

12392
# Hard links are not supported in Testing Farm approach during sync to guest
12493
# operation system. Therefore tests are failing on error
12594
# /usr/libexec/s2i/run no such file or directory
126-
{% if spec.prod == 'rhel8' and spec.version == '8.0' %}RUN ln -s /bin/run-mysqld $STI_SCRIPTS_PATH/run
127-
{% else %}RUN ln -s /bin/run-mysqld ${STI_SCRIPTS_PATH}/run
128-
{% endif %}
95+
RUN ln -s /bin/run-mysqld ${STI_SCRIPTS_PATH}/run
12996

13097
# this is needed due to issues with squash
13198
# when this directory gets rm'd by the container-setup
13299
# script.
133100
# Also reset permissions of filesystem to default values
134-
{% if spec.prod == 'rhel8' and spec.version == '8.0' %}RUN rm -rf /etc/my.cnf.d/* && \
135-
/usr/libexec/container-setup && \
136-
rpm-file-permissions && \
137-
/usr/libexec/mysqld -V | grep -qe "$MYSQL_VERSION\." && echo "Found VERSION $MYSQL_VERSION"
138-
{% else %}RUN rm -rf /etc/my.cnf.d/* && \
101+
RUN rm -rf /etc/my.cnf.d/* && \
139102
/usr/libexec/container-setup && \
140103
rpm-file-permissions && \
141104
/usr/libexec/mysqld -V | grep -qe "${MYSQL_VERSION}\." && echo "Found VERSION ${MYSQL_VERSION}"
142-
{% endif %}
143105

144106
USER 27
145107

0 commit comments

Comments
 (0)