Skip to content

better dockerfile #148

@GeoffreyStemys

Description

@GeoffreyStemys

I put it here as a general info for other users (or clevyr team if they still update), this strictly follow instructions from the official package registry: https://packagecloud.io/timescale/timescaledb (which the not the case of the dockerfile of this repo)

ARG CNPG="x"
# get official cnpg image from https://github.com/cloudnative-pg/postgres-containers/pkgs/container/postgresql/versions?filters%5Bversion_type%5D=tagged
# also explore it with 'cat /etc/os-release' to get the debian id
FROM ghcr.io/cloudnative-pg/postgresql:${CNPG}

USER root
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
SHELL ["/bin/bash", "-l", "-c"]

ARG CNPG="x"
ARG TS="x"
ARG DEB="x"

# Install Timescale from https://packagecloud.io/timescale/timescaledb and search for "timescaledb-2-postgresql-"
RUN apt update && apt install -y --no-install-recommends curl
RUN curl -s https://packagecloud.io/install/repositories/timescale/timescaledb/script.deb.sh | bash

RUN PG="${CNPG:0:2}" && PKG="$PG=$TS~debian$DEB" && \
    apt install -y --no-install-recommends \
        timescaledb-tools timescaledb-toolkit-postgresql-$PG \
        timescaledb-2-loader-postgresql-$PKG \
        timescaledb-2-postgresql-$PKG

RUN apt purge -y curl
RUN rm -rf /var/cache/apt/* /etc/apt/sources.list.d/timescaledb.list /etc/apt/trusted.gpg.d/timescale.gpg

USER 26

Then you can build really specific versions like:

docker build \
    --build-arg CNPG=16.0 \
    --build-arg TS=2.23.1 \
    --build-arg DEB=11-1610 \
    -t mycompany/cnpg-ts:16.0.0 .

or

docker build \
    --build-arg CNPG=17.7 \
    --build-arg TS=2.23.1 \
    --build-arg DEB=11-1706 \
    -t mycompany/cnpg-ts:17.0.0 .

or

docker build \
    --build-arg CNPG=18.1-system-trixie \
    --build-arg TS=2.24.0 \
    --build-arg DEB=13-1801 \
    -t mycompany/cnpg-ts:18.0.0 .

Then the generated image will work seamlessly with the official cnpg operator (1.28 for now).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions