-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContainerfile
More file actions
87 lines (71 loc) · 3.5 KB
/
Containerfile
File metadata and controls
87 lines (71 loc) · 3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# --------------------------------------------------------------------------
# THIS FILE IS AUTOGENERATED - DO NOT EDIT MANUALLY
#
# Source: Containerfile.j2
# --------------------------------------------------------------------------
ARG PG_VERSION=14
# Builder stage - compile extensions
FROM ghcr.io/daemonless/postgres:${PG_VERSION} AS builder
# Build dependencies
RUN pkg update && pkg install -y \
FreeBSD-bmake FreeBSD-clibs-dev FreeBSD-clang FreeBSD-clang-dev FreeBSD-toolchain \
FreeBSD-libexecinfo FreeBSD-libexecinfo-dev FreeBSD-runtime-dev FreeBSD-utilities-dev \
rust gmake git-lite pkgconf \
&& pkg clean -ay
# Fetch minimal ports tree for pgvector
RUN fetch -qo /tmp/ports.tar.zst \
"https://download.freebsd.org/ports/ports/ports.tar.zst" && \
mkdir -p /usr/ports && \
tar -xf /tmp/ports.tar.zst -C /usr/ports --strip-components=1 \
ports/databases/pgvector ports/Mk ports/Templates ports/Keywords && \
rm /tmp/ports.tar.zst
# Build pgvector
WORKDIR /usr/ports/databases/pgvector
RUN make DEFAULT_VERSIONS+=pgsql=${PG_VERSION} BATCH=yes install clean
# Build VectorChord from source
ARG VECTORCHORD_VERSION=0.5.3
RUN fetch -qo /tmp/vectorchord.tar.gz \
"https://github.com/tensorchord/VectorChord/archive/refs/tags/${VECTORCHORD_VERSION}.tar.gz" && \
tar -xzf /tmp/vectorchord.tar.gz -C /tmp && \
cd /tmp/VectorChord-${VECTORCHORD_VERSION} && \
gmake build && \
gmake install
# Production image
FROM ghcr.io/daemonless/postgres:${PG_VERSION}
ARG FREEBSD_ARCH=amd64
ARG VECTORCHORD_VERSION=0.4.3
ARG HEALTHCHECK_ENDPOINT="pg_isready -U postgres"
ENV HEALTHCHECK_CMD="${HEALTHCHECK_ENDPOINT}"
# --- Metadata (Injected by Generator) ---
LABEL org.opencontainers.image.title="Immich PostgreSQL" \
org.opencontainers.image.description="PostgreSQL with pgvector and vectorchord extensions required by Immich for vector similarity search. Defaults to PostgreSQL 14 (:latest), PostgreSQL 18 available as :18." \
org.opencontainers.image.source="https://github.com/daemonless/immich-postgres" \
org.opencontainers.image.url="https://immich.app/" \
org.opencontainers.image.licenses="PostgreSQL" \
org.opencontainers.image.vendor="daemonless" \
org.opencontainers.image.authors="daemonless" \
io.daemonless.category="Databases" \
io.daemonless.port="5432" \
io.daemonless.volumes="/var/lib/postgresql/data" \
io.daemonless.arch="${FREEBSD_ARCH}" \
io.daemonless.vectorchord-version="${VECTORCHORD_VERSION}" \
io.daemonless.healthcheck-cmd="${HEALTHCHECK_ENDPOINT}" \
org.freebsd.jail.allow.sysvipc="required"
# Copy built extensions from builder
COPY --from=builder /usr/local/lib/postgresql/vector.so /usr/local/lib/postgresql/
COPY --from=builder /usr/local/share/postgresql/extension/vector* /usr/local/share/postgresql/extension/
COPY --from=builder /usr/local/lib/postgresql/vchord.so /usr/local/lib/postgresql/
COPY --from=builder /usr/local/share/postgresql/extension/vchord* /usr/local/share/postgresql/extension/
# Fix permissions
RUN chmod 644 /usr/local/share/postgresql/extension/vchord* && \
chmod 755 /usr/local/lib/postgresql/vchord.so
# Copy init scripts for extensions
COPY docker-entrypoint-initdb.d/ /docker-entrypoint-initdb.d/
RUN chmod 644 /docker-entrypoint-initdb.d/*
# Immich-specific defaults
ENV POSTGRES_DB=immich \
POSTGRES_SHARED_PRELOAD_LIBRARIES=vchord
# --- Expose (Injected by Generator) ---
EXPOSE 5432
# --- Volumes (Injected by Generator) ---
VOLUME /var/lib/postgresql/data