-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathpostgres_duckdb.docker
More file actions
63 lines (53 loc) · 2.31 KB
/
postgres_duckdb.docker
File metadata and controls
63 lines (53 loc) · 2.31 KB
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
ARG base_tag=17.6
ARG pg_version=17
# build stage
FROM docker.io/postgres:${base_tag} AS build
ARG pg_version
# there is a bug which prevents usage of the duckdb_fdw version 1.1.3
# https://github.com/alitrack/duckdb_fdw/issues/64
# it is possible to workaround it by renaming "libduckdb.so" to "libduckdb.1.1.3.so" during compilation
# and copying "libduckdb.so.1.1.3" as "libduckdb.so" to the final image
# or, just copy the "libduckdb.so.1.1.3" and create a symlink "libduckdb.so" -> "libduckdb.so.1.1.3"
# but since it's bug in the extension, let's just use the previous version which works fine
ARG fdw_version=1.1.2
ARG duckdb_version=1.1.3
# must be *.zip resource
ARG fdw_url=https://github.com/alitrack/duckdb_fdw/archive/refs/tags/v${fdw_version}.zip
ARG duckdb_lib_url=https://github.com/duckdb/duckdb/releases/download/v${duckdb_version}/libduckdb-linux-amd64.zip
ARG source_files=/tmp/duckdb_fdw
ARG source_root=duckdb_fdw-${fdw_version}
RUN apt-get update && \
# compilation deps
apt-get install -y --no-install-recommends wget unzip ca-certificates \
make gcc g++ \
postgresql-server-dev-${pg_version} && \
# duckdb_fdw
rm -rf ${source_files} && \
mkdir -p ${source_files} && \
wget -O sources.zip ${fdw_url} && \
unzip sources.zip -d ${source_files} && \
rm sources.zip && \
cd ${source_files}/${source_root} && \
# duckdb lib
# it must be extracted into the same directory as duckdb_fdw source files
# compilation process requires duckdb.h and duckdb.hpp files to be in the same directory
# as the duckdb_fdw source files
wget -O sources.zip ${duckdb_lib_url} && \
unzip -o sources.zip -d . && \
# runtime deps
cp ./libduckdb.so $(pg_config --libdir) && \
rm sources.zip && \
# install
make USE_PGXS=1 && \
make USE_PGXS=1 install;
# final stage
FROM docker.io/postgres:${base_tag}
LABEL maintainer="https://chumaky.team/"
LABEL description="Postgres database with duckdb_fdw foreign data wrapper extension installed."
ARG pg_version
ARG extdir=/usr/share/postgresql/${pg_version}/extension
ARG extlibdir=/usr/lib/postgresql/${pg_version}/lib
ARG libdir=/usr/lib/x86_64-linux-gnu
COPY --from=build ${extdir}/duckdb_fdw* ${extdir}/
COPY --from=build ${extlibdir}/duckdb_fdw.so ${extlibdir}/
COPY --from=build ${libdir}/libduckdb.so ${libdir}/