Skip to content

Commit

Permalink
Merge pull request #26 from cybertec-postgresql/reduceContainerSize
Browse files Browse the repository at this point in the history
fix missing files for pg
  • Loading branch information
Schmaetz authored May 31, 2024
2 parents 6a1b34f + 2a02ca7 commit 99bc7e8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ base-build:
base: base-build;

pgbackrest-build:
docker build $(ROOTPATH) --no-cache \
docker build $(ROOTPATH) \
--file $(ROOTPATH)/docker/pgbackrest/Dockerfile \
--tag cybertec-pg-container/pgbackrest:$(IMAGE_TAG)-$(BUILD) \
--build-arg BASE_IMAGE=$(BASE_IMAGE) \
Expand Down
38 changes: 28 additions & 10 deletions docker/pgbackrest/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ RUN rm -rf /var/spool/pgbackrest
# Add kubectl
RUN curl -LO https://dl.k8s.io/release/v1.30.0/bin/linux/amd64/kubectl && chmod +x kubectl

RUN mkdir -p /tmp/pgsql && cp -r /usr/pgsql* /tmp/pgsql
RUN mkdir -p /tmp/pg && cp -r /usr/bin/pg* /tmp/pg
RUN mkdir -p /tmp/lz4 && cp -r /usr/bin/lz4* /tmp/lz4
RUN mkdir -p /tmp/zstd && cp -r /usr/bin/zstd* /tmp/zstd


FROM ${CONTAINERIMAGE} as micro

ARG PGVERSION
Expand All @@ -57,27 +63,37 @@ COPY --from=builder /usr/share/licenses/pgbackrest/LICENSE /usr/share/licenses/p
COPY --from=builder /var/lib/pgbackrest /var/lib/pgbackrest
COPY --from=builder /var/log/pgbackrest /var/log/pgbackrest
# Postgres
COPY --from=builder /tmp/pgsql/ /usr/
COPY --from=builder /var/lib/pgsql /var/lib/pgsql
COPY --from=builder /tmp/pg /usr/bin/

COPY --from=builder ./kubectl /usr/local/bin/
# lz4
COPY --from=builder /usr/bin/lz4* /usr/bin/lz4*
COPY --from=builder /tmp/lz4 /usr/bin/
# zstd
COPY --from=builder /usr/bin/zstd* /usr/bin/zstd*
COPY --from=builder /tmp/zstd /usr/bin/
# Others
COPY --from=builder /usr/bin/sed /usr/bin/sed
COPY --from=builder /usr/bin/jq /usr/bin/jq
COPY --from=builder /usr/bin/watch /usr/bin/watch
COPY --from=builder /usr/share/locale /usr/share/locale
COPY --from=builder /usr/lib /usr/lib
COPY --from=builder /usr/lib64 /usr/lib64
# PostgreSQL
# TODO: implement a method that works with $PG_SUPPORTED_VERSIONS
COPY --from=builder /usr/pgsql-13 /usr/pgsql-13
COPY --from=builder /usr/pgsql-14 /usr/pgsql-14
COPY --from=builder /usr/pgsql-15 /usr/pgsql-15
COPY --from=builder /usr/pgsql-16 /usr/pgsql-16
COPY --from=builder /var/lib/pgsql /var/lib/pgsql
COPY --from=builder /usr/bin/pg_* /usr/bin/
# CA
COPY --from=builder /usr/bin/ca-legacy /usr/bin/ca-legacy
COPY --from=builder /usr/bin/update-ca-trust /usr/bin/update-ca-trust
# p11-kit
COPY --from=builder /etc/pkcs11 /etc/pkcs11
COPY --from=builder /usr/libexec/p11-kit /usr/libexec/p11-kit
COPY --from=builder /usr/share/bash-completion/completions /usr/share/bash-completion/completions
COPY --from=builder /usr/share/p11-kit /usr/share/p11-kit
COPY --from=builder /usr/share/polkit-1 /usr/share/polkit-1

COPY --from=builder /usr/bin/p11-kit /usr/bin/p11-kit
COPY --from=builder /etc/pki /etc/pki
COPY --from=builder /usr/share/pki /usr/share/pki
COPY --from=builder /etc/ssl /etc/ssl
COPY --from=builder /etc/pkcs11 /etc/pkcs11

# libraries
COPY --from=builder /usr/bin/nss_wrapper.pl /usr/bin/nss_wrapper.pl
Expand All @@ -100,6 +116,8 @@ ADD /scripts/nss_wrapper /scripts/nss_wrapper
FROM scratch
COPY --from=micro / /

ARG PGVERSION

# set user and group ownership
RUN chown -R postgres:postgres /opt/pgbackrest \
/backrestrepo /home/postgres/pgdata/pgbackrest /home/postgres/pgdata
Expand Down

0 comments on commit 99bc7e8

Please sign in to comment.