Skip to content

Commit 1c843f7

Browse files
committed
create postgresql user
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
1 parent d28ddac commit 1c843f7

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Dockerfile.pgsql

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,23 @@ RUN apt-get update && \
2222
postgresql-common \
2323
jq \
2424
build-essential \
25+
gosu \
2526
&& rm -rf /var/lib/apt/lists/*
2627
28+
# Create postgres user with specific UID/GID (999:999) for Kubernetes compatibility
29+
# This must be done before installing PostgreSQL packages
30+
# In Kubernetes, set fsGroup: 999 in securityContext to automatically fix volume permissions
31+
RUN if ! getent group postgres > /dev/null 2>&1; then \
32+
groupadd -r postgres --gid=999; \
33+
else \
34+
groupmod -g 999 postgres 2>/dev/null || true; \
35+
fi && \
36+
if ! getent passwd postgres > /dev/null 2>&1; then \
37+
useradd -r -g postgres --uid=999 --home-dir=/var/lib/postgresql --shell=/bin/bash postgres; \
38+
else \
39+
usermod -u 999 -g postgres postgres 2>/dev/null || true; \
40+
fi
41+
2742
# Add the PostgreSQL 18 repository
2843
RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - && \
2944
sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' && \

0 commit comments

Comments
 (0)