Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 

40 строки
2.0 KiB

  1. # Custom PostgreSQL 18.4 image with pg_partman + pg_cron extensions.
  2. #
  3. # The logs table of new-api is a RANGE-partitioned table on created_at, created
  4. # and maintained entirely on the database side by the pg_partman extension.
  5. # pg_cron drives periodic maintenance (premake future weekly partitions).
  6. #
  7. # Both extensions are installed via Debian packages. pg_cron must be loaded via
  8. # shared_preload_libraries, so we append it to postgresql.conf.sample: initdb
  9. # generates PGDATA/postgresql.conf from this sample, meaning both the temporary
  10. # server (during docker-entrypoint-initdb.d) and the real server load pg_cron,
  11. # allowing CREATE EXTENSION pg_cron to succeed at init time.
  12. #
  13. # Build/push:
  14. # docker build -t registry.cn-hangzhou.aliyuncs.com/fengsilin/postgres-partman:18 .
  15. # docker push registry.cn-hangzhou.aliyuncs.com/fengsilin/postgres-partman:18
  16. FROM postgres:18
  17. # Use Aliyun Debian mirror for faster/reliable apt downloads from within China.
  18. # postgres:18 is based on Debian trixie which uses the deb822-format
  19. # /etc/apt/sources.list.d/debian.sources file instead of sources.list.
  20. RUN sed -i 's|deb.debian.org|mirrors.aliyun.com|g; s|security.debian.org|mirrors.aliyun.com|g' \
  21. /etc/apt/sources.list.d/debian.sources
  22. RUN apt-get update \
  23. && apt-get install -y --no-install-recommends \
  24. postgresql-18-partman \
  25. postgresql-18-cron \
  26. && rm -rf /var/lib/apt/lists/*
  27. # Preload pg_cron so it is available during first-run init scripts.
  28. # pg_partman is a plain SQL extension and does not need preloading.
  29. RUN echo "shared_preload_libraries = 'pg_cron'" >> /usr/share/postgresql/18/postgresql.conf.sample
  30. RUN echo "cron.database_name = 'new-api'" >> /usr/share/postgresql/18/postgresql.conf.sample
  31. # First-run init: create extensions, the partitioned logs parent table, register
  32. # it with pg_partman, build core indexes, and schedule maintenance via pg_cron.
  33. # Runs against the database named by POSTGRES_DB (new-api).
  34. COPY docker-entrypoint-initdb.d/01-partition.sql /docker-entrypoint-initdb.d/01-partition.sql