ARG POSTGRES_VERSION=13
FROM postgres:${POSTGRES_VERSION} as gvm-postgres-base

RUN apt update && apt install -y --no-install-recommends \
    libglib2.0-dev \
    libical3-dev \
    libglib2.0-dev \
    libgpgme-dev \
    libgnutls28-dev \
    uuid-dev \
    libssh-gcrypt-dev \
    libhiredis-dev \
    libxml2-dev \
    libpcap-dev \
    libnet1-dev \
    libldap2-dev \
    libradcli-dev

FROM gvm-postgres-base

COPY --from=gvmd /install /
RUN echo "/usr/local/lib" > "/etc/ld.so.conf.d/gvm.conf" && ldconfig -f /etc/ld.so.conf.d/gvm.conf /usr/local/lib/libgvm-pg-server.so

RUN set -ex; \
    # Add jit = off according to this thread:
    # https://community.greenbone.net/t/everything-works-but-i-cant-see-any-report/5875/21
    # (The postgresql.conf.sample will be copied to
    # /var/lib/postgresql/data/postgresql.conf by the database initializer)
    printf "\n\n# Added for gvm-postgres\njit = off\n" >> /usr/share/postgresql/postgresql.conf.sample