# Postgres 17 whose server runs under libfaketime (time-bomb.yml). Only the postgres binary is preloaded:
# the image's entrypoint scripts hang under libfaketime, and they don't need the fake clock. The clock
# comes from FAKETIME / FAKETIME_* in the container's environment; without them it's ordinary Postgres.
FROM postgres:17
RUN apt-get update -qq \
 && apt-get install -y -qq --no-install-recommends libfaketime \
 && rm -rf /var/lib/apt/lists/* \
 && bin=/usr/lib/postgresql/17/bin \
 && mv "$bin/postgres" "$bin/postgres.real" \
 && lib="$(ls /usr/lib/*/faketime/libfaketime.so.1)" \
 && printf '#!/bin/sh\nexport LD_PRELOAD=%s\nexec %s/postgres.real "$@"\n' "$lib" "$bin" > "$bin/postgres" \
 && chmod 755 "$bin/postgres"
