|
| 1 | +ARG CONTAINERSUITE |
| 2 | +ARG BUILD |
| 3 | +ARG BASEOS |
| 4 | +ARG CONTAINERIMAGE |
| 5 | + |
| 6 | +FROM ${CONTAINERSUITE}/base:${BASEOS}-${BUILD} AS builder |
| 7 | + |
| 8 | +# Dockerfile specific informations |
| 9 | +ARG PACKAGER |
| 10 | +ARG PGBACKREST_VERSION |
| 11 | +ARG PGVERSION |
| 12 | +ARG OLD_PG_VERSIONS |
| 13 | +ARG PG_SUPPORTED_VERSIONS="$OLD_PG_VERSIONS $PGVERSION" |
| 14 | + |
| 15 | +# Enable Beta-Repo |
| 16 | +RUN ${PACKAGER} config-manager --set-enabled pgdg${PGVERSION}-updates-testing \ |
| 17 | + && ${PACKAGER} config-manager --set-enabled pgdg${PGVERSION}-source-updates-testing \ |
| 18 | + && ${PACKAGER} -y update; |
| 19 | + |
| 20 | +RUN ${PACKAGER} -y install --nodocs \ |
| 21 | + --setopt=skip_missing_names_on_install=False \ |
| 22 | + openssh-clients \ |
| 23 | + openssh-server \ |
| 24 | + bzip2 \ |
| 25 | + lz4 \ |
| 26 | + zstd \ |
| 27 | + libicu \ |
| 28 | + dumb-init \ |
| 29 | + jq \ |
| 30 | + pgbackrest-${PGBACKREST_VERSION} \ |
| 31 | + && ${PACKAGER} -y clean all ; |
| 32 | + |
| 33 | +# Install postgres-server |
| 34 | +RUN ${PACKAGER} -y update \ |
| 35 | + && for version in $PG_SUPPORTED_VERSIONS; do \ |
| 36 | + ${PACKAGER} -y install --nodocs postgresql${version}-server; \ |
| 37 | + done \ |
| 38 | + && ${PACKAGER} -y clean all; |
| 39 | + |
| 40 | +# Remove default pgbackrest-config |
| 41 | +RUN rm /etc/pgbackrest.conf |
| 42 | +RUN rm -rf /var/spool/pgbackrest |
| 43 | + |
| 44 | +# Add kubectl |
| 45 | +RUN curl -LO https://dl.k8s.io/release/v1.30.0/bin/linux/amd64/kubectl && chmod +x kubectl |
| 46 | + |
| 47 | +RUN mkdir -p /tmp/pgsql && cp -r /usr/pgsql* /tmp/pgsql |
| 48 | +RUN mkdir -p /tmp/pg && cp -r /usr/bin/pg* /tmp/pg |
| 49 | +RUN mkdir -p /tmp/lz4 && cp -r /usr/bin/lz4* /tmp/lz4 |
| 50 | +RUN mkdir -p /tmp/zstd && cp -r /usr/bin/zstd* /tmp/zstd |
| 51 | + |
| 52 | + |
| 53 | +FROM ${CONTAINERIMAGE} as micro |
| 54 | + |
| 55 | +ARG PGVERSION |
| 56 | + |
| 57 | +COPY --from=builder /usr/bin/dumb-init /usr/bin/dumb-init |
| 58 | +COPY --from=builder /etc/passwd /etc/passwd |
| 59 | +COPY --from=builder /etc/group /etc/group |
| 60 | +COPY --from=builder /usr/lib64 /usr/lib64 |
| 61 | +# SSH-client |
| 62 | +COPY --from=builder /etc/ssh /etc/ssh |
| 63 | +COPY --from=builder /usr/bin/ssh /usr/bin/ssh |
| 64 | +COPY --from=builder /usr/libexec/openssh /usr/libexec/openssh |
| 65 | +# pgBackRest |
| 66 | +COPY --from=builder /usr/bin/pgbackrest /usr/bin/pgbackrest |
| 67 | +COPY --from=builder /usr/share/licenses/pgbackrest/LICENSE /usr/share/licenses/pgbackrest/LICENSE |
| 68 | +COPY --from=builder /var/lib/pgbackrest /var/lib/pgbackrest |
| 69 | +COPY --from=builder /var/log/pgbackrest /var/log/pgbackrest |
| 70 | +# Postgres |
| 71 | +COPY --from=builder /tmp/pgsql/ /usr/ |
| 72 | +COPY --from=builder /var/lib/pgsql /var/lib/pgsql |
| 73 | +COPY --from=builder /tmp/pg /usr/bin/ |
| 74 | + |
| 75 | +COPY --from=builder ./kubectl /usr/local/bin/ |
| 76 | +# lz4 |
| 77 | +COPY --from=builder /tmp/lz4 /usr/bin/ |
| 78 | +# zstd |
| 79 | +COPY --from=builder /tmp/zstd /usr/bin/ |
| 80 | +# Others |
| 81 | +COPY --from=builder /usr/bin/sed /usr/bin/sed |
| 82 | +COPY --from=builder /usr/bin/jq /usr/bin/jq |
| 83 | +COPY --from=builder /usr/bin/watch /usr/bin/watch |
| 84 | +COPY --from=builder /usr/share/locale /usr/share/locale |
| 85 | +COPY --from=builder /usr/lib /usr/lib |
| 86 | +COPY --from=builder /usr/lib64 /usr/lib64 |
| 87 | +# CA |
| 88 | +COPY --from=builder /usr/bin/ca-legacy /usr/bin/ca-legacy |
| 89 | +COPY --from=builder /usr/bin/update-ca-trust /usr/bin/update-ca-trust |
| 90 | +# grep |
| 91 | +COPY --from=builder /etc/profile.d /etc/profile.d |
| 92 | +COPY --from=builder /usr/bin/grep /usr/bin/grep |
| 93 | +COPY --from=builder /usr/libexec /usr/libexec |
| 94 | +# COPY --from=builder /usr/bin/update-ca-trust /usr/bin/update-ca-trust |
| 95 | +# COPY --from=builder /usr/bin/update-ca-trust /usr/bin/update-ca-trust |
| 96 | + |
| 97 | +# p11-kit |
| 98 | +COPY --from=builder /etc/pkcs11 /etc/pkcs11 |
| 99 | +COPY --from=builder /usr/libexec/p11-kit /usr/libexec/p11-kit |
| 100 | +COPY --from=builder /usr/share/bash-completion/completions /usr/share/bash-completion/completions |
| 101 | +COPY --from=builder /usr/share/p11-kit /usr/share/p11-kit |
| 102 | +COPY --from=builder /usr/share/polkit-1 /usr/share/polkit-1 |
| 103 | + |
| 104 | +COPY --from=builder /usr/bin/p11-kit /usr/bin/p11-kit |
| 105 | +COPY --from=builder /etc/pki /etc/pki |
| 106 | +COPY --from=builder /usr/share/pki /usr/share/pki |
| 107 | +COPY --from=builder /etc/ssl /etc/ssl |
| 108 | +COPY --from=builder /etc/pkcs11 /etc/pkcs11 |
| 109 | + |
| 110 | +# p11-kit-trust |
| 111 | +COPY --from=builder /usr/bin/trust /usr/bin/ |
| 112 | + |
| 113 | +# libraries |
| 114 | +COPY --from=builder /usr/bin/nss_wrapper.pl /usr/bin/nss_wrapper.pl |
| 115 | +# COPY --from=builder /usr/lib64/libnss_wrapper.so /usr/lib64/libnss_wrapper.so |
| 116 | +COPY --from=builder /usr/share/man/man1 /usr/share/man/man1 |
| 117 | +COPY --from=builder /usr/bin/envsubst /usr/bin/envsubst |
| 118 | + |
| 119 | +RUN /usr/bin/update-ca-trust extract |
| 120 | + |
| 121 | +# add postgres user and group |
| 122 | +#RUN groupadd postgres -g 26 && useradd postgres -u 26 -g 26 |
| 123 | + |
| 124 | +# Prepare all needed stuff |
| 125 | +Run mkdir -p /opt/pgbackrest /backrestrepo /home/postgres /home/postgres/pgdata/pgbackrest/log |
| 126 | + |
| 127 | +# add pgbackrest-restore files |
| 128 | +ADD scripts/pgbackrest/ /opt/pgbackrest/bin/ |
| 129 | + |
| 130 | +# add pgbackrest-common files |
| 131 | +ADD /scripts/nss_wrapper /scripts/nss_wrapper |
| 132 | + |
| 133 | +FROM scratch |
| 134 | +COPY --from=micro / / |
| 135 | + |
| 136 | +ARG PGVERSION |
| 137 | + |
| 138 | +# set user and group ownership |
| 139 | +RUN chown -R postgres:postgres /opt/pgbackrest \ |
| 140 | + /backrestrepo /home/postgres/pgdata/pgbackrest /home/postgres/pgdata |
| 141 | + |
| 142 | +RUN mkdir -p /etc/pgbackrest \ |
| 143 | + && chown -R postgres:postgres /etc/pgbackrest |
| 144 | + |
| 145 | +RUN chmod -R g=u /etc/pgbackrest \ |
| 146 | + && rm -f /run/nologin |
| 147 | + |
| 148 | +RUN mkdir /.ssh && chown postgres:postgres /.ssh && chmod o+rwx /.ssh |
| 149 | + |
| 150 | +# set user and group ownership |
| 151 | +RUN chown -R postgres:postgres /opt/pgbackrest \ |
| 152 | + /backrestrepo /home/postgres/pgdata |
| 153 | + |
| 154 | +#ENV PATH=$PATH:/usr/pgsql-$PGVERSION/bin |
| 155 | +COPY launcher/pgbackrest/launch.sh / |
| 156 | + |
| 157 | +VOLUME ["sshd", "/home/postgres/pgdata", "/backrestrepo"] |
| 158 | + |
| 159 | +ENTRYPOINT ["/scripts/nss_wrapper/nss_wrapper.sh"] |
| 160 | + |
| 161 | +USER 26 |
| 162 | + |
| 163 | +CMD ["dumb-init", "/launch.sh", "init"] |
0 commit comments