-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathpostgres_jdbc.docker
51 lines (38 loc) · 1.45 KB
/
postgres_jdbc.docker
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
ARG base_tag=16.6
ARG pg_version=16
ARG JAVA_LIBS=/usr/lib/jvm/java-17-openjdk-amd64/lib/server
# build stage
FROM docker.io/postgres:${base_tag} AS build
ARG pg_version
ARG JAVA_LIBS
ARG JDBC_FDW_VERSION=0.4.0
ARG JDBC_FDW_URL=https://github.com/pgspider/jdbc_fdw/archive/refs/tags/v${JDBC_FDW_VERSION}.tar.gz
ARG SOURCE_FILES=/tmp/jdbc_fdw
RUN apt-get update && \
# compilation deps
apt-get install -y --no-install-recommends wget ca-certificates \
default-jdk \
make gcc \
postgresql-server-dev-${pg_version} && \
# download JDBC_FDW source files
mkdir -p ${SOURCE_FILES} && \
wget -O - ${JDBC_FDW_URL} | tar -zx -C ${SOURCE_FILES} --strip-components=1 && \
cd ${SOURCE_FILES} && \
# compilation
ln -s ${JAVA_LIBS}/libjvm.so /usr/lib64/libjvm.so && \
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 jdbc_fdw foreign data wrapper extension installed."
ARG pg_version
ARG JAVA_LIBS
ARG extdir=/usr/share/postgresql/${pg_version}/extension
ARG extlibdir=/usr/lib/postgresql/${pg_version}/lib
COPY --from=build ${extdir}/jdbc_fdw* ${extdir}/
COPY --from=build ${extlibdir}/jdbc_fdw.so ${extlibdir}/*.class ${extlibdir}/
RUN apt-get update && \
apt-get install -y --no-install-recommends openjdk-17-jre-headless && \
rm -rf /var/lib/apt/lists/*;
ENV LD_LIBRARY_PATH=${JAVA_LIBS}