diff --git a/Dockerfile.pg b/Dockerfile.pg new file mode 100644 index 0000000..225043d --- /dev/null +++ b/Dockerfile.pg @@ -0,0 +1,32 @@ +# Custom arm64 PostgreSQL 16 image with PostGIS 3 + TimescaleDB 2. +# Timescale's published timescaledb-postgis image is amd64-only, so we build +# our own on Debian 12 (arm64). The app only uses standard SQL types (UUID, +# JSON, TSVECTOR, float lat/lon), so pg16 is fully sufficient. +FROM debian:12 + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && apt-get install -y --no-install-recommends \ + ca-certificates curl gnupg lsb-release && \ + install -d /usr/share/postgresql-common/pgdg && \ + curl -fsSL -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc \ + https://www.postgresql.org/media/keys/ACCC4CF8.asc && \ + echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] \ + https://apt.postgresql.org/pub/repos/apt bookworm-pgdg main" \ + > /etc/apt/sources.list.d/pgdg.list && \ + curl -fsSL https://packagecloud.io/install/repositories/timescale/timescaledb/script.deb.sh | bash && \ + apt-get update && apt-get install -y --no-install-recommends \ + postgresql-16 postgresql-16-postgis-3 timescaledb-2-postgresql-16 && \ + # load TimescaleDB at startup + sed -ri "s/^#?shared_preload_libraries = .*/shared_preload_libraries = 'timescaledb'/" \ + /etc/postgresql/16/main/postgresql.conf && \ + rm -rf /var/lib/apt/lists/* + +# Match the official postgres image layout so volume mounts/behavior are familiar. +VOLUME ["/var/lib/postgresql/data"] +EXPOSE 5432 + +# Run as the postgres user (uid 999) like the official image. +USER postgres +ENV PGDATA=/var/lib/postgresql/data +ENTRYPOINT ["/usr/lib/postgresql/16/bin/postgres", "-D", "/etc/postgresql/16/main", "-c", "config_file=/etc/postgresql/16/main/postgresql.conf"] diff --git a/docker-compose.yml b/docker-compose.yml index dac36b4..ba89f54 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,7 +9,11 @@ services: db: - image: timescale/timescaledb-postgis:latest-pg13 + build: + context: . + dockerfile: Dockerfile.pg + platforms: ["linux/arm64"] + image: localhost/osint-dashboard-pg:latest container_name: osint-db restart: unless-stopped environment: @@ -28,6 +32,7 @@ services: nats: image: nats:2.10 + platform: linux/arm64 container_name: osint-nats restart: unless-stopped profiles: ["ingest"]