Files
shelfmark/entrypoint.sh
T
Vincent De Borger 06f654f4be Add UID and GID to set the user & group ID's during runtime (#10)
This PR add the option to set UID/GID during runtime, making sure the
application is running as a non-root user.
Besides this, it also helps with making sure UID/GID match between
containers.
2024-12-19 10:16:25 -05:00

23 lines
484 B
Bash

#!/bin/bash
set -e
mkdir -p /var/logs
mkdir -p "$INGEST_DIR"
# Create group if it doesn't exist
if ! getent group "$GID" >/dev/null; then
groupadd -g "$GID" abc
fi
# Create user if it doesn't exist
if ! id -u "$UID" >/dev/null 2>&1; then
useradd -u "$UID" -g "$GID" -d /app -s /sbin/nologin abc
fi
# Adjust ownership of application directories
chown -R $UID:$GID /app "$INGEST_DIR" /var/logs
# Switch to the created user and execute the main command
exec gosu $UID "$@"