1
0
cvsa/Dockerfile.pg

65 lines
2.5 KiB
Docker

FROM postgres:18.1
RUN localedef -i zh_CN -c -f UTF-8 -A /usr/share/locale/locale.alias zh_CN.UTF-8
ENV LANG=zh_CN.utf8 LC_ALL=zh_CN.utf8
LABEL maintainer="alikia2x <alikia2x@outlook.com>" \
description="Customized PostgreSQL image for Project CVSA including TimescaleDB & pgBackRest" \
version="1.0.0" \
org.opencontainers.image.title="CVSA PostgreSQL Extended" \
org.opencontainers.image.description="Customized PostgreSQL image for Project CVSA including TimescaleDB & pgBackRest" \
org.opencontainers.image.vendor="Luminara Studio" \
org.opencontainers.image.version="1.0.0" \
org.opencontainers.image.authors="alikia2x@outlook.com"
ENV DEBIAN_FRONTEND=noninteractive \
TZ=Asia/Shanghai
USER root
RUN set -eux; \
apt update -qq; \
apt install -y --no-install-recommends \
ca-certificates \
curl \
gnupg \
lsb-release \
wget \
; \
curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor -o /etc/apt/trusted.gpg.d/apt.postgresql.org.gpg; \
echo "deb https://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list; \
\
curl -L https://packagecloud.io/timescale/timescaledb/gpgkey | gpg --dearmor -o /etc/apt/trusted.gpg.d/timescaledb.gpg; \
echo "deb https://packagecloud.io/timescale/timescaledb/debian/ $(lsb_release -cs) main" > /etc/apt/sources.list.d/timescaledb.list; \
\
wget https://packages.groonga.org/debian/groonga-apt-source-latest-$(lsb_release --codename --short).deb; \
apt install -y -V ./groonga-apt-source-latest-$(lsb_release --codename --short).deb; \
\
apt update -q;
RUN apt install -y -V \
timescaledb-2-postgresql-18 \
postgresql-18-pgvector \
postgresql-18-cron \
postgresql-18-repack \
pgbackrest \
;
RUN apt purge -y --auto-remove \
curl gnupg lsb-release wget \
&& apt clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN mkdir -p /etc/postgresql/custom
RUN cp /usr/share/postgresql/postgresql.conf.sample /etc/postgresql/postgresql.conf
RUN echo "include_dir = '/etc/postgresql/custom/'" >> /etc/postgresql/postgresql.conf
RUN echo "shared_preload_libraries = 'timescaledb,pg_cron,pg_stat_statements'" >> /etc/postgresql/custom/extensions.conf
USER postgres
EXPOSE 5432
HEALTHCHECK --interval=20s --timeout=10s --start-period=5s --retries=3 \
CMD pg_isready -U postgres -h 127.0.0.1 || exit 1
CMD ["postgres"]