forked from duckdb/pg_duckdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
65 lines (52 loc) · 1.95 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
FROM postgres_base AS base
###
### BUILDER
###
FROM base AS builder
ARG POSTGRES_VERSION
RUN apt-get update -qq && \
apt-get install -y \
postgresql-server-dev-${POSTGRES_VERSION} \
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 liblz4-dev ccache ninja-build && \
rm -rf /var/lib/apt/lists/*
WORKDIR /build
ENV PATH=/usr/lib/ccache:$PATH
ENV CCACHE_DIR=/ccache
# permissions so we can run as `postgres` (uid=999,gid=999)
RUN mkdir /out
RUN chown -R postgres:postgres . /usr/lib/postgresql /usr/share/postgresql /out
USER postgres
# Selectively copy the files that we need. Sadly we need separate COPY commands
# for each directory, because docker puts only the contents of the source
# directory into the target directory, and not the directory itself too.
COPY --chown=postgres:postgres Makefile Makefile.global pg_duckdb.control .
COPY --chown=postgres:postgres sql sql
COPY --chown=postgres:postgres src src
COPY --chown=postgres:postgres include include
COPY --chown=postgres:postgres third_party third_party
COPY --chown=postgres:postgres test test
RUN make clean-all
# build
RUN --mount=type=cache,target=/ccache/,uid=999,gid=999 echo "Available CPUs=$(nproc)" && make -j$(nproc)
# install into location specified by pg_config for tests
RUN make install
# install into /out for packaging
RUN DESTDIR=/out make install
###
### CHECKER
###
FROM builder AS checker
USER postgres
RUN make installcheck
###
### OUTPUT
###
# this creates a usable postgres image but without the packages needed to build
FROM base AS output
# Automatically enable pg_duckdb
RUN echo "shared_preload_libraries='pg_duckdb'" >> /usr/share/postgresql/postgresql.conf.sample
RUN echo "CREATE EXTENSION IF NOT EXISTS pg_duckdb;" >> /docker-entrypoint-initdb.d/0001-install-pg_duckdb.sql
COPY --from=builder /out /
USER postgres