-
Notifications
You must be signed in to change notification settings - Fork 23
/
Dockerfile
52 lines (41 loc) · 1.75 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
# Use an official PostgreSQL image as the base image
ARG POSTGRES_VERSION=17
FROM postgres:${POSTGRES_VERSION} AS builder
# Set default values for build arguments
ARG POSTGRES_VERSION=17
ARG DUCKDB_VERSION=1.1.3
# Install build dependencies
RUN apt-get update && apt-get install -y \
git \
build-essential \
cmake \
postgresql-server-dev-${POSTGRES_VERSION} \
postgresql-client-${POSTGRES_VERSION} \
wget \
unzip
# add local checkout
ADD . duckdb_fdw
# build fdw
RUN cd duckdb_fdw \
&& export DUCK_ARCH=$(uname -m | sed -e s/arm64/aarch64/ | sed -e s/x86_64/amd64/) \
&& wget -c https://github.com/duckdb/duckdb/releases/download/v${DUCKDB_VERSION}/libduckdb-linux-${DUCK_ARCH}.zip \
&& unzip -o -d . libduckdb-linux-${DUCK_ARCH}.zip \
&& cp libduckdb.so $(pg_config --libdir) \
&& make USE_PGXS=1 \
&& make install USE_PGXS=1
# Set environment variables
ENV POSTGRES_HOST_AUTH_METHOD='trust'
# Switch to the postgres user
USER postgres
# Optionally, you might want to include additional configurations or initialization steps here
# Create the final image
FROM postgres:${POSTGRES_VERSION}
ARG POSTGRES_VERSION=17
# Copy duckdb_fdw artifacts from the builder stage
COPY --from=builder duckdb_fdw/duckdb_fdw.so /usr/lib/postgresql/${POSTGRES_VERSION}/lib/
COPY --from=builder duckdb_fdw/duckdb_fdw.control /usr/share/postgresql/${POSTGRES_VERSION}/extension/
COPY --from=builder duckdb_fdw/duckdb_fdw*.sql /usr/share/postgresql/${POSTGRES_VERSION}/extension/
# Horrible workaround for Docker's completely brain damaged multiplatform builds
RUN mkdir /usr/lib/platform
COPY --from=builder /usr/lib/*-linux-gnu/libduckdb.so /usr/lib/platform/
RUN ln -sf /usr/lib/platform/libduckdb.so /usr/lib/$(uname -m | sed -e s/arm64/aarch64/)-linux-gnu/libduckdb.so