# Build container FROM docker.io/debian:bullseye-slim as builder # Update package lists and install necessary packages in the build container RUN apt-get update && \ apt-get install -y --no-install-recommends git build-essential ca-certificates && \ rm -rf /var/lib/apt/lists/* # Clone the specific version of the pgvector repository RUN git clone --branch v0.4.1 https://github.com/pgvector/pgvector.git /tmp/pgvector # Build pgvector RUN cd /tmp/pgvector && \ make # Final base image FROM bitnami/postgresql:16.0.0-debian-11-r3 # Switch to root to install packages and make directories USER 0 # Ensure the package manager is functional and install build tools in the final image RUN mkdir -p /var/lib/apt/lists/partial && \ apt-get clean && \ apt-get update && \ apt-get install -y --no-install-recommends make gcc libc6-dev ca-certificates && \ rm -rf /var/lib/apt/lists/* # Copy the pgvector build from the builder stage COPY --from=builder /tmp/pgvector /tmp/pgvector # Install pgvector in the final image RUN export PG_CONFIG=/opt/bitnami/postgresql/bin/pg_config && \ cd /tmp/pgvector && \ make install && \ make clean # Cleanup the build tools to keep the image lean RUN apt-get remove -y make gcc libc6-dev && \ apt-get autoremove -y && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* USER 1001