Reputation: 5
I'm trying to deploy a Postgres cluster with the pgvector
extension based on the bitnami/postgresql-repmgr
docker image.
However, running docker build
throws
E: List directory /var/lib/apt/lists/partial is missing. - Acquire (2: No such file or directory) apt failed, retrying
I attempted to solve this by switching to the root user before installing the packages and then switching back to the default bitnami user 1001. While this fixes the build issue, it now causes the deployment to fail with reason
"root" execution of the PostgreSQL server is not permitted. The server must be started under an unprivileged user ID to prevent possible system security compromise. See the documentation for more information on how to properly start the server.
So this leaves me with the dilemma that I can't install the pgvector packages without root permissions and at the same time I can't deploy the database with root permissions. How do I get around this, and why would it be running with the root user if I switched back to 1001?
Some context
bitnami/postgresql-repmgr
Dockerfile
FROM bitnami/postgresql-repmgr:16
# USER root
RUN install_packages git build-essential && \
cd /tmp && \
git clone --branch v0.8.0 https://github.com/pgvector/pgvector.git && \
cd pgvector && \
export PG_CONFIG=/opt/bitnami/postgresql/bin/pg_config && \
make && \
make install && \
rm -rf /tmp/pgvector
# USER 1001
CMD ["postgres"]
Edit:
I tried referencing the pgvector image itself rather than installing the packages manually. This got me further and the database deploys correctly but now fails to start.
FROM pgvector/pgvector:pg16 AS builder
FROM bitnami/postgresql-repmgr:16
COPY --from=builder /usr/lib/postgresql/16/lib/vector.so /opt/bitnami/postgresql/lib/
COPY --from=builder /usr/share/postgresql/16/extension/vector* /opt/bitnami/postgresql/share/extension/
Error
postgres: could not access the server configuration file "/bitnami/postgresql/postgresql.conf": No such file or directory
Upvotes: 0
Views: 94
Reputation: 4936
I don't think CMD
should be ["postgres"]
. From origianl postgresql-repmgr Dockerfile, it should be
CMD [ "/opt/bitnami/scripts/postgresql-repmgr/run.sh" ]
Otherwise, you could also remove CMD
line altogether as it will use the CMD
from the original bitnami/postgresql-repmgr
image
Upvotes: 0