Skip to content

Commit 05ab071

Browse files
janiszclaude
andcommitted
fix: Use sclorg postgres base image for scanner-db to fix timezone data
Problem: Scanner-DB pods were failing to start with error: FATAL: configuration file "/etc/postgresql.conf" contains errors LOG: invalid value for parameter "log_timezone": "UTC" LOG: could not open directory "/usr/share/zoneinfo": No such file or directory Root Cause: The ubi9-micro base image with manually installed PostgreSQL was missing /usr/share/zoneinfo directory that PostgreSQL requires. Solution: Switch Dockerfile and Dockerfile.slim to use quay.io/sclorg/postgresql-15-c9s base image, matching the pattern from stackrox/stackrox commit c92e85134. The sclorg image includes all required timezone data and dependencies. Note: konflux.Dockerfile continues to use registry.redhat.io/rhel9/postgresql-15 which has its own timezone data handling. This simplifies the regular Dockerfiles by: - Eliminating multi-stage ubi9-micro builds - Removing RPM downloads and GPG key handling (download.sh, PGDG-RPM-GPG-KEY-RHEL) - Using existing postgres user (modified to UID/GID 70) - Adding chown for sclorg-specific directories (/var/lib/pgsql, /opt/app-root) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 7b1dd2b commit 05ab071

4 files changed

Lines changed: 39 additions & 251 deletions

File tree

image/db/rhel/Dockerfile

Lines changed: 19 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,19 @@
1-
ARG RPMS_REGISTRY=registry.access.redhat.com
2-
ARG RPMS_BASE_IMAGE=ubi9
3-
ARG RPMS_BASE_TAG=latest
1+
ARG PG_VERSION=15
2+
FROM quay.io/sclorg/postgresql-${PG_VERSION}-c9s:latest
43

54
ARG BASE_REGISTRY=registry.access.redhat.com
65
ARG BASE_IMAGE=ubi9-minimal
76
ARG BASE_TAG=latest
87

9-
FROM ${BASE_REGISTRY}/ubi9-micro:${BASE_TAG} AS ubi-micro-base
10-
118
FROM ${BASE_REGISTRY}/${BASE_IMAGE}:${BASE_TAG} AS extracted_bundle
129
COPY bundle.tar.gz /
1310

1411
WORKDIR /bundle
1512
RUN microdnf install -y tar gzip && tar -zxf /bundle.tar.gz
1613

17-
FROM ${RPMS_REGISTRY}/${RPMS_BASE_IMAGE}:${RPMS_BASE_TAG} AS postgres_rpms
18-
19-
COPY scripts/download.sh /download.sh
20-
RUN /download.sh
21-
22-
FROM ${RPMS_REGISTRY}/${RPMS_BASE_IMAGE}:${RPMS_BASE_TAG} AS dependency_builder
23-
24-
ENV PG_MAJOR=15
25-
26-
COPY --from=ubi-micro-base / /out/
27-
28-
RUN dnf install -y \
29-
--installroot=/out/ \
30-
--releasever=9 \
31-
--setopt=install_weak_deps=0 \
32-
--nodocs \
33-
findutils \
34-
shadow-utils \
35-
ca-certificates \
36-
openldap \
37-
glibc-langpack-en \
38-
glibc-locale-source \
39-
libicu \
40-
libxslt \
41-
lz4 \
42-
perl-libs \
43-
python3 \
44-
systemd-sysv \
45-
zstd \
46-
uuid \
47-
gzip \
48-
less \
49-
tar && \
50-
dnf clean all --installroot=/out/ && \
51-
rm -rf /out/var/cache/dnf /out/var/cache/yum
52-
53-
COPY --from=postgres_rpms /rpms/postgres.rpm /rpms/postgres-libs.rpm /rpms/postgres-server.rpm /rpms/postgres-contrib.rpm /tmp/
54-
COPY signatures/PGDG-RPM-GPG-KEY-RHEL /tmp/
14+
FROM quay.io/sclorg/postgresql-${PG_VERSION}-c9s:latest
5515

56-
RUN rpm --root=/out/ --import /tmp/PGDG-RPM-GPG-KEY-RHEL && \
57-
rpm --root=/out/ -ivh --nodeps /tmp/postgres-libs.rpm /tmp/postgres-server.rpm /tmp/postgres.rpm /tmp/postgres-contrib.rpm && \
58-
rm -rf /tmp/*.rpm /tmp/PGDG-RPM-GPG-KEY-RHEL
59-
60-
RUN chroot /out /bin/sh -c " \
61-
if getent group postgres >/dev/null; then \
62-
current_gid=\$(getent group postgres | cut -d: -f3); \
63-
if [ \$current_gid -ne 70 ]; then \
64-
groupmod -g 70 postgres; \
65-
fi; \
66-
else \
67-
groupadd -g 70 postgres; \
68-
fi && \
69-
if id -u postgres &>/dev/null; then \
70-
current_uid=\$(id -u postgres); \
71-
if [ \$current_uid -ne 70 ]; then \
72-
usermod -u 70 -g 70 postgres; \
73-
fi; \
74-
else \
75-
useradd postgres -u 70 -g 70 -d /var/lib/postgresql -s /bin/sh; \
76-
fi \
77-
"
78-
79-
RUN chroot /out /bin/sh -c "localedef -f UTF-8 -i en_US en_US.UTF-8"
80-
81-
RUN mkdir -p /out/docker-entrypoint-initdb.d \
82-
/out/var/run/postgresql \
83-
/out/var/lib/postgresql && \
84-
chroot /out /bin/sh -c "chown 70:70 /var/run/postgresql && chmod 03775 /var/run/postgresql && chown 70:70 /var/lib/postgresql && chmod 0700 /var/lib/postgresql"
85-
86-
FROM ubi-micro-base AS base
16+
USER root
8717

8818
ARG LABEL_VERSION
8919
ARG LABEL_RELEASE
@@ -98,15 +28,25 @@ LABEL name="scanner-db" \
9828
release="${LABEL_RELEASE}" \
9929
quay.expires-after="${QUAY_TAG_EXPIRATION}"
10030

101-
ENV PG_MAJOR=15
102-
ENV PATH="$PATH:/usr/pgsql-$PG_MAJOR/bin/" \
103-
PGDATA="/var/lib/postgresql/data/pgdata"
104-
105-
COPY --from=dependency_builder /out/ /
31+
ENV LANG="en_US.utf8"
10632

10733
COPY scripts/docker-entrypoint.sh /usr/local/bin/
10834
COPY --from=extracted_bundle /bundle/etc/postgresql.conf /bundle/etc/pg_hba.conf /etc/
10935

36+
RUN dnf upgrade -y --nobest && \
37+
localedef -f UTF-8 -i en_US en_US.UTF-8 && \
38+
mkdir -p /var/lib/postgresql && \
39+
groupmod -g 70 postgres && \
40+
usermod -u 70 postgres -d /var/lib/postgresql && \
41+
chown -R postgres:postgres /var/lib/postgresql && \
42+
chown -R postgres:postgres /var/run/postgresql && \
43+
chown -R postgres /var/lib/pgsql && \
44+
chown -R postgres /opt/app-root && \
45+
dnf clean all && \
46+
rpm --verbose -e --nodeps $(rpm -qa curl '*rpm*' '*dnf*' '*libsolv*' '*hawkey*' 'yum*') && \
47+
rm -rf /var/cache/dnf /var/cache/yum && \
48+
mkdir /docker-entrypoint-initdb.d
49+
11050
# This is equivalent to postgres:postgres.
11151
USER 70:70
11252

image/db/rhel/Dockerfile.slim

Lines changed: 20 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,7 @@
1-
ARG RPMS_REGISTRY=registry.access.redhat.com
2-
ARG RPMS_BASE_IMAGE=ubi9
3-
ARG RPMS_BASE_TAG=latest
1+
ARG PG_VERSION=15
2+
FROM quay.io/sclorg/postgresql-${PG_VERSION}-c9s:latest
43

5-
ARG BASE_REGISTRY=registry.access.redhat.com
6-
ARG BASE_IMAGE=ubi9-minimal
7-
ARG BASE_TAG=latest
8-
9-
FROM ${BASE_REGISTRY}/ubi9-micro:${BASE_TAG} AS ubi-micro-base
10-
11-
FROM ${BASE_REGISTRY}/${BASE_IMAGE}:${BASE_TAG} AS extracted_bundle
12-
COPY bundle.tar.gz /
13-
14-
WORKDIR /bundle
15-
RUN microdnf install -y tar gzip && tar -zxf /bundle.tar.gz
16-
17-
FROM ${RPMS_REGISTRY}/${RPMS_BASE_IMAGE}:${RPMS_BASE_TAG} AS postgres_rpms
18-
19-
COPY scripts/download.sh /download.sh
20-
RUN /download.sh
21-
22-
FROM ${RPMS_REGISTRY}/${RPMS_BASE_IMAGE}:${RPMS_BASE_TAG} AS dependency_builder
23-
24-
ENV PG_MAJOR=15
25-
26-
COPY --from=ubi-micro-base / /out/
27-
28-
RUN dnf install -y \
29-
--installroot=/out/ \
30-
--releasever=9 \
31-
--setopt=install_weak_deps=0 \
32-
--nodocs \
33-
findutils \
34-
shadow-utils \
35-
ca-certificates \
36-
openldap \
37-
glibc-langpack-en \
38-
glibc-locale-source \
39-
libicu \
40-
libxslt \
41-
lz4 \
42-
perl-libs \
43-
python3 \
44-
systemd-sysv \
45-
zstd \
46-
uuid \
47-
gzip \
48-
less \
49-
tar && \
50-
dnf clean all --installroot=/out/ && \
51-
rm -rf /out/var/cache/dnf /out/var/cache/yum
52-
53-
COPY --from=postgres_rpms /rpms/postgres.rpm /rpms/postgres-libs.rpm /rpms/postgres-server.rpm /rpms/postgres-contrib.rpm /tmp/
54-
COPY signatures/PGDG-RPM-GPG-KEY-RHEL /tmp/
55-
56-
RUN rpm --root=/out/ --import /tmp/PGDG-RPM-GPG-KEY-RHEL && \
57-
rpm --root=/out/ -ivh --nodeps /tmp/postgres-libs.rpm /tmp/postgres-server.rpm /tmp/postgres.rpm /tmp/postgres-contrib.rpm && \
58-
rm -rf /tmp/*.rpm /tmp/PGDG-RPM-GPG-KEY-RHEL
59-
60-
RUN chroot /out /bin/sh -c " \
61-
if getent group postgres >/dev/null; then \
62-
current_gid=\$(getent group postgres | cut -d: -f3); \
63-
if [ \$current_gid -ne 70 ]; then \
64-
groupmod -g 70 postgres; \
65-
fi; \
66-
else \
67-
groupadd -g 70 postgres; \
68-
fi && \
69-
if id -u postgres &>/dev/null; then \
70-
current_uid=\$(id -u postgres); \
71-
if [ \$current_uid -ne 70 ]; then \
72-
usermod -u 70 -g 70 postgres; \
73-
fi; \
74-
else \
75-
useradd postgres -u 70 -g 70 -d /var/lib/postgresql -s /bin/sh; \
76-
fi \
77-
"
78-
79-
RUN chroot /out /bin/sh -c "localedef -f UTF-8 -i en_US en_US.UTF-8"
80-
81-
RUN mkdir -p /out/docker-entrypoint-initdb.d \
82-
/out/var/run/postgresql \
83-
/out/var/lib/postgresql && \
84-
chroot /out /bin/sh -c "chown 70:70 /var/run/postgresql && chmod 03775 /var/run/postgresql && chown 70:70 /var/lib/postgresql && chmod 0700 /var/lib/postgresql"
85-
86-
FROM ubi-micro-base AS base
4+
USER root
875

886
ARG LABEL_VERSION
897
ARG LABEL_RELEASE
@@ -98,20 +16,29 @@ LABEL name="scanner-db-slim" \
9816
release="${LABEL_RELEASE}" \
9917
quay.expires-after="${QUAY_TAG_EXPIRATION}"
10018

101-
ENV PG_MAJOR=15
102-
ENV PATH="$PATH:/usr/pgsql-$PG_MAJOR/bin/" \
103-
PGDATA="/var/lib/postgresql/data/pgdata"
104-
105-
COPY --from=dependency_builder /out/ /
19+
ENV LANG="en_US.utf8"
20+
ENV ROX_SLIM_MODE="true"
10621

10722
COPY scripts/docker-entrypoint.sh /usr/local/bin/
108-
COPY --from=extracted_bundle /bundle/etc/postgresql.conf /bundle/etc/pg_hba.conf /etc/
23+
COPY etc/postgresql.conf etc/pg_hba.conf /etc/
24+
25+
RUN dnf upgrade -y --nobest && \
26+
localedef -f UTF-8 -i en_US en_US.UTF-8 && \
27+
mkdir -p /var/lib/postgresql && \
28+
groupmod -g 70 postgres && \
29+
usermod -u 70 postgres -d /var/lib/postgresql && \
30+
chown -R postgres:postgres /var/lib/postgresql && \
31+
chown -R postgres:postgres /var/run/postgresql && \
32+
chown -R postgres /var/lib/pgsql && \
33+
chown -R postgres /opt/app-root && \
34+
dnf clean all && \
35+
rpm --verbose -e --nodeps $(rpm -qa curl '*rpm*' '*dnf*' '*libsolv*' '*hawkey*' 'yum*') && \
36+
rm -rf /var/cache/dnf /var/cache/yum && \
37+
mkdir /docker-entrypoint-initdb.d
10938

11039
# This is equivalent to postgres:postgres.
11140
USER 70:70
11241

113-
ENV ROX_SLIM_MODE="true"
114-
11542
ENTRYPOINT ["docker-entrypoint.sh"]
11643

11744
EXPOSE 5432

image/db/rhel/scripts/download.sh

Lines changed: 0 additions & 38 deletions
This file was deleted.

image/db/rhel/signatures/PGDG-RPM-GPG-KEY-RHEL

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)