Batch weighted least-squares differential correction using equinoctial elements, LAPACK dgelss_() for SVD solve, vendored SGP4/SDP4 as the propagation engine. Per Vallado & Crawford (2008) AIAA 2008-6770. New SQL functions: - tle_from_eci(): fit TLE from ECI position/velocity ephemeris - tle_from_topocentric(): fit TLE from az/el/range observations - tle_fit_residuals(): per-observation position residuals diagnostic Solver features: 6-state (orbital) or 7-state (+ B*) fitting, equinoctial elements for singularity-free optimization, tiered step limiting, Brouwer/Kozai Newton-Raphson conversion, auto initial guess from first ECI observation when no seed TLE provided. Tested: 8 regression tests (LEO/MEO/near-circular round-trips, B* recovery, topocentric, seedless, error handling, diagnostics), 67 standalone math unit tests, all 14 suites pass.
86 lines
3.4 KiB
Docker
86 lines
3.4 KiB
Docker
ARG PG_MAJOR=17
|
|
|
|
# ── Stage 1: Compile against PostgreSQL on Ubuntu 22.04 ─────
|
|
# Ubuntu Jammy matches TimescaleDB-HA's glibc (2.35).
|
|
# Building on Debian Bookworm (glibc 2.36) risks symbol version
|
|
# mismatches when the .so loads in TimescaleDB's runtime.
|
|
FROM ubuntu:22.04 AS builder
|
|
|
|
ARG PG_MAJOR
|
|
ARG DEBIAN_FRONTEND=noninteractive
|
|
|
|
# PGDG apt repository (same source TimescaleDB-HA uses)
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
ca-certificates curl gnupg lsb-release && \
|
|
curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc \
|
|
| gpg --dearmor -o /usr/share/keyrings/postgresql.gpg && \
|
|
echo "deb [signed-by=/usr/share/keyrings/postgresql.gpg] \
|
|
http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" \
|
|
> /etc/apt/sources.list.d/pgdg.list && \
|
|
apt-get update && apt-get install -y --no-install-recommends \
|
|
postgresql-${PG_MAJOR} \
|
|
postgresql-server-dev-${PG_MAJOR} \
|
|
gcc make \
|
|
liblapack-dev libblas-dev && \
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copy source tree (submodule content included as regular files)
|
|
WORKDIR /build/pg_orrery
|
|
COPY . .
|
|
|
|
ENV PG_CONFIG=/usr/lib/postgresql/${PG_MAJOR}/bin/pg_config
|
|
|
|
# Build extension
|
|
RUN make PG_CONFIG=${PG_CONFIG}
|
|
|
|
# Install to system location (needed for installcheck)
|
|
RUN make PG_CONFIG=${PG_CONFIG} install
|
|
|
|
# Run all 14 regression test suites against a throwaway cluster
|
|
RUN su postgres -c "/usr/lib/postgresql/${PG_MAJOR}/bin/initdb -D /tmp/pgtest" && \
|
|
su postgres -c "/usr/lib/postgresql/${PG_MAJOR}/bin/pg_ctl -D /tmp/pgtest -l /tmp/pgtest.log start" && \
|
|
su postgres -c "/usr/lib/postgresql/${PG_MAJOR}/bin/createuser -s root" && \
|
|
make PG_CONFIG=${PG_CONFIG} installcheck && \
|
|
su postgres -c "/usr/lib/postgresql/${PG_MAJOR}/bin/pg_ctl -D /tmp/pgtest stop"
|
|
|
|
# Standalone unit tests (no PostgreSQL dependency)
|
|
RUN make test-de-reader
|
|
RUN make test-od-math
|
|
|
|
# Capture artifacts under /pg_orrery prefix for the next stage
|
|
RUN make PG_CONFIG=${PG_CONFIG} DESTDIR=/pg_orrery install
|
|
|
|
|
|
# ── Stage 2: Minimal artifact (COPY --from target) ──────────
|
|
# ~525 KB total: .so + .control + .sql + init script.
|
|
# Downstream images (TimescaleDB-HA, vanilla PG) pull from here.
|
|
FROM scratch AS artifact
|
|
|
|
COPY --from=builder /pg_orrery/ /
|
|
COPY docker/020_install_pg_orrery.sh /docker-entrypoint-initdb.d/
|
|
|
|
|
|
# ── Stage 3: Standalone dev/test image ───────────────────────
|
|
# Ready-to-run PostgreSQL with pg_orrery pre-installed.
|
|
# For development, CI, and standalone experiments.
|
|
#
|
|
# Optional DE ephemeris at runtime (recommended):
|
|
# docker run -v /path/to/de440.bin:/var/lib/postgresql/pg_orrery/de440.bin pg_orrery
|
|
# Then: ALTER SYSTEM SET pg_orrery.ephemeris_path = '/var/lib/postgresql/pg_orrery/de440.bin';
|
|
#
|
|
# Or bake into the image (115 MB for DE440, 3.1 GB for DE441):
|
|
# Place the DE file in the build context, then:
|
|
# docker build --build-arg DE_FILE=de440.bin -t pg_orrery:de440 .
|
|
FROM postgres:${PG_MAJOR}-bookworm AS standalone
|
|
|
|
# LAPACK/BLAS runtime for OD solver (dgelss_)
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
liblapack3 libblas3 && \
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
COPY --from=artifact / /
|
|
|
|
# Create the pg_orrery data directory for DE ephemeris files
|
|
RUN mkdir -p /var/lib/postgresql/pg_orrery && \
|
|
chown postgres:postgres /var/lib/postgresql/pg_orrery
|