-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContainerfile.j2
More file actions
96 lines (81 loc) · 3.47 KB
/
Containerfile.j2
File metadata and controls
96 lines (81 loc) · 3.47 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
88
89
90
91
92
93
94
95
96
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
{%- if ports %}
ARG HEALTHCHECK_ENDPOINT="pg_isready -U postgres"
{%- else %}
ARG HEALTHCHECK_ENDPOINT="pg_isready -U postgres"
{%- endif %}
ENV HEALTHCHECK_CMD="${HEALTHCHECK_ENDPOINT}"
# --- Metadata (Injected by Generator) ---
LABEL org.opencontainers.image.title="{{ title }}" \
org.opencontainers.image.description="{{ description }}" \
org.opencontainers.image.source="{{ repo_url }}" \
org.opencontainers.image.url="{{ web_url }}" \
org.opencontainers.image.licenses="PostgreSQL" \
org.opencontainers.image.vendor="daemonless" \
org.opencontainers.image.authors="daemonless" \
io.daemonless.category="{{ category }}" \
{%- if ports %}
io.daemonless.port="{{ ports[0].port }}" \
{%- endif %}
{%- if volumes %}
io.daemonless.volumes="{{ volumes | map(attribute='path') | join(',') }}" \
{%- endif %}
{%- if mlock %}
org.freebsd.jail.allow.mlock="required" \
{%- endif %}
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) ---
{%- if ports %}
EXPOSE {{ ports | map(attribute='port') | join(' ') }}
{%- endif %}
# --- Volumes (Injected by Generator) ---
{%- if volumes %}
VOLUME {{ volumes | map(attribute='path') | join(' ') }}
{%- endif %}