feat: storage type env and other changes (#215)

This commit is contained in:
Zack Pollard
2025-05-21 15:38:23 +01:00
committed by GitHub
parent 206e05877c
commit 480dd76db0
4 changed files with 28 additions and 3 deletions

View File

@@ -8,6 +8,8 @@ ARG VECTORCHORD_TAG
ARG PGVECTORS_TAG
ARG TARGETARCH
ENV DB_STORAGE_TYPE=SSD
RUN apt-get update && \
apt-get install -y wget && \
wget -nv -O /tmp/vchord.deb https://github.com/tensorchord/VectorChord/releases/download/$VECTORCHORD_TAG/postgresql-${PG_MAJOR%.*}-vchord_${VECTORCHORD_TAG#"v"}-1_${TARGETARCH}.deb && \
@@ -24,6 +26,7 @@ RUN apt-get update && \
rm -rf /var/lib/apt/lists/*
COPY postgresql.hdd.conf postgresql.ssd.conf /etc/postgresql/
COPY immich-docker-entrypoint.sh /usr/local/bin/
RUN if [ -n "$PGVECTORS_TAG" ]; then \
sed -i "s/vchord.so/vchord.so, vectors.so/" /etc/postgresql/postgresql.*.conf; \
@@ -32,4 +35,6 @@ RUN if [ -n "$PGVECTORS_TAG" ]; then \
HEALTHCHECK --interval=5m --start-interval=30s --start-period=5m CMD pg_isready --dbname="${POSTGRES_DB}" --username="${POSTGRES_USER}" || exit 1; Chksum="$(psql --dbname="${POSTGRES_DB}" --username="${POSTGRES_USER}" --tuples-only --no-align --command='SELECT COALESCE(SUM(checksum_failures), 0) FROM pg_stat_database')"; echo "checksum failure count is $Chksum"; [ "$Chksum" = '0' ] || exit 1
CMD ["postgres", "-c", "config_file=/etc/postgresql/postgresql.ssd.conf"]
ENTRYPOINT ["/usr/local/bin/immich-docker-entrypoint.sh"]
CMD ["postgres", "-c", "config_file=/etc/postgresql/postgresql.conf"]

View File

@@ -0,0 +1,22 @@
#!/usr/bin/env bash
: "${DB_STORAGE_TYPE:=SSD}"
case "${DB_STORAGE_TYPE^^}" in
SSD|HDD)
echo "Using ${DB_STORAGE_TYPE^^} storage"
cp -n "/etc/postgresql/postgresql.${DB_STORAGE_TYPE,,}.conf" /etc/postgresql/postgresql.conf
;;
*)
echo "Error: DB_STORAGE_TYPE must be set to 'SSD' or 'HDD'" >&2
exit 1
;;
esac
: "${POSTGRES_USER:=${DB_USERNAME}}"
: "${POSTGRES_PASSWORD:=${DB_PASSWORD}}"
: "${POSTGRES_DB:=${DB_DATABASE_NAME}}"
export POSTGRES_USER POSTGRES_PASSWORD POSTGRES_DB
exec /usr/local/bin/docker-entrypoint.sh "$@"

View File

@@ -2,7 +2,6 @@ include_if_exists '/var/lib/postgresql/data/postgresql.conf'
shared_preload_libraries = 'vchord.so'
search_path = '"$user", public'
logging_collector = on
max_wal_size = 5GB
shared_buffers = 512MB
wal_compression = on

View File

@@ -2,7 +2,6 @@ include_if_exists '/var/lib/postgresql/data/postgresql.conf'
shared_preload_libraries = 'vchord.so'
search_path = '"$user", public'
logging_collector = on
max_wal_size = 5GB
shared_buffers = 512MB
wal_compression = on