1
1
ARG BASE_REGISTRY=registry.access.redhat.com
2
- ARG BASE_IMAGE=ubi8/ubi
2
+ ARG BASE_IMAGE=ubi8-minimal
3
3
ARG BASE_TAG=8.6
4
4
5
5
FROM ${BASE_REGISTRY}/${BASE_IMAGE}:${BASE_TAG} AS extracted_bundle
6
6
COPY bundle.tar.gz /
7
7
8
8
WORKDIR /bundle
9
- RUN tar -xzf /bundle.tar.gz
9
+ RUN microdnf -y install tar gzip && tar -zxf /bundle.tar.gz
10
10
11
11
FROM ${BASE_REGISTRY}/${BASE_IMAGE}:${BASE_TAG} AS base
12
12
@@ -25,18 +25,30 @@ COPY --from=extracted_bundle /bundle/etc/postgresql.conf /bundle/etc/pg_hba.conf
25
25
26
26
ARG POSTGRESQL_ARCH=x86_64
27
27
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 && \
29
37
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 \
32
39
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 && \
36
48
rpm -e --nodeps $(rpm -qa 'pgdg-redhat-repo*' ) && \
37
49
# (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 && \
40
52
localedef -f UTF-8 -i en_US en_US.UTF-8 && \
41
53
chown postgres:postgres /usr/local/bin/docker-entrypoint.sh && \
42
54
chmod +x /usr/local/bin/docker-entrypoint.sh && \
0 commit comments