Skip to content

Commit df4b2b5

Browse files
committed
hurray for less dependency
1 parent d8683b0 commit df4b2b5

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

Dockerfile

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,8 @@ FROM percona/percona-postgresql-operator:2.6.0-ppg16.8-postgres
33
# Switch to root user temporarily to gain necessary privileges for setup
44
USER root
55

6-
# Install gosu for stepping down from root
7-
RUN apt-get update && apt-get install -y --no-install-recommends gosu \
8-
&& rm -rf /var/lib/apt/lists/* \
9-
&& apt-get clean
10-
11-
# Create a custom entrypoint script that sets OOM score and starts postgres
12-
COPY entrypoint-wrapper.sh /usr/local/bin/
136
COPY postgres-oom-adjuster.sh /usr/local/bin/
7+
COPY entrypoint-wrapper.sh /usr/local/bin/
148

159
# We don't change the original ENTRYPOINT - we wrap around it
1610
ENTRYPOINT ["/usr/local/bin/entrypoint-wrapper.sh"]

entrypoint-wrapper.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@ echo "Started postmaster OOM adjuster in background"
2222
export PG_OOM_ADJUST_FILE=/proc/self/oom_score_adj
2323
export PG_OOM_ADJUST_VALUE=0
2424

25-
# Verify the original entrypoint exists
25+
# Switching to the original user and executing original entrypoint
2626
echo "Switching to user $ORIGINAL_USER and executing original entrypoint: $ORIGINAL_ENTRYPOINT $@"
27-
exec gosu $ORIGINAL_USER "$ORIGINAL_ENTRYPOINT" "$@"
27+
28+
# Check which user-switching command is available
29+
if command -v runuser >/dev/null 2>&1; then
30+
# Use runuser (available on RHEL/CentOS/Fedora)
31+
exec runuser -u "#$ORIGINAL_USER" -- "$ORIGINAL_ENTRYPOINT" "$@"
32+
else
33+
# Fall back to su
34+
exec su -s /bin/bash $ORIGINAL_USER -c "$ORIGINAL_ENTRYPOINT $*"
35+
fi

0 commit comments

Comments
 (0)