mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-05-24 01:12:54 -04:00
feat: added gosu & updated run.sh to switch to the dedicated user (#1395)
Co-authored-by: Maka0 <360614-Maka0@users.noreply.gitlab.com>
This commit is contained in:
parent
7ce02c31d5
commit
a7c6e89dfa
@ -97,7 +97,7 @@ ENV GIT_COMMIT_HASH=$COMMIT
|
|||||||
# curl for used by healthcheck
|
# curl for used by healthcheck
|
||||||
RUN apt-get update \
|
RUN apt-get update \
|
||||||
&& apt-get install --no-install-recommends -y \
|
&& apt-get install --no-install-recommends -y \
|
||||||
curl \
|
curl gosu \
|
||||||
&& apt-get autoremove \
|
&& apt-get autoremove \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
@ -12,17 +12,28 @@ PGID=${PGID:-911}
|
|||||||
add_user() {
|
add_user() {
|
||||||
groupmod -o -g "$PGID" abc
|
groupmod -o -g "$PGID" abc
|
||||||
usermod -o -u "$PUID" abc
|
usermod -o -u "$PUID" abc
|
||||||
|
}
|
||||||
|
|
||||||
echo "
|
change_user() {
|
||||||
User uid: $(id -u abc)
|
# If container is started as root then create a new user and switch to it
|
||||||
User gid: $(id -g abc)
|
if [ "$(id -u)" = "0" ]; then
|
||||||
"
|
add_user
|
||||||
chown -R abc:abc /app
|
chown -R $PUID:$PGID /app
|
||||||
|
|
||||||
|
echo "Switching to dedicated user"
|
||||||
|
exec gosu $PUID "$BASH_SOURCE" "$@"
|
||||||
|
elif [ "$(id -u)" = $PUID ]; then
|
||||||
|
echo "
|
||||||
|
User uid: $PUID
|
||||||
|
User gid: $PGID
|
||||||
|
"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
# $MEALIE_HOME directory
|
# $MEALIE_HOME directory
|
||||||
cd /app
|
cd /app
|
||||||
|
|
||||||
# Activate our virtual environment here
|
# Activate our virtual environment here
|
||||||
. /opt/pysetup/.venv/bin/activate
|
. /opt/pysetup/.venv/bin/activate
|
||||||
|
|
||||||
@ -45,7 +56,8 @@ if [ "$ARG1" == "reload" ]; then
|
|||||||
else
|
else
|
||||||
echo "Production"
|
echo "Production"
|
||||||
|
|
||||||
add_user
|
change_user
|
||||||
|
|
||||||
init
|
init
|
||||||
|
|
||||||
# Start API
|
# Start API
|
||||||
|
Loading…
x
Reference in New Issue
Block a user