mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 07:36:14 -05:00
map host docker group id to containers
This commit is contained in:
@ -10,8 +10,6 @@ WORKDIR /app
|
||||
EXPOSE 5000
|
||||
COPY obj/Docker/publish .
|
||||
COPY entrypoint.sh /
|
||||
|
||||
RUN groupadd -g 999 bitwarden \
|
||||
&& chmod +x /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
|
@ -1,35 +1,67 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Setup
|
||||
|
||||
GROUPNAME="bitwarden"
|
||||
USERNAME="bitwarden"
|
||||
NOUSER=`id -u $USERNAME > /dev/null 2>&1; echo $?`
|
||||
|
||||
CURRENTGID=`getent group $GROUPNAME | cut -d: -f3`
|
||||
LGID=${LOCAL_GID:-999}
|
||||
|
||||
CURRENTUID=`id -u $USERNAME`
|
||||
NOUSER=`$CURRENTUID > /dev/null 2>&1; echo $?`
|
||||
LUID=${LOCAL_UID:-999}
|
||||
|
||||
# Step down from host root
|
||||
|
||||
if [ $LGID == 0 ]
|
||||
then
|
||||
LGID=999
|
||||
fi
|
||||
|
||||
if [ $LUID == 0 ]
|
||||
then
|
||||
LUID=999
|
||||
fi
|
||||
|
||||
if [ $NOUSER == 0 ] && [ `id -u $USERNAME` != $LUID ]
|
||||
# Create group
|
||||
|
||||
if [ $CURRENTGID ]
|
||||
then
|
||||
if [ $CURRENTGID != $LGID ]
|
||||
then
|
||||
groupmod -g $LGID $GROUPNAME
|
||||
fi
|
||||
else
|
||||
groupadd -g $LGID $GROUPNAME
|
||||
fi
|
||||
|
||||
# Create user and assign group
|
||||
|
||||
if [ $NOUSER == 0 ] && [ $CURRENTUID != $LUID ]
|
||||
then
|
||||
usermod -u $LUID $USERNAME
|
||||
elif [ $NOUSER == 1 ]
|
||||
then
|
||||
useradd -r -u $LUID -g $USERNAME $USERNAME
|
||||
useradd -r -u $LUID -g $GROUPNAME $USERNAME
|
||||
fi
|
||||
|
||||
# Make home directory for user
|
||||
|
||||
if [ ! -d "/home/$USERNAME" ]
|
||||
then
|
||||
mkhomedir_helper $USERNAME
|
||||
fi
|
||||
|
||||
chown -R $USERNAME:$USERNAME /app
|
||||
# The rest...
|
||||
|
||||
chown -R $USERNAME:$GROUPNAME /app
|
||||
mkdir -p /etc/bitwarden/core
|
||||
mkdir -p /etc/bitwarden/logs
|
||||
mkdir -p /etc/bitwarden/ca-certificates
|
||||
chown -R $USERNAME:$USERNAME /etc/bitwarden
|
||||
chown -R $USERNAME:$GROUPNAME /etc/bitwarden
|
||||
|
||||
cp /etc/bitwarden/ca-certificates/*.crt /usr/local/share/ca-certificates/ \
|
||||
&& update-ca-certificates
|
||||
|
||||
gosu $USERNAME:$USERNAME dotnet /app/Admin.dll
|
||||
gosu $USERNAME:$GROUPNAME dotnet /app/Admin.dll
|
||||
|
@ -12,11 +12,9 @@ EXPOSE 5000
|
||||
COPY obj/Docker/publish/Api .
|
||||
COPY obj/Docker/publish/Jobs /jobs
|
||||
COPY entrypoint.sh /
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
||||
RUN mv /jobs/crontab /etc/cron.d/bitwarden-cron \
|
||||
&& chmod 0644 /etc/cron.d/bitwarden-cron
|
||||
|
||||
RUN groupadd -g 999 bitwarden \
|
||||
&& chmod +x /entrypoint.sh
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
|
@ -1,36 +1,68 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Setup
|
||||
|
||||
GROUPNAME="bitwarden"
|
||||
USERNAME="bitwarden"
|
||||
NOUSER=`id -u $USERNAME > /dev/null 2>&1; echo $?`
|
||||
|
||||
CURRENTGID=`getent group $GROUPNAME | cut -d: -f3`
|
||||
LGID=${LOCAL_GID:-999}
|
||||
|
||||
CURRENTUID=`id -u $USERNAME`
|
||||
NOUSER=`$CURRENTUID > /dev/null 2>&1; echo $?`
|
||||
LUID=${LOCAL_UID:-999}
|
||||
|
||||
# Step down from host root
|
||||
|
||||
if [ $LGID == 0 ]
|
||||
then
|
||||
LGID=999
|
||||
fi
|
||||
|
||||
if [ $LUID == 0 ]
|
||||
then
|
||||
LUID=999
|
||||
fi
|
||||
|
||||
if [ $NOUSER == 0 ] && [ `id -u $USERNAME` != $LUID ]
|
||||
# Create group
|
||||
|
||||
if [ $CURRENTGID ]
|
||||
then
|
||||
if [ $CURRENTGID != $LGID ]
|
||||
then
|
||||
groupmod -g $LGID $GROUPNAME
|
||||
fi
|
||||
else
|
||||
groupadd -g $LGID $GROUPNAME
|
||||
fi
|
||||
|
||||
# Create user and assign group
|
||||
|
||||
if [ $NOUSER == 0 ] && [ $CURRENTUID != $LUID ]
|
||||
then
|
||||
usermod -u $LUID $USERNAME
|
||||
elif [ $NOUSER == 1 ]
|
||||
then
|
||||
useradd -r -u $LUID -g $USERNAME $USERNAME
|
||||
useradd -r -u $LUID -g $GROUPNAME $USERNAME
|
||||
fi
|
||||
|
||||
# Make home directory for user
|
||||
|
||||
if [ ! -d "/home/$USERNAME" ]
|
||||
then
|
||||
mkhomedir_helper $USERNAME
|
||||
fi
|
||||
|
||||
# The rest...
|
||||
|
||||
touch /var/log/cron.log
|
||||
chown $USERNAME:$USERNAME /var/log/cron.log
|
||||
chown -R $USERNAME:$USERNAME /app
|
||||
chown -R $USERNAME:$USERNAME /jobs
|
||||
chown $USERNAME:$GROUPNAME /var/log/cron.log
|
||||
chown -R $USERNAME:$GROUPNAME /app
|
||||
chown -R $USERNAME:$GROUPNAME /jobs
|
||||
mkdir -p /etc/bitwarden/core
|
||||
mkdir -p /etc/bitwarden/logs
|
||||
mkdir -p /etc/bitwarden/ca-certificates
|
||||
chown -R $USERNAME:$USERNAME /etc/bitwarden
|
||||
chown -R $USERNAME:$GROUPNAME /etc/bitwarden
|
||||
|
||||
env >> /etc/environment
|
||||
cron
|
||||
@ -38,4 +70,4 @@ cron
|
||||
cp /etc/bitwarden/ca-certificates/*.crt /usr/local/share/ca-certificates/ \
|
||||
&& update-ca-certificates
|
||||
|
||||
gosu bitwarden:bitwarden dotnet /app/Api.dll
|
||||
gosu $USERNAME:$GROUPNAME dotnet /app/Api.dll
|
||||
|
@ -18,8 +18,6 @@ WORKDIR /app
|
||||
EXPOSE 5000
|
||||
COPY obj/Docker/publish .
|
||||
COPY entrypoint.sh /
|
||||
|
||||
RUN groupadd -g 999 bitwarden \
|
||||
&& chmod +x /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
|
@ -1,30 +1,62 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Setup
|
||||
|
||||
GROUPNAME="bitwarden"
|
||||
USERNAME="bitwarden"
|
||||
NOUSER=`id -u $USERNAME > /dev/null 2>&1; echo $?`
|
||||
|
||||
CURRENTGID=`getent group $GROUPNAME | cut -d: -f3`
|
||||
LGID=${LOCAL_GID:-999}
|
||||
|
||||
CURRENTUID=`id -u $USERNAME`
|
||||
NOUSER=`$CURRENTUID > /dev/null 2>&1; echo $?`
|
||||
LUID=${LOCAL_UID:-999}
|
||||
|
||||
# Step down from host root
|
||||
|
||||
if [ $LGID == 0 ]
|
||||
then
|
||||
LGID=999
|
||||
fi
|
||||
|
||||
if [ $LUID == 0 ]
|
||||
then
|
||||
LUID=999
|
||||
fi
|
||||
|
||||
if [ $NOUSER == 0 ] && [ `id -u $USERNAME` != $LUID ]
|
||||
# Create group
|
||||
|
||||
if [ $CURRENTGID ]
|
||||
then
|
||||
if [ $CURRENTGID != $LGID ]
|
||||
then
|
||||
groupmod -g $LGID $GROUPNAME
|
||||
fi
|
||||
else
|
||||
groupadd -g $LGID $GROUPNAME
|
||||
fi
|
||||
|
||||
# Create user and assign group
|
||||
|
||||
if [ $NOUSER == 0 ] && [ $CURRENTUID != $LUID ]
|
||||
then
|
||||
usermod -u $LUID $USERNAME
|
||||
elif [ $NOUSER == 1 ]
|
||||
then
|
||||
useradd -r -u $LUID -g $USERNAME $USERNAME
|
||||
useradd -r -u $LUID -g $GROUPNAME $USERNAME
|
||||
fi
|
||||
|
||||
# Make home directory for user
|
||||
|
||||
if [ ! -d "/home/$USERNAME" ]
|
||||
then
|
||||
mkhomedir_helper $USERNAME
|
||||
fi
|
||||
|
||||
chown -R $USERNAME:$USERNAME /app
|
||||
chown -R $USERNAME:$USERNAME /etc/iconserver
|
||||
# The rest...
|
||||
|
||||
gosu $USERNAME:$USERNAME /etc/iconserver/iconserver &
|
||||
gosu $USERNAME:$USERNAME dotnet /app/Icons.dll iconsSettings:bestIconBaseUrl=http://localhost:8080
|
||||
chown -R $USERNAME:$GROUPNAME /app
|
||||
chown -R $USERNAME:$GROUPNAME /etc/iconserver
|
||||
|
||||
gosu $USERNAME:$GROUPNAME /etc/iconserver/iconserver &
|
||||
gosu $USERNAME:$GROUPNAME dotnet /app/Icons.dll iconsSettings:bestIconBaseUrl=http://localhost:8080
|
||||
|
@ -10,8 +10,6 @@ WORKDIR /app
|
||||
EXPOSE 5000
|
||||
COPY obj/Docker/publish .
|
||||
COPY entrypoint.sh /
|
||||
|
||||
RUN groupadd -g 999 bitwarden \
|
||||
&& chmod +x /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
|
@ -1,38 +1,70 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Setup
|
||||
|
||||
GROUPNAME="bitwarden"
|
||||
USERNAME="bitwarden"
|
||||
NOUSER=`id -u $USERNAME > /dev/null 2>&1; echo $?`
|
||||
|
||||
CURRENTGID=`getent group $GROUPNAME | cut -d: -f3`
|
||||
LGID=${LOCAL_GID:-999}
|
||||
|
||||
CURRENTUID=`id -u $USERNAME`
|
||||
NOUSER=`$CURRENTUID > /dev/null 2>&1; echo $?`
|
||||
LUID=${LOCAL_UID:-999}
|
||||
|
||||
# Step down from host root
|
||||
|
||||
if [ $LGID == 0 ]
|
||||
then
|
||||
LGID=999
|
||||
fi
|
||||
|
||||
if [ $LUID == 0 ]
|
||||
then
|
||||
LUID=999
|
||||
fi
|
||||
|
||||
if [ $NOUSER == 0 ] && [ `id -u $USERNAME` != $LUID ]
|
||||
# Create group
|
||||
|
||||
if [ $CURRENTGID ]
|
||||
then
|
||||
if [ $CURRENTGID != $LGID ]
|
||||
then
|
||||
groupmod -g $LGID $GROUPNAME
|
||||
fi
|
||||
else
|
||||
groupadd -g $LGID $GROUPNAME
|
||||
fi
|
||||
|
||||
# Create user and assign group
|
||||
|
||||
if [ $NOUSER == 0 ] && [ $CURRENTUID != $LUID ]
|
||||
then
|
||||
usermod -u $LUID $USERNAME
|
||||
elif [ $NOUSER == 1 ]
|
||||
then
|
||||
useradd -r -u $LUID -g $USERNAME $USERNAME
|
||||
useradd -r -u $LUID -g $GROUPNAME $USERNAME
|
||||
fi
|
||||
|
||||
# Make home directory for user
|
||||
|
||||
if [ ! -d "/home/$USERNAME" ]
|
||||
then
|
||||
mkhomedir_helper $USERNAME
|
||||
fi
|
||||
|
||||
# The rest...
|
||||
|
||||
mkdir -p /etc/bitwarden/identity
|
||||
mkdir -p /etc/bitwarden/core
|
||||
mkdir -p /etc/bitwarden/logs
|
||||
mkdir -p /etc/bitwarden/ca-certificates
|
||||
chown -R $USERNAME:$USERNAME /etc/bitwarden
|
||||
chown -R $USERNAME:$GROUPNAME /etc/bitwarden
|
||||
|
||||
cp /etc/bitwarden/identity/identity.pfx /app/identity.pfx
|
||||
chown -R $USERNAME:$USERNAME /app
|
||||
chown -R $USERNAME:$GROUPNAME /app
|
||||
|
||||
cp /etc/bitwarden/ca-certificates/*.crt /usr/local/share/ca-certificates/ \
|
||||
&& update-ca-certificates
|
||||
|
||||
gosu $USERNAME:$USERNAME dotnet /app/Identity.dll
|
||||
gosu $USERNAME:$GROUPNAME dotnet /app/Identity.dll
|
||||
|
Reference in New Issue
Block a user