Skip to content

Commit 1cf4201

Browse files
janiszvladbologa
andauthored
ROX-10613: Use ubi-minimal for scanner-db (#956)
Co-authored-by: Vlad Bologa <vbologa@redhat.com>
1 parent 3a07578 commit 1cf4201

File tree

2 files changed

+44
-20
lines changed

2 files changed

+44
-20
lines changed

image/db/rhel/Dockerfile

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
ARG BASE_REGISTRY=registry.access.redhat.com
2-
ARG BASE_IMAGE=ubi8/ubi
2+
ARG BASE_IMAGE=ubi8-minimal
33
ARG BASE_TAG=8.6
44

55
FROM ${BASE_REGISTRY}/${BASE_IMAGE}:${BASE_TAG} AS extracted_bundle
66
COPY bundle.tar.gz /
77

88
WORKDIR /bundle
9-
RUN tar -xzf /bundle.tar.gz
9+
RUN microdnf -y install tar gzip && tar -zxf /bundle.tar.gz
1010

1111
FROM ${BASE_REGISTRY}/${BASE_IMAGE}:${BASE_TAG} AS base
1212

@@ -25,18 +25,30 @@ COPY --from=extracted_bundle /bundle/etc/postgresql.conf /bundle/etc/pg_hba.conf
2525

2626
ARG POSTGRESQL_ARCH=x86_64
2727

28-
RUN groupadd -g 70 postgres && \
28+
RUN curl -sSLf https://download.postgresql.org/pub/repos/yum/RPM-GPG-KEY-PGDG-${PG_MAJOR} -o /tmp/pg_repo.key && \
29+
rpm --import /tmp/pg_repo.key && \
30+
curl -sSLf https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-${POSTGRESQL_ARCH}/pgdg-redhat-repo-latest.noarch.rpm -o /tmp/pg_repo.rpm && \
31+
rpm -i /tmp/pg_repo.rpm && \
32+
# Skip repo check for ARM as it's used only for development purposes and package has wrong signature.
33+
if [[ "$POSTGRESQL_ARCH" == "aarch64" ]]; then sed -i 's/repo_gpgcheck = 1/repo_gpgcheck = 0/g' /etc/yum.repos.d/pgdg-redhat-all.repo; fi && \
34+
microdnf upgrade -y && \
35+
microdnf install -y shadow-utils && \
36+
groupadd -g 70 postgres && \
2937
adduser postgres -u 70 -g 70 -d /var/lib/postgresql -s /bin/sh && \
30-
dnf upgrade -y && \
31-
dnf install -y \
38+
microdnf install -y \
3239
ca-certificates libicu systemd-sysv glibc-locale-source glibc-langpack-en \
33-
https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-${POSTGRESQL_ARCH}/pgdg-redhat-repo-latest.noarch.rpm && \
34-
dnf install -y postgresql12-server && \
35-
dnf clean all && \
40+
postgresql12-server && \
41+
# The removal of /usr/share/zoneinfo from UBI minimal images is intentional.
42+
# After building the image, the image is reduced in size as much as possible,
43+
# and the /usr/share/zoneinfo directory is purged as it saves space
44+
# in the final distribution of the image.
45+
# https://access.redhat.com/solutions/5616681
46+
microdnf reinstall tzdata && \
47+
microdnf clean all && \
3648
rpm -e --nodeps $(rpm -qa 'pgdg-redhat-repo*') && \
3749
# (Optional) Remove line below to keep package management utilities
38-
rpm -e --nodeps $(rpm -qa curl '*rpm*' '*dnf*' '*libsolv*' '*hawkey*' 'yum*') && \
39-
rm -rf /var/cache/dnf /var/cache/yum && \
50+
rpm -e --nodeps $(rpm -qa shadow-utils curl '*rpm*' '*dnf*' '*libsolv*' '*hawkey*' 'yum*') && \
51+
rm -rf /var/cache/dnf /var/cache/yum /tmp/pg_repo.rpm /tmp/pg_repo.key && \
4052
localedef -f UTF-8 -i en_US en_US.UTF-8 && \
4153
chown postgres:postgres /usr/local/bin/docker-entrypoint.sh && \
4254
chmod +x /usr/local/bin/docker-entrypoint.sh && \

image/db/rhel/Dockerfile.slim

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
ARG BASE_REGISTRY=registry.access.redhat.com
2-
ARG BASE_IMAGE=ubi8/ubi
2+
ARG BASE_IMAGE=ubi8-minimal
33
ARG BASE_TAG=8.6
44

55
FROM ${BASE_REGISTRY}/${BASE_IMAGE}:${BASE_TAG} AS extracted_bundle
66
COPY bundle.tar.gz /
77

88
WORKDIR /bundle
9-
RUN tar -xzf /bundle.tar.gz
9+
RUN microdnf -y install tar gzip && tar -zxf /bundle.tar.gz
1010

1111
FROM ${BASE_REGISTRY}/${BASE_IMAGE}:${BASE_TAG} AS base
1212

@@ -25,18 +25,30 @@ COPY --from=extracted_bundle /bundle/etc/postgresql.conf /bundle/etc/pg_hba.conf
2525

2626
ARG POSTGRESQL_ARCH=x86_64
2727

28-
RUN groupadd -g 70 postgres && \
28+
RUN curl -sSLf https://download.postgresql.org/pub/repos/yum/RPM-GPG-KEY-PGDG-${PG_MAJOR} -o /tmp/pg_repo.key && \
29+
rpm --import /tmp/pg_repo.key && \
30+
curl -sSLf https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-${POSTGRESQL_ARCH}/pgdg-redhat-repo-latest.noarch.rpm -o /tmp/pg_repo.rpm && \
31+
rpm -i /tmp/pg_repo.rpm && \
32+
# Skip repo check for ARM as it's used only for development purposes and package has wrong signature.
33+
if [[ "$POSTGRESQL_ARCH" == "aarch64" ]]; then sed -i 's/repo_gpgcheck = 1/repo_gpgcheck = 0/g' /etc/yum.repos.d/pgdg-redhat-all.repo; fi && \
34+
microdnf upgrade -y && \
35+
microdnf install -y shadow-utils && \
36+
groupadd -g 70 postgres && \
2937
adduser postgres -u 70 -g 70 -d /var/lib/postgresql -s /bin/sh && \
30-
dnf upgrade -y && \
31-
dnf install -y \
38+
microdnf install -y \
3239
ca-certificates libicu systemd-sysv glibc-locale-source glibc-langpack-en \
33-
https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-${POSTGRESQL_ARCH}/pgdg-redhat-repo-latest.noarch.rpm && \
34-
dnf install -y postgresql12-server && \
35-
dnf clean all && \
40+
postgresql12-server && \
41+
# The removal of /usr/share/zoneinfo from UBI minimal images is intentional.
42+
# After building the image, the image is reduced in size as much as possible,
43+
# and the /usr/share/zoneinfo directory is purged as it saves space
44+
# in the final distribution of the image.
45+
# https://access.redhat.com/solutions/5616681
46+
microdnf reinstall tzdata && \
47+
microdnf clean all && \
3648
rpm -e --nodeps $(rpm -qa 'pgdg-redhat-repo*') && \
3749
# (Optional) Remove line below to keep package management utilities
38-
rpm -e --nodeps $(rpm -qa curl '*rpm*' '*dnf*' '*libsolv*' '*hawkey*' 'yum*') && \
39-
rm -rf /var/cache/dnf /var/cache/yum && \
50+
rpm -e --nodeps $(rpm -qa shadow-utils curl '*rpm*' '*dnf*' '*libsolv*' '*hawkey*' 'yum*') && \
51+
rm -rf /var/cache/dnf /var/cache/yum /tmp/pg_repo.rpm /tmp/pg_repo.key && \
4052
localedef -f UTF-8 -i en_US en_US.UTF-8 && \
4153
chown postgres:postgres /usr/local/bin/docker-entrypoint.sh && \
4254
chmod +x /usr/local/bin/docker-entrypoint.sh && \

0 commit comments

Comments
 (0)