mirror of
https://github.com/rustmailer/bichon.git
synced 2026-08-03 07:48:34 +02:00
fix: switch from PUID/PGID env vars to Docker --user for permissions
This commit is contained in:
@@ -25,9 +25,6 @@ RUN chmod +x /opt/bichon/bichon
|
||||
RUN chmod +x /usr/local/bin/bichonctl
|
||||
RUN chmod +x /usr/local/bin/bichon-admin
|
||||
|
||||
# Copy and setup entrypoint script for PUID/PGID support
|
||||
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||
RUN chmod +x /usr/local/bin/entrypoint.sh
|
||||
|
||||
# Install ca-certificates to ensure HTTPS certificate verification works correctly
|
||||
RUN apt update && apt install -y ca-certificates curl && rm -rf /var/lib/apt/lists/*
|
||||
@@ -43,6 +40,4 @@ WORKDIR /data
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
|
||||
CMD curl -fs http://localhost:15630/api/status || exit 1
|
||||
|
||||
# Entrypoint with PUID/PGID support
|
||||
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
||||
CMD ["/opt/bichon/bichon"]
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Entrypoint script for Bichon Docker container
|
||||
# Handles PUID/PGID environment variables for proper user permissions
|
||||
|
||||
set -e
|
||||
|
||||
# If not running as root, do nothing
|
||||
if [ "$(id -u)" != "0" ]; then
|
||||
echo "Running as non-root user ($(id -u)), skipping PUID/PGID handling"
|
||||
exec "$@"
|
||||
fi
|
||||
|
||||
|
||||
# Function to create user and switch to it
|
||||
switch_user() {
|
||||
local puid="$1"
|
||||
local pgid="$2"
|
||||
local USER_NAME
|
||||
local GROUP_NAME
|
||||
|
||||
# group
|
||||
if getent group "$pgid" >/dev/null 2>&1; then
|
||||
GROUP_NAME=$(getent group "$pgid" | cut -d: -f1)
|
||||
else
|
||||
groupadd -g "$pgid" bichon
|
||||
GROUP_NAME=bichon
|
||||
fi
|
||||
|
||||
# user
|
||||
if getent passwd "$puid" >/dev/null 2>&1; then
|
||||
USER_NAME=$(getent passwd "$puid" | cut -d: -f1)
|
||||
else
|
||||
useradd -u "$puid" -g "$GROUP_NAME" -s /bin/bash -d /data bichon
|
||||
USER_NAME=bichon
|
||||
fi
|
||||
|
||||
chown -R "$puid:$pgid" /data
|
||||
chown -R "$puid:$pgid" /opt/bichon
|
||||
[ -d /envelope ] && chown -R "$puid:$pgid" /envelope
|
||||
[ -d /eml ] && chown -R "$puid:$pgid" /eml
|
||||
|
||||
exec runuser -u "$USER_NAME" -- "$@"
|
||||
}
|
||||
|
||||
|
||||
# Check if PUID and PGID are set
|
||||
if [ -n "$PUID" ] && [ -n "$PGID" ]; then
|
||||
echo "Switching to user with PUID=$PUID, PGID=$PGID"
|
||||
switch_user "$PUID" "$PGID" "$@"
|
||||
else
|
||||
echo "No PUID/PGID specified, running as root"
|
||||
exec "$@"
|
||||
fi
|
||||
Reference in New Issue
Block a user