Skip to content

Instantly share code, notes, and snippets.

@JerrySievert
Created January 19, 2024 05:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JerrySievert/dc0af0d4ca126987e2917ddc7873b1f4 to your computer and use it in GitHub Desktop.
Save JerrySievert/dc0af0d4ca126987e2917ddc7873b1f4 to your computer and use it in GitHub Desktop.
plv8/timescale
ARG PG_CONTAINER_VERSION=16
FROM docker.io/library/postgres:${PG_CONTAINER_VERSION}-bookworm as builder
ARG DEBIAN_FRONTEND=noninteractive
RUN set -ex \
&& apt-get update \
&& apt-get install -y build-essential git postgresql-server-dev-${PG_MAJOR} libtinfo5 pkg-config clang binutils libstdc++-12-dev cmake gnupg postgresql-common postgresql-server-dev-${PG_MAJOR} apt-transport-https lsb-release wget\
&& apt-get clean
RUN echo "deb https://packagecloud.io/timescale/timescaledb/debian/ $(lsb_release -c -s) main" | tee /etc/apt/sources.list.d/timescaledb.list
RUN wget --quiet -O - https://packagecloud.io/timescale/timescaledb/gpgkey | apt-key add -
RUN apt update \
&& apt install -y timescaledb-2-postgresql-16
ARG PLV8_BRANCH=r3.2
ENV PLV8_BRANCH=${PLV8_BRANCH}
ARG PLV8_VERSION=3.2.1
ENV PLV8_VERSION=${PLV8_VERSION}
RUN set -ex \
&& git clone --branch ${PLV8_BRANCH} --single-branch --depth 1 https://github.com/plv8/plv8 \
&& cd plv8 \
&& make install \
&& strip /usr/lib/postgresql/${PG_MAJOR}/lib/plv8-${PLV8_VERSION}.so
RUN find / | grep timescale
FROM docker.io/library/postgres:${PG_CONTAINER_VERSION}-bookworm
ARG PLV8_VERSION=3.2.1
ENV PLV8_VERSION=${PLV8_VERSION}
COPY --from=builder /usr/lib/postgresql/${PG_MAJOR}/lib/plv8* /usr/lib/postgresql/${PG_MAJOR}/lib/
COPY --from=builder /usr/lib/postgresql/${PG_MAJOR}/lib/bitcode/plv8-${PLV8_VERSION}/* /usr/lib/postgresql/${PG_MAJOR}/lib/bitcode/plv8-${PLV8_VERSION}/
COPY --from=builder /usr/share/postgresql/${PG_MAJOR}/extension/plv8* /usr/share/postgresql/${PG_MAJOR}/extension/
COPY --from=builder /usr/lib/postgresql/${PG_MAJOR}/lib/timescaledb* /usr/lib/postgresql/${PG_MAJOR}/lib/
COPY --from=builder /usr/share/postgresql/${PG_MAJOR}/extension/timescaledb* /usr/share/postgresql/${PG_MAJOR}/extension/
RUN echo "#!/usr/bin/env bash" > /docker-entrypoint-initdb.d/timescale.sh \
&& echo "echo \"shared_preload_libraries = 'timescaledb'\" >> /var/lib/postgresql/data/postgresql.conf" >>/docker-entrypoint-initdb.d/timescale.sh \
&& chmod 755 /docker-entrypoint-initdb.d/timescale.sh \
&& service postgresql restart
RUN mkdir -p /var/log/postgres \
&& touch /var/log/postgres/log /var/log/postgres/log.csv \
&& chown -R postgres /var/log/postgres
USER postgres
RUN ln -fs /dev/stderr /var/log/postgres/log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment