-
Notifications
You must be signed in to change notification settings - Fork 172
ROX-30858: Migrate scanner DB image from ubi8-minimal to ubi8-micro #17431
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
janisz
wants to merge
8
commits into
master
Choose a base branch
from
ubi-micro-scanner-db
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+79
−38
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
076f402
ROX-30858: Migrate scanner DB image from ubi8-minimal to ubi8-micro
janisz c6a4ab9
ROX-30858: Fix postgres user creation in ubi8-micro migration
janisz 6d8f2b7
Fix scanner-v4-db crash by adding essential shell utilities
janisz 4f807a9
Add openldap dependency for PostgreSQL runtime
janisz 1b443ca
Fix scanner-db PostgreSQL lock file directory in ubi8-micro
janisz 8eaee53
chore: Clean up scanner-db Dockerfile comments
janisz 1464fd2
Fix scanner-db ubi-micro migration to preserve rpmdb
janisz b5ecb82
Fix scanner-v4-db timezone data in ubi9-micro migration
janisz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,14 +3,90 @@ ARG RPMS_BASE_IMAGE=ubi9 | |
| ARG RPMS_BASE_TAG=latest | ||
|
|
||
| ARG BASE_REGISTRY=registry.access.redhat.com | ||
| ARG BASE_IMAGE=ubi9-minimal | ||
| ARG BASE_IMAGE=ubi9-micro | ||
| ARG BASE_TAG=latest | ||
|
|
||
| FROM ${RPMS_REGISTRY}/${RPMS_BASE_IMAGE}:${RPMS_BASE_TAG} AS postgres_rpms | ||
|
|
||
| COPY scripts/download.sh /download.sh | ||
| RUN /download.sh | ||
|
|
||
| FROM ${BASE_REGISTRY}/${BASE_IMAGE}:${BASE_TAG} AS ubi-micro-base | ||
|
|
||
| FROM ${RPMS_REGISTRY}/${RPMS_BASE_IMAGE}:${RPMS_BASE_TAG} AS dependency_builder | ||
|
|
||
| COPY --from=ubi-micro-base / /out/ | ||
|
|
||
| # If this is updated, be sure to update postgres_major in download.sh and the signature file. | ||
| ENV PG_MAJOR=15 | ||
|
|
||
| RUN dnf install \ | ||
| --installroot=/out/ \ | ||
| --releasever=9 \ | ||
| --setopt=install_weak_deps=0 \ | ||
| --nodocs \ | ||
| -y \ | ||
| findutils \ | ||
| util-linux \ | ||
| shadow-utils \ | ||
| ca-certificates \ | ||
| openldap \ | ||
| glibc-langpack-en \ | ||
| glibc-locale-source \ | ||
| libicu \ | ||
| libxslt \ | ||
| lz4 \ | ||
| perl-libs \ | ||
| python3 \ | ||
| systemd-sysv \ | ||
| zstd && \ | ||
| # Reinstall tzdata without --nodocs to populate /usr/share/zoneinfo directory. | ||
| # ubi9-micro ships with tzdata pre-installed but /usr/share/zoneinfo is empty. | ||
| # Regular install won't work since package is already present, must use reinstall. | ||
| # PostgreSQL requires timezone files at runtime. | ||
| dnf reinstall \ | ||
| --installroot=/out/ \ | ||
| --releasever=9 \ | ||
| --setopt=reposdir=/etc/yum.repos.d \ | ||
| -y \ | ||
| tzdata && \ | ||
| if [[ $(awk -F'=' '/VERSION_ID/{ gsub(/"/,""); print substr($2,1,1)}' /etc/os-release) -gt 8 ]]; then \ | ||
| dnf install --installroot=/out/ --releasever=8 --setopt=install_weak_deps=0 --nodocs -y uuid; \ | ||
|
Comment on lines
+53
to
+54
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This conditional still needed? given that |
||
| fi && \ | ||
| dnf --installroot=/out/ clean all && \ | ||
| rm -rf /out/var/cache/dnf /out/var/cache/yum | ||
|
|
||
| COPY --from=postgres_rpms /rpms/postgres.rpm /rpms/postgres-libs.rpm /rpms/postgres-server.rpm /rpms/postgres-contrib.rpm /tmp/ | ||
|
|
||
| COPY signatures/PGDG-RPM-GPG-KEY-RHEL /tmp/ | ||
| RUN rpm --root=/out/ --import /tmp/PGDG-RPM-GPG-KEY-RHEL && \ | ||
| rpm --root=/out/ -ivh --nodeps /tmp/postgres-libs.rpm /tmp/postgres-server.rpm /tmp/postgres.rpm /tmp/postgres-contrib.rpm && \ | ||
| rm -rf /tmp/*.rpm /tmp/PGDG-RPM-GPG-KEY-RHEL | ||
|
|
||
| RUN chroot /out /bin/sh -c " \ | ||
| if getent group postgres >/dev/null; then \ | ||
| current_gid=\$(getent group postgres | cut -d: -f3); \ | ||
| if [ \$current_gid -ne 70 ]; then \ | ||
| groupmod -g 70 postgres; \ | ||
| fi; \ | ||
| else \ | ||
| groupadd -g 70 postgres; \ | ||
| fi && \ | ||
| if id -u postgres &>/dev/null; then \ | ||
| current_uid=\$(id -u postgres); \ | ||
| if [ \$current_uid -ne 70 ]; then \ | ||
| usermod -u 70 -g 70 postgres; \ | ||
| fi; \ | ||
| else \ | ||
| useradd postgres -u 70 -g 70 -d /var/lib/postgresql -s /bin/sh; \ | ||
| fi && \ | ||
| localedef -f UTF-8 -i en_US en_US.UTF-8 \ | ||
| " | ||
|
|
||
| RUN mkdir -p /out/docker-entrypoint-initdb.d \ | ||
| /out/var/run/postgresql && \ | ||
| chroot /out /bin/sh -c "chown postgres:postgres /var/run/postgresql && chmod 03775 /var/run/postgresql" | ||
|
|
||
| FROM ${BASE_REGISTRY}/${BASE_IMAGE}:${BASE_TAG} | ||
|
|
||
| ARG LABEL_VERSION | ||
|
|
@@ -26,49 +102,14 @@ LABEL name="scanner-v4-db" \ | |
| release="${LABEL_RELEASE}" \ | ||
| quay.expires-after="${QUAY_TAG_EXPIRATION}" | ||
|
|
||
| # If this is updated, be sure to update postgres_major in download.sh and the signature file. | ||
| ENV PG_MAJOR=15 | ||
| ENV PATH="$PATH:/usr/pgsql-$PG_MAJOR/bin/" | ||
| ENV LANG=en_US.utf8 | ||
|
|
||
| # This will be ignored if empty in the init script. | ||
| COPY init-bundles/db-init.dump.zst /db-init.dump.zst | ||
| COPY --from=dependency_builder /out/ / | ||
janisz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| COPY signatures/PGDG-RPM-GPG-KEY-RHEL / | ||
| COPY init-bundles/db-init.dump.zst /db-init.dump.zst | ||
| COPY scripts/docker-entrypoint.sh scripts/init-entrypoint.sh /usr/local/bin/ | ||
| COPY --from=postgres_rpms /rpms/postgres.rpm /rpms/postgres-libs.rpm /rpms/postgres-server.rpm /rpms/postgres-contrib.rpm /tmp/ | ||
|
|
||
| RUN microdnf upgrade -y --nobest && \ | ||
| # groupadd is in shadow-utils package that is not installed by default. | ||
| microdnf install -y shadow-utils && \ | ||
| groupadd -g 70 postgres && \ | ||
| adduser postgres -u 70 -g 70 -d /var/lib/postgresql -s /bin/sh && \ | ||
| rpm --import PGDG-RPM-GPG-KEY-RHEL && \ | ||
| microdnf install -y \ | ||
| ca-certificates \ | ||
| glibc-langpack-en \ | ||
| glibc-locale-source \ | ||
| libicu \ | ||
| libxslt \ | ||
| lz4 \ | ||
| perl-libs \ | ||
| python3 \ | ||
| systemd-sysv \ | ||
| zstd \ | ||
| && \ | ||
| if [[ $(awk -F'=' '/VERSION_ID/{ gsub(/"/,""); print substr($2,1,1)}' /etc/os-release) -gt 8 ]]; then \ | ||
| microdnf install -y uuid; \ | ||
| fi && \ | ||
| rpm -i /tmp/postgres-libs.rpm /tmp/postgres-server.rpm /tmp/postgres.rpm /tmp/postgres-contrib.rpm && \ | ||
| # Restore /usr/share/zoneinfo that's empty in ubi-minimal because postgres reads timezone data from it. | ||
| # https://access.redhat.com/solutions/5616681 | ||
| microdnf reinstall -y tzdata && \ | ||
| microdnf clean all && \ | ||
| # (Optional) Remove line below to keep package management utilities | ||
| rpm -e --nodeps $(rpm -qa shadow-utils curl '*rpm*' '*dnf*' '*libsolv*' '*hawkey*' 'yum*') && \ | ||
| rm -rf /var/cache/dnf /var/cache/yum /tmp/postgres-libs.rpm /tmp/postgres-server.rpm /tmp/postgres.rpm /tmp/postgres-contrib.rpm && \ | ||
| localedef -f UTF-8 -i en_US en_US.UTF-8 && \ | ||
| mkdir /docker-entrypoint-initdb.d | ||
|
|
||
| STOPSIGNAL SIGINT | ||
|
|
||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one may be unnecessary? Is repeated in a later stage.