Three-stage Dockerfile: Ubuntu 22.04 builder (glibc-matched to TimescaleDB-HA), scratch artifact image (~748KB), and standalone postgres:17 image. All 6 regression suites run during build. Makefile gains docker-build, docker-push, and docker-test targets.
67 lines
2.3 KiB
Makefile
67 lines
2.3 KiB
Makefile
MODULE_big = pg_orbit
|
|
EXTENSION = pg_orbit
|
|
DATA = sql/pg_orbit--0.1.0.sql
|
|
|
|
# Our extension C sources
|
|
OBJS = src/pg_orbit.o src/tle_type.o src/eci_type.o src/observer_type.o \
|
|
src/sgp4_funcs.o src/coord_funcs.o src/pass_funcs.o src/gist_tle.o
|
|
|
|
# sat_code C++ sources (compiled with g++, linked with extern "C" symbols)
|
|
SAT_CODE_DIR = lib/sat_code
|
|
SAT_CODE_SRCS = $(SAT_CODE_DIR)/sgp4.cpp $(SAT_CODE_DIR)/sdp4.cpp \
|
|
$(SAT_CODE_DIR)/deep.cpp $(SAT_CODE_DIR)/common.cpp \
|
|
$(SAT_CODE_DIR)/basics.cpp $(SAT_CODE_DIR)/get_el.cpp \
|
|
$(SAT_CODE_DIR)/tle_out.cpp
|
|
SAT_CODE_OBJS = $(SAT_CODE_SRCS:.cpp=.o)
|
|
|
|
OBJS += $(SAT_CODE_OBJS)
|
|
|
|
# Regression tests
|
|
REGRESS = tle_parse sgp4_propagate coord_transforms pass_prediction gist_index convenience
|
|
REGRESS_OPTS = --inputdir=test
|
|
|
|
# Need C++ runtime for sat_code
|
|
SHLIB_LINK += -lstdc++ -lm
|
|
|
|
# Compiler flags
|
|
PG_CPPFLAGS = -I$(SAT_CODE_DIR)
|
|
|
|
# Use PGXS
|
|
PG_CONFIG ?= pg_config
|
|
PGXS := $(shell $(PG_CONFIG) --pgxs)
|
|
include $(PGXS)
|
|
|
|
# Rule for compiling sat_code C++ files
|
|
$(SAT_CODE_DIR)/%.o: $(SAT_CODE_DIR)/%.cpp
|
|
$(CXX) $(CXXFLAGS) -fPIC -I$(SAT_CODE_DIR) -c -o $@ $<
|
|
|
|
# ── Docker packaging ────────────────────────────────────────
|
|
REGISTRY ?= git.supported.systems/warehack.ing
|
|
IMAGE ?= pg_orbit
|
|
PG_MAJOR ?= 17
|
|
TAG ?= pg$(PG_MAJOR)
|
|
|
|
docker-build:
|
|
docker build --build-arg PG_MAJOR=$(PG_MAJOR) \
|
|
--target artifact -t $(REGISTRY)/$(IMAGE):$(TAG)-artifact .
|
|
docker build --build-arg PG_MAJOR=$(PG_MAJOR) \
|
|
--target standalone -t $(REGISTRY)/$(IMAGE):$(TAG) .
|
|
|
|
docker-push:
|
|
docker push $(REGISTRY)/$(IMAGE):$(TAG)-artifact
|
|
docker push $(REGISTRY)/$(IMAGE):$(TAG)
|
|
|
|
docker-test:
|
|
@echo "Smoke-testing standalone image..."
|
|
docker run --rm -d --name pg_orbit_test \
|
|
-e POSTGRES_PASSWORD=test $(REGISTRY)/$(IMAGE):$(TAG)
|
|
@echo "Waiting for PostgreSQL to initialize..."
|
|
@sleep 10
|
|
docker exec pg_orbit_test psql -U postgres -tAc \
|
|
"SELECT tle_norad_id(E'1 25544U 98067A 24001.50000000 .00016717 00000-0 10270-3 0 9025\n2 25544 51.6400 208.9163 0006703 30.1694 61.7520 15.50100486 00001'::tle);" \
|
|
| grep -q 25544
|
|
@docker stop pg_orbit_test
|
|
@echo "Smoke test passed."
|
|
|
|
.PHONY: docker-build docker-push docker-test
|