From d9167efdd6c499e57f48456d52a440bcb02ffab8 Mon Sep 17 00:00:00 2001 From: Jonathan Dance Date: Thu, 20 Jun 2024 20:35:51 -0500 Subject: [PATCH] initial docker image --- .dockerignore | 4 ++++ Dockerfile | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..1cfe1407 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +*.o +*.so +.depend +Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..c5a87dc6 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,48 @@ +FROM postgres:16-bookworm as base + +### +### BUILDER +### +FROM base as builder + +RUN --mount=type=cache,target=/var/cache/apt \ + apt-get update -qq && \ + apt-get install -y build-essential libreadline-dev zlib1g-dev flex bison libxml2-dev libxslt-dev \ + libssl-dev libxml2-utils xsltproc pkg-config libc++-dev libc++abi-dev libglib2.0-dev libtinfo5 cmake \ + libstdc++-12-dev postgresql-server-dev-16 liblz4-dev ccache + +WORKDIR /build + +ENV PATH=/usr/lib/ccache:$PATH +ENV CCACHE_DIR=/ccache + +# A more selective copy might be nice, but the git submodules are not cooperative. +# Instead, use .dockerignore to not copy files here. +COPY . . + +RUN make clean + +# permissions so we can run as `postgres` (uid=999,gid=999) +RUN chown -R postgres:postgres . +RUN chown -R postgres:postgres /usr/lib/postgresql /usr/share/postgresql +RUN mkdir /out && chown postgres:postgres /out +RUN rm -f .depend + +USER postgres +RUN --mount=type=cache,target=/ccache/,uid=999,gid=999 make install +RUN --mount=type=cache,target=/ccache/,uid=999,gid=999 DESTDIR=/out make install + +### +### CHECKER +### +FROM builder as checker + +USER postgres +RUN --mount=type=cache,target=/ccache/,uid=999,gid=999 make installcheck + +### +### OUTPUT +### +# this creates a usable postgres image but without the packages needed to build +FROM base as output +COPY --from=builder /out /