ARG PG_VERSION=18
FROM postgres:${PG_VERSION}

ARG PG_VERSION=18
ARG POSTGIS_VERSION=3
ARG VCHORD_VERSION=0.5.3

RUN set -eux; \
    apt-get update; \
    DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
        ca-certificates \
        wget \
        postgresql-${PG_VERSION}-cron \
        postgresql-${PG_VERSION}-pgvector \
        postgresql-${PG_VERSION}-postgis-${POSTGIS_VERSION}; \
    wget -O /tmp/vchord.deb "https://github.com/tensorchord/VectorChord/releases/download/${VCHORD_VERSION}/postgresql-${PG_VERSION}-vchord_${VCHORD_VERSION}-1_amd64.deb"; \
    DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends /tmp/vchord.deb; \
    rm -f /tmp/vchord.deb; \
    rm -rf /var/lib/apt/lists/*

CMD ["postgres", "-c", "shared_preload_libraries=pg_cron,vchord", "-c", "cron.database_name=firecrawl"]
