|
| 1 | +# |
| 2 | +# NOTE: RockyLinux-10 creates zomby processes! |
| 3 | +# |
| 4 | +ARG PG_VERSION=17 |
| 5 | +ARG PYTHON_VERSION=3 |
| 6 | + |
| 7 | +# --------------------------------------------- base1 |
| 8 | +FROM rockylinux/rockylinux:10 AS base1 |
| 9 | + |
| 10 | +# In RHEL 9/10, the repository for dev packages is called CRB (instead of powertools) |
| 11 | +RUN dnf install -y 'dnf-command(config-manager)' && \ |
| 12 | + dnf config-manager --set-enabled crb |
| 13 | + |
| 14 | +# Consolidating system utilities, including iproute (to prevent tests from failing) |
| 15 | +# Added the --allowerasing flag so dnf can seamlessly replace curl-minimal with full-fledged curl |
| 16 | +RUN dnf install -y --allowerasing \ |
| 17 | + sudo \ |
| 18 | + curl \ |
| 19 | + ca-certificates \ |
| 20 | + openssh-server \ |
| 21 | + openssh-clients \ |
| 22 | + sshpass \ |
| 23 | + time \ |
| 24 | + util-linux \ |
| 25 | + procps-ng \ |
| 26 | + git \ |
| 27 | + iproute \ |
| 28 | + bzip2 \ |
| 29 | + && dnf clean all |
| 30 | + |
| 31 | +# In RHEL 9/10, to generate host keys inside Docker, you need to call this binary |
| 32 | +RUN /usr/libexec/openssh/sshd-keygen rsa && \ |
| 33 | + /usr/libexec/openssh/sshd-keygen ed25519 |
| 34 | + |
| 35 | +RUN sed -i 's/#MaxStartups 10:30:100/MaxStartups 2000:30:2000/' /etc/ssh/sshd_config && \ |
| 36 | + sed -i 's/#MaxSessions 10/MaxSessions 500/' /etc/ssh/sshd_config && \ |
| 37 | + sed -i 's/#MaxAuthTries 6/MaxAuthTries 20/' /etc/ssh/sshd_config |
| 38 | + |
| 39 | +# --------------------------------------------- postgres dev tools |
| 40 | +FROM base1 AS base1_with_dev_tools |
| 41 | + |
| 42 | +RUN dnf install -y \ |
| 43 | + gcc \ |
| 44 | + make \ |
| 45 | + meson \ |
| 46 | + flex \ |
| 47 | + bison \ |
| 48 | + pkg-config \ |
| 49 | + openssl-devel \ |
| 50 | + libicu-devel \ |
| 51 | + libzstd-devel \ |
| 52 | + zlib-devel \ |
| 53 | + lz4-devel \ |
| 54 | + libxml2-devel \ |
| 55 | + perl-interpreter \ |
| 56 | + perl-FindBin \ |
| 57 | + perl-File-Compare \ |
| 58 | + && dnf clean all |
| 59 | + |
| 60 | +# --------------------------------------------- postgres build |
| 61 | +FROM base1_with_dev_tools AS base1_with_pg-17 |
| 62 | + |
| 63 | +RUN curl -fsSL https://ftp.postgresql.org/pub/source/v17.7/postgresql-17.7.tar.bz2 -o postgresql.tar.bz2 \ |
| 64 | + && mkdir -p /pg/postgres/source \ |
| 65 | + && tar -xjf postgresql.tar.bz2 -C /pg/postgres/source --strip-components=1 \ |
| 66 | + && rm postgresql.tar.bz2 |
| 67 | + |
| 68 | +WORKDIR /pg/postgres/source |
| 69 | + |
| 70 | +RUN ./configure --prefix=/pg/postgres/install --with-zlib --with-openssl --without-readline --with-lz4 --with-zstd --with-libxml |
| 71 | +RUN make -j 4 install |
| 72 | +RUN make -j 4 -C contrib install |
| 73 | + |
| 74 | +# SETUP PG_CONFIG |
| 75 | +RUN ln -s /pg/postgres/install/bin/pg_config -t /usr/local/bin |
| 76 | + |
| 77 | +# SETUP PG CLIENT LIBRARY |
| 78 | +# ИСПРАВЛЕНО: ссылаемся на базовое имя libpq.so.5, чтобы Dockerfile не ломался при обновлении минорных версий PG |
| 79 | +RUN ln -s /pg/postgres/install/lib/libpq.so.5 /usr/lib64/libpq.so.5 && \ |
| 80 | + echo "/pg/postgres/install/lib" > /etc/ld.so.conf.d/postgres.conf && ldconfig |
| 81 | + |
| 82 | +# --------------------------------------------- base2_with_python-3 |
| 83 | +FROM base1_with_pg-${PG_VERSION} AS base2_with_python-3 |
| 84 | + |
| 85 | +# Rocky 9/10 installs python3.9 or higher (depending on the repository) |
| 86 | +RUN dnf install -y \ |
| 87 | + python3 \ |
| 88 | + python3-devel \ |
| 89 | + && dnf clean all |
| 90 | + |
| 91 | +ENV PYTHON_BINARY=/usr/bin/python3 |
| 92 | + |
| 93 | +# --------------------------------------------- final |
| 94 | +FROM base2_with_python-${PYTHON_VERSION} AS final |
| 95 | + |
| 96 | +EXPOSE 22 |
| 97 | + |
| 98 | +RUN useradd -m test && usermod -aG wheel test |
| 99 | + |
| 100 | +# Enable sudo without a password |
| 101 | +RUN echo "test ALL=(ALL:ALL) NOPASSWD:ALL" >> /etc/sudoers |
| 102 | + |
| 103 | +# HACK FOR RHEL 9/10: Allow legacy key types and disable UsePAM. |
| 104 | +# Additionally, allow passwordless root/test authentication for testing. |
| 105 | +RUN echo "test:*" | chpasswd -e && \ |
| 106 | + sed -i 's/UsePAM yes/UsePAM no/' /etc/ssh/sshd_config && \ |
| 107 | + echo "PubkeyAcceptedKeyTypes +ssh-rsa" >> /etc/ssh/sshd_config && \ |
| 108 | + echo "PermitEmptyPasswords yes" >> /etc/ssh/sshd_config |
| 109 | + |
| 110 | +COPY --chown=test:test . /home/test/testgres |
| 111 | +WORKDIR /home/test/testgres |
| 112 | + |
| 113 | +ENV LANG=C.UTF-8 |
| 114 | + |
| 115 | +RUN chmod 700 /home/test/ && \ |
| 116 | + mkdir -p /home/test/.ssh && \ |
| 117 | + echo 'Host *' > /home/test/.ssh/config && \ |
| 118 | + echo ' ControlMaster auto' >> /home/test/.ssh/config && \ |
| 119 | + echo ' ControlPath /home/test/.ssh/master-%r@%h:%p' >> /home/test/.ssh/config && \ |
| 120 | + echo ' ControlPersist 30m' >> /home/test/.ssh/config && \ |
| 121 | + echo ' StrictHostKeyChecking no' >> /home/test/.ssh/config && \ |
| 122 | + echo ' UserKnownHostsFile /dev/null' >> /home/test/.ssh/config && \ |
| 123 | + echo ' GSSAPIAuthentication no' >> /home/test/.ssh/config && \ |
| 124 | + chown -R test:test /home/test/.ssh && \ |
| 125 | + chmod 700 /home/test/.ssh && \ |
| 126 | + chmod 600 /home/test/.ssh/config |
| 127 | + |
| 128 | +# Our ENTRYPOINT with a stub |
| 129 | +ENTRYPOINT ["sh", "-c", " \ |
| 130 | + set -eux; \ |
| 131 | + echo 'SYSTEM START: PREPARING SSH'; \ |
| 132 | + /usr/sbin/sshd; \ |
| 133 | + ls -la /home/test/.ssh/; \ |
| 134 | + \"$@\" \ |
| 135 | +", "DUMMY-DUMMY-DUMMY"] |
| 136 | + |
| 137 | +# In CMD, we change the key generation from the deprecated -t rsa to the modern -t ed25519! |
| 138 | +# This ensures that Rocky 9/10 will accept this key without any cryptographic policy issues. |
| 139 | +CMD ["bash", "-c", " \ |
| 140 | +set -eux; \ |
| 141 | +echo \"HOME DIR IS [`realpath ~/`]\"; \ |
| 142 | +echo \"WORK DIR IS [$(pwd)]\"; \ |
| 143 | +if [ ! -f /home/test/.ssh/id_ed25519 ]; then \ |
| 144 | + su test -c \"ssh-keygen -t ed25519 -f /home/test/.ssh/id_ed25519 -q -N ''\"; \ |
| 145 | + su test -c \"cat /home/test/.ssh/id_ed25519.pub >> /home/test/.ssh/authorized_keys\"; \ |
| 146 | + chmod 600 /home/test/.ssh/authorized_keys; \ |
| 147 | +fi; \ |
| 148 | +ls -la /home/test/.ssh/; \ |
| 149 | +if [ -n \"${TEST_CFG__REMOTE_SSH_KEY:-}\" ]; then \ |
| 150 | + cp \"${TEST_CFG__REMOTE_SSH_KEY}\" \"${TEST_CFG__REMOTE_SSH_KEY}_ci\"; \ |
| 151 | + export TEST_CFG__REMOTE_SSH_KEY=\"${TEST_CFG__REMOTE_SSH_KEY}_ci\"; \ |
| 152 | + chown test:test \"${TEST_CFG__REMOTE_SSH_KEY}\"; \ |
| 153 | + chmod 600 \"${TEST_CFG__REMOTE_SSH_KEY}\"; \ |
| 154 | + ls -la /home/test/.ssh/; \ |
| 155 | +fi; \ |
| 156 | +ls -la ./; \ |
| 157 | +su test -c \"TEST_FILTER='' bash ./run_tests.sh\"; \ |
| 158 | +"] |
0 commit comments