From 8c790380d097a8b500fc6688174568f11d3b3bb4 Mon Sep 17 00:00:00 2001 From: Daishan Peng Date: Mon, 25 Nov 2024 18:13:22 -0700 Subject: [PATCH] Chore: setup postgres and vector in dockerfile Signed-off-by: Daishan Peng --- Dockerfile | 43 +++++++++++++++++++++---------------------- run.sh | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 22 deletions(-) create mode 100644 run.sh diff --git a/Dockerfile b/Dockerfile index 784cb799..52d5137d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,6 +22,25 @@ RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store \ UV_LINK_MODE=copy BIN_DIR=/bin make package-tools FROM cgr.dev/chainguard/wolfi-base AS final + +# Setup postgres and postgres-vector, although in production setup we don't really need standalone postgres +RUN apk add postgresql build-base git postgresql-dev +RUN git clone --branch v0.8.0 https://github.com/pgvector/pgvector.git && \ + cd pgvector && \ + make clean && \ + make OPTFLAGS="" && \ + make install && \ + cd .. && \ + rm -rf pgvector + +RUN adduser -D postgres && mkdir -p /var/lib/postgresql/data && chown -R postgres:postgres /var/lib/postgresql +RUN su postgres -c "initdb --encoding=UTF8 -D /var/lib/postgresql/data" +RUN su - postgres -c "pg_ctl -D /var/lib/postgresql/data start" && \ + su - postgres -c "psql --command \"CREATE USER otto8 WITH SUPERUSER;\"" && \ + su - postgres -c "psql --command \"CREATE DATABASE otto8 OWNER otto8;\"" && \ + su - postgres -c "psql -d otto8 --command \"CREATE EXTENSION vector;\"" || true && \ + su - postgres -c "pg_ctl -D /var/lib/postgresql/data stop" || true + RUN apk add --no-cache git python-3.13 py3.13-pip openssh-server npm bash tini procps libreoffice COPY --chmod=0755 /tools/package-chrome.sh / RUN /package-chrome.sh && rm /package-chrome.sh @@ -29,28 +48,7 @@ RUN sed -E 's/^#(PermitRootLogin)no/\1yes/' /etc/ssh/sshd_config -i RUN ssh-keygen -A RUN mkdir /run/sshd && /usr/sbin/sshd COPY encryption.yaml / -COPY --chmod=0755 <