mirror of
https://github.com/bitwarden/server.git
synced 2025-04-05 05:00:19 -05:00
map host docker group id to containers
This commit is contained in:
parent
2c65bd8403
commit
b7a2e47bd9
@ -28,6 +28,9 @@ then
|
|||||||
OS="mac"
|
OS="mac"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
LUID="LOCAL_UID=`id -u $USER`"
|
||||||
|
LGID="LOCAL_GID=`getent group docker | cut -d: -f3`"
|
||||||
|
|
||||||
mkdir -p $OUTPUT_DIR
|
mkdir -p $OUTPUT_DIR
|
||||||
|
|
||||||
LETS_ENCRYPT="n"
|
LETS_ENCRYPT="n"
|
||||||
@ -63,7 +66,7 @@ fi
|
|||||||
docker pull bitwarden/setup:$COREVERSION
|
docker pull bitwarden/setup:$COREVERSION
|
||||||
if [ $OS == "lin" ]
|
if [ $OS == "lin" ]
|
||||||
then
|
then
|
||||||
docker run -it --rm --name setup -v $OUTPUT_DIR:/bitwarden -e LOCAL_UID=`id -u $USER` bitwarden/setup:$COREVERSION \
|
docker run -it --rm --name setup -v $OUTPUT_DIR:/bitwarden -e $LUID -e $LGID bitwarden/setup:$COREVERSION \
|
||||||
dotnet Setup.dll -install 1 -domain $DOMAIN -letsencrypt $LETS_ENCRYPT -os $OS -corev $COREVERSION -webv $WEBVERSION
|
dotnet Setup.dll -install 1 -domain $DOMAIN -letsencrypt $LETS_ENCRYPT -os $OS -corev $COREVERSION -webv $WEBVERSION
|
||||||
else
|
else
|
||||||
docker run -it --rm --name setup -v $OUTPUT_DIR:/bitwarden bitwarden/setup:$COREVERSION \
|
docker run -it --rm --name setup -v $OUTPUT_DIR:/bitwarden bitwarden/setup:$COREVERSION \
|
||||||
|
@ -31,6 +31,8 @@ fi
|
|||||||
|
|
||||||
DOCKER_DIR="$OUTPUT_DIR/docker"
|
DOCKER_DIR="$OUTPUT_DIR/docker"
|
||||||
ENV_DIR="$OUTPUT_DIR/env"
|
ENV_DIR="$OUTPUT_DIR/env"
|
||||||
|
LUID="LOCAL_UID=`id -u $USER`"
|
||||||
|
LGID="LOCAL_GID=`getent group docker | cut -d: -f3`"
|
||||||
|
|
||||||
# Functions
|
# Functions
|
||||||
|
|
||||||
@ -80,7 +82,7 @@ function updateDatabase() {
|
|||||||
if [ $OS == "lin" ]
|
if [ $OS == "lin" ]
|
||||||
then
|
then
|
||||||
docker run -i --rm --name setup --network container:bitwarden-mssql \
|
docker run -i --rm --name setup --network container:bitwarden-mssql \
|
||||||
-v $OUTPUT_DIR:/bitwarden -e LOCAL_UID=`id -u $USER` bitwarden/setup:$COREVERSION \
|
-v $OUTPUT_DIR:/bitwarden -e $LUID -e $LGID bitwarden/setup:$COREVERSION \
|
||||||
dotnet Setup.dll -update 1 -db 1 -os $OS -corev $COREVERSION -webv $WEBVERSION
|
dotnet Setup.dll -update 1 -db 1 -os $OS -corev $COREVERSION -webv $WEBVERSION
|
||||||
else
|
else
|
||||||
docker run -i --rm --name setup --network container:bitwarden-mssql \
|
docker run -i --rm --name setup --network container:bitwarden-mssql \
|
||||||
@ -95,7 +97,7 @@ function update() {
|
|||||||
if [ $OS == "lin" ]
|
if [ $OS == "lin" ]
|
||||||
then
|
then
|
||||||
docker run -i --rm --name setup -v $OUTPUT_DIR:/bitwarden \
|
docker run -i --rm --name setup -v $OUTPUT_DIR:/bitwarden \
|
||||||
-e LOCAL_UID=`id -u $USER` bitwarden/setup:$COREVERSION \
|
-e $LUID -e $LGID bitwarden/setup:$COREVERSION \
|
||||||
dotnet Setup.dll -update 1 -os $OS -corev $COREVERSION -webv $WEBVERSION
|
dotnet Setup.dll -update 1 -os $OS -corev $COREVERSION -webv $WEBVERSION
|
||||||
else
|
else
|
||||||
docker run -i --rm --name setup \
|
docker run -i --rm --name setup \
|
||||||
@ -109,7 +111,7 @@ function printEnvironment() {
|
|||||||
if [ $OS == "lin" ]
|
if [ $OS == "lin" ]
|
||||||
then
|
then
|
||||||
docker run -i --rm --name setup -v $OUTPUT_DIR:/bitwarden \
|
docker run -i --rm --name setup -v $OUTPUT_DIR:/bitwarden \
|
||||||
-e LOCAL_UID=`id -u $USER` bitwarden/setup:$COREVERSION \
|
-e $LUID -e $LGID bitwarden/setup:$COREVERSION \
|
||||||
dotnet Setup.dll -printenv 1 -os $OS -corev $COREVERSION -webv $WEBVERSION
|
dotnet Setup.dll -printenv 1 -os $OS -corev $COREVERSION -webv $WEBVERSION
|
||||||
else
|
else
|
||||||
docker run -i --rm --name setup \
|
docker run -i --rm --name setup \
|
||||||
@ -126,7 +128,7 @@ function restart() {
|
|||||||
if [ $OS == "lin" ]
|
if [ $OS == "lin" ]
|
||||||
then
|
then
|
||||||
mkdir -p $ENV_DIR
|
mkdir -p $ENV_DIR
|
||||||
echo "LOCAL_UID=`id -u $USER`" > $ENV_DIR/uid.env
|
(echo $LUID; echo $LGID) > $ENV_DIR/uid.env
|
||||||
fi
|
fi
|
||||||
|
|
||||||
dockerComposeUp
|
dockerComposeUp
|
||||||
|
@ -10,8 +10,6 @@ WORKDIR /app
|
|||||||
EXPOSE 5000
|
EXPOSE 5000
|
||||||
COPY obj/Docker/publish .
|
COPY obj/Docker/publish .
|
||||||
COPY entrypoint.sh /
|
COPY entrypoint.sh /
|
||||||
|
RUN chmod +x /entrypoint.sh
|
||||||
RUN groupadd -g 999 bitwarden \
|
|
||||||
&& chmod +x /entrypoint.sh
|
|
||||||
|
|
||||||
ENTRYPOINT ["/entrypoint.sh"]
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
|
@ -1,35 +1,67 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Setup
|
||||||
|
|
||||||
|
GROUPNAME="bitwarden"
|
||||||
USERNAME="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}
|
LUID=${LOCAL_UID:-999}
|
||||||
|
|
||||||
# Step down from host root
|
# Step down from host root
|
||||||
|
|
||||||
|
if [ $LGID == 0 ]
|
||||||
|
then
|
||||||
|
LGID=999
|
||||||
|
fi
|
||||||
|
|
||||||
if [ $LUID == 0 ]
|
if [ $LUID == 0 ]
|
||||||
then
|
then
|
||||||
LUID=999
|
LUID=999
|
||||||
fi
|
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
|
then
|
||||||
usermod -u $LUID $USERNAME
|
usermod -u $LUID $USERNAME
|
||||||
elif [ $NOUSER == 1 ]
|
elif [ $NOUSER == 1 ]
|
||||||
then
|
then
|
||||||
useradd -r -u $LUID -g $USERNAME $USERNAME
|
useradd -r -u $LUID -g $GROUPNAME $USERNAME
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Make home directory for user
|
||||||
|
|
||||||
if [ ! -d "/home/$USERNAME" ]
|
if [ ! -d "/home/$USERNAME" ]
|
||||||
then
|
then
|
||||||
mkhomedir_helper $USERNAME
|
mkhomedir_helper $USERNAME
|
||||||
fi
|
fi
|
||||||
|
|
||||||
chown -R $USERNAME:$USERNAME /app
|
# The rest...
|
||||||
|
|
||||||
|
chown -R $USERNAME:$GROUPNAME /app
|
||||||
mkdir -p /etc/bitwarden/core
|
mkdir -p /etc/bitwarden/core
|
||||||
mkdir -p /etc/bitwarden/logs
|
mkdir -p /etc/bitwarden/logs
|
||||||
mkdir -p /etc/bitwarden/ca-certificates
|
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/ \
|
cp /etc/bitwarden/ca-certificates/*.crt /usr/local/share/ca-certificates/ \
|
||||||
&& update-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/Api .
|
||||||
COPY obj/Docker/publish/Jobs /jobs
|
COPY obj/Docker/publish/Jobs /jobs
|
||||||
COPY entrypoint.sh /
|
COPY entrypoint.sh /
|
||||||
|
RUN chmod +x /entrypoint.sh
|
||||||
|
|
||||||
RUN mv /jobs/crontab /etc/cron.d/bitwarden-cron \
|
RUN mv /jobs/crontab /etc/cron.d/bitwarden-cron \
|
||||||
&& chmod 0644 /etc/cron.d/bitwarden-cron
|
&& chmod 0644 /etc/cron.d/bitwarden-cron
|
||||||
|
|
||||||
RUN groupadd -g 999 bitwarden \
|
|
||||||
&& chmod +x /entrypoint.sh
|
|
||||||
|
|
||||||
ENTRYPOINT ["/entrypoint.sh"]
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
|
@ -1,36 +1,68 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Setup
|
||||||
|
|
||||||
|
GROUPNAME="bitwarden"
|
||||||
USERNAME="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}
|
LUID=${LOCAL_UID:-999}
|
||||||
|
|
||||||
# Step down from host root
|
# Step down from host root
|
||||||
|
|
||||||
|
if [ $LGID == 0 ]
|
||||||
|
then
|
||||||
|
LGID=999
|
||||||
|
fi
|
||||||
|
|
||||||
if [ $LUID == 0 ]
|
if [ $LUID == 0 ]
|
||||||
then
|
then
|
||||||
LUID=999
|
LUID=999
|
||||||
fi
|
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
|
then
|
||||||
usermod -u $LUID $USERNAME
|
usermod -u $LUID $USERNAME
|
||||||
elif [ $NOUSER == 1 ]
|
elif [ $NOUSER == 1 ]
|
||||||
then
|
then
|
||||||
useradd -r -u $LUID -g $USERNAME $USERNAME
|
useradd -r -u $LUID -g $GROUPNAME $USERNAME
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Make home directory for user
|
||||||
|
|
||||||
if [ ! -d "/home/$USERNAME" ]
|
if [ ! -d "/home/$USERNAME" ]
|
||||||
then
|
then
|
||||||
mkhomedir_helper $USERNAME
|
mkhomedir_helper $USERNAME
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# The rest...
|
||||||
|
|
||||||
touch /var/log/cron.log
|
touch /var/log/cron.log
|
||||||
chown $USERNAME:$USERNAME /var/log/cron.log
|
chown $USERNAME:$GROUPNAME /var/log/cron.log
|
||||||
chown -R $USERNAME:$USERNAME /app
|
chown -R $USERNAME:$GROUPNAME /app
|
||||||
chown -R $USERNAME:$USERNAME /jobs
|
chown -R $USERNAME:$GROUPNAME /jobs
|
||||||
mkdir -p /etc/bitwarden/core
|
mkdir -p /etc/bitwarden/core
|
||||||
mkdir -p /etc/bitwarden/logs
|
mkdir -p /etc/bitwarden/logs
|
||||||
mkdir -p /etc/bitwarden/ca-certificates
|
mkdir -p /etc/bitwarden/ca-certificates
|
||||||
chown -R $USERNAME:$USERNAME /etc/bitwarden
|
chown -R $USERNAME:$GROUPNAME /etc/bitwarden
|
||||||
|
|
||||||
env >> /etc/environment
|
env >> /etc/environment
|
||||||
cron
|
cron
|
||||||
@ -38,4 +70,4 @@ cron
|
|||||||
cp /etc/bitwarden/ca-certificates/*.crt /usr/local/share/ca-certificates/ \
|
cp /etc/bitwarden/ca-certificates/*.crt /usr/local/share/ca-certificates/ \
|
||||||
&& update-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
|
EXPOSE 5000
|
||||||
COPY obj/Docker/publish .
|
COPY obj/Docker/publish .
|
||||||
COPY entrypoint.sh /
|
COPY entrypoint.sh /
|
||||||
|
RUN chmod +x /entrypoint.sh
|
||||||
RUN groupadd -g 999 bitwarden \
|
|
||||||
&& chmod +x /entrypoint.sh
|
|
||||||
|
|
||||||
ENTRYPOINT ["/entrypoint.sh"]
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
|
@ -1,30 +1,62 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Setup
|
||||||
|
|
||||||
|
GROUPNAME="bitwarden"
|
||||||
USERNAME="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}
|
LUID=${LOCAL_UID:-999}
|
||||||
|
|
||||||
# Step down from host root
|
# Step down from host root
|
||||||
|
|
||||||
|
if [ $LGID == 0 ]
|
||||||
|
then
|
||||||
|
LGID=999
|
||||||
|
fi
|
||||||
|
|
||||||
if [ $LUID == 0 ]
|
if [ $LUID == 0 ]
|
||||||
then
|
then
|
||||||
LUID=999
|
LUID=999
|
||||||
fi
|
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
|
then
|
||||||
usermod -u $LUID $USERNAME
|
usermod -u $LUID $USERNAME
|
||||||
elif [ $NOUSER == 1 ]
|
elif [ $NOUSER == 1 ]
|
||||||
then
|
then
|
||||||
useradd -r -u $LUID -g $USERNAME $USERNAME
|
useradd -r -u $LUID -g $GROUPNAME $USERNAME
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Make home directory for user
|
||||||
|
|
||||||
if [ ! -d "/home/$USERNAME" ]
|
if [ ! -d "/home/$USERNAME" ]
|
||||||
then
|
then
|
||||||
mkhomedir_helper $USERNAME
|
mkhomedir_helper $USERNAME
|
||||||
fi
|
fi
|
||||||
|
|
||||||
chown -R $USERNAME:$USERNAME /app
|
# The rest...
|
||||||
chown -R $USERNAME:$USERNAME /etc/iconserver
|
|
||||||
|
|
||||||
gosu $USERNAME:$USERNAME /etc/iconserver/iconserver &
|
chown -R $USERNAME:$GROUPNAME /app
|
||||||
gosu $USERNAME:$USERNAME dotnet /app/Icons.dll iconsSettings:bestIconBaseUrl=http://localhost:8080
|
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
|
EXPOSE 5000
|
||||||
COPY obj/Docker/publish .
|
COPY obj/Docker/publish .
|
||||||
COPY entrypoint.sh /
|
COPY entrypoint.sh /
|
||||||
|
RUN chmod +x /entrypoint.sh
|
||||||
RUN groupadd -g 999 bitwarden \
|
|
||||||
&& chmod +x /entrypoint.sh
|
|
||||||
|
|
||||||
ENTRYPOINT ["/entrypoint.sh"]
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
|
@ -1,38 +1,70 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Setup
|
||||||
|
|
||||||
|
GROUPNAME="bitwarden"
|
||||||
USERNAME="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}
|
LUID=${LOCAL_UID:-999}
|
||||||
|
|
||||||
# Step down from host root
|
# Step down from host root
|
||||||
|
|
||||||
|
if [ $LGID == 0 ]
|
||||||
|
then
|
||||||
|
LGID=999
|
||||||
|
fi
|
||||||
|
|
||||||
if [ $LUID == 0 ]
|
if [ $LUID == 0 ]
|
||||||
then
|
then
|
||||||
LUID=999
|
LUID=999
|
||||||
fi
|
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
|
then
|
||||||
usermod -u $LUID $USERNAME
|
usermod -u $LUID $USERNAME
|
||||||
elif [ $NOUSER == 1 ]
|
elif [ $NOUSER == 1 ]
|
||||||
then
|
then
|
||||||
useradd -r -u $LUID -g $USERNAME $USERNAME
|
useradd -r -u $LUID -g $GROUPNAME $USERNAME
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Make home directory for user
|
||||||
|
|
||||||
if [ ! -d "/home/$USERNAME" ]
|
if [ ! -d "/home/$USERNAME" ]
|
||||||
then
|
then
|
||||||
mkhomedir_helper $USERNAME
|
mkhomedir_helper $USERNAME
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# The rest...
|
||||||
|
|
||||||
mkdir -p /etc/bitwarden/identity
|
mkdir -p /etc/bitwarden/identity
|
||||||
mkdir -p /etc/bitwarden/core
|
mkdir -p /etc/bitwarden/core
|
||||||
mkdir -p /etc/bitwarden/logs
|
mkdir -p /etc/bitwarden/logs
|
||||||
mkdir -p /etc/bitwarden/ca-certificates
|
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
|
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/ \
|
cp /etc/bitwarden/ca-certificates/*.crt /usr/local/share/ca-certificates/ \
|
||||||
&& update-ca-certificates
|
&& update-ca-certificates
|
||||||
|
|
||||||
gosu $USERNAME:$USERNAME dotnet /app/Identity.dll
|
gosu $USERNAME:$GROUPNAME dotnet /app/Identity.dll
|
||||||
|
@ -8,8 +8,6 @@ RUN apt-get update \
|
|||||||
ENV ASPNETCORE_URLS http://+:5000
|
ENV ASPNETCORE_URLS http://+:5000
|
||||||
EXPOSE 5000
|
EXPOSE 5000
|
||||||
COPY entrypoint.sh /
|
COPY entrypoint.sh /
|
||||||
|
RUN chmod +x /entrypoint.sh
|
||||||
RUN groupadd -g 999 bitwarden \
|
|
||||||
&& chmod +x /entrypoint.sh
|
|
||||||
|
|
||||||
ENTRYPOINT ["/entrypoint.sh"]
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
|
@ -1,31 +1,63 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Setup
|
||||||
|
|
||||||
|
GROUPNAME="bitwarden"
|
||||||
USERNAME="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}
|
LUID=${LOCAL_UID:-999}
|
||||||
|
|
||||||
# Step down from host root
|
# Step down from host root
|
||||||
|
|
||||||
|
if [ $LGID == 0 ]
|
||||||
|
then
|
||||||
|
LGID=999
|
||||||
|
fi
|
||||||
|
|
||||||
if [ $LUID == 0 ]
|
if [ $LUID == 0 ]
|
||||||
then
|
then
|
||||||
LUID=999
|
LUID=999
|
||||||
fi
|
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
|
then
|
||||||
usermod -u $LUID $USERNAME
|
usermod -u $LUID $USERNAME
|
||||||
elif [ $NOUSER == 1 ]
|
elif [ $NOUSER == 1 ]
|
||||||
then
|
then
|
||||||
useradd -r -u $LUID -g $USERNAME $USERNAME
|
useradd -r -u $LUID -g $GROUPNAME $USERNAME
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Make home directory for user
|
||||||
|
|
||||||
if [ ! -d "/home/$USERNAME" ]
|
if [ ! -d "/home/$USERNAME" ]
|
||||||
then
|
then
|
||||||
mkhomedir_helper $USERNAME
|
mkhomedir_helper $USERNAME
|
||||||
fi
|
fi
|
||||||
|
|
||||||
chown -R $USERNAME:$USERNAME /bitwarden_server
|
# The rest...
|
||||||
mkdir -p /etc/bitwarden/core/attachments
|
|
||||||
chown -R $USERNAME:$USERNAME /etc/bitwarden
|
|
||||||
|
|
||||||
gosu $USERNAME:$USERNAME dotnet /bitwarden_server/Server.dll \
|
chown -R $USERNAME:$GROUPNAME /bitwarden_server
|
||||||
|
mkdir -p /etc/bitwarden/core/attachments
|
||||||
|
chown -R $USERNAME:$GROUPNAME /etc/bitwarden
|
||||||
|
|
||||||
|
gosu $USERNAME:$GROUPNAME dotnet /bitwarden_server/Server.dll \
|
||||||
/contentRoot=/etc/bitwarden/core/attachments /webRoot=. /serveUnknown=true
|
/contentRoot=/etc/bitwarden/core/attachments /webRoot=. /serveUnknown=true
|
||||||
|
@ -6,8 +6,6 @@ RUN apt-get update \
|
|||||||
gosu \
|
gosu \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
RUN groupadd -g 999 bitwarden
|
|
||||||
|
|
||||||
COPY crontab /etc/cron.d/bitwarden-cron
|
COPY crontab /etc/cron.d/bitwarden-cron
|
||||||
RUN chmod 0644 /etc/cron.d/bitwarden-cron
|
RUN chmod 0644 /etc/cron.d/bitwarden-cron
|
||||||
COPY backup-db.sql /
|
COPY backup-db.sql /
|
||||||
@ -16,4 +14,5 @@ COPY entrypoint.sh /
|
|||||||
|
|
||||||
RUN chmod +x /entrypoint.sh \
|
RUN chmod +x /entrypoint.sh \
|
||||||
&& chmod +x /backup-db.sh
|
&& chmod +x /backup-db.sh
|
||||||
|
|
||||||
ENTRYPOINT ["/entrypoint.sh"]
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
|
@ -1,38 +1,70 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Setup
|
||||||
|
|
||||||
|
GROUPNAME="bitwarden"
|
||||||
USERNAME="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}
|
LUID=${LOCAL_UID:-999}
|
||||||
|
|
||||||
# Step down from host root
|
# Step down from host root
|
||||||
|
|
||||||
|
if [ $LGID == 0 ]
|
||||||
|
then
|
||||||
|
LGID=999
|
||||||
|
fi
|
||||||
|
|
||||||
if [ $LUID == 0 ]
|
if [ $LUID == 0 ]
|
||||||
then
|
then
|
||||||
LUID=999
|
LUID=999
|
||||||
fi
|
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
|
then
|
||||||
usermod -u $LUID $USERNAME
|
usermod -u $LUID $USERNAME
|
||||||
elif [ $NOUSER == 1 ]
|
elif [ $NOUSER == 1 ]
|
||||||
then
|
then
|
||||||
useradd -r -u $LUID -g $USERNAME $USERNAME
|
useradd -r -u $LUID -g $GROUPNAME $USERNAME
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Make home directory for user
|
||||||
|
|
||||||
if [ ! -d "/home/$USERNAME" ]
|
if [ ! -d "/home/$USERNAME" ]
|
||||||
then
|
then
|
||||||
mkhomedir_helper $USERNAME
|
mkhomedir_helper $USERNAME
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# The rest...
|
||||||
|
|
||||||
touch /var/log/cron.log
|
touch /var/log/cron.log
|
||||||
chown $USERNAME:$USERNAME /var/log/cron.log
|
chown $USERNAME:$GROUPNAME /var/log/cron.log
|
||||||
mkdir -p /etc/bitwarden/mssql/backups
|
mkdir -p /etc/bitwarden/mssql/backups
|
||||||
chown -R $USERNAME:$USERNAME /etc/bitwarden
|
chown -R $USERNAME:$GROUPNAME /etc/bitwarden
|
||||||
mkdir -p /var/opt/mssql/data
|
mkdir -p /var/opt/mssql/data
|
||||||
chown -R $USERNAME:$USERNAME /var/opt/mssql
|
chown -R $USERNAME:$GROUPNAME /var/opt/mssql
|
||||||
chown $USERNAME:$USERNAME /backup-db.sh
|
chown $USERNAME:$GROUPNAME /backup-db.sh
|
||||||
chown $USERNAME:$USERNAME /backup-db.sql
|
chown $USERNAME:$GROUPNAME /backup-db.sql
|
||||||
|
|
||||||
env >> /etc/environment
|
env >> /etc/environment
|
||||||
cron
|
cron
|
||||||
|
|
||||||
gosu $USERNAME:$USERNAME /opt/mssql/bin/sqlservr
|
gosu $USERNAME:$GROUPNAME /opt/mssql/bin/sqlservr
|
||||||
|
@ -9,8 +9,6 @@ COPY nginx.conf /etc/nginx
|
|||||||
COPY proxy.conf /etc/nginx
|
COPY proxy.conf /etc/nginx
|
||||||
COPY mime.types /etc/nginx
|
COPY mime.types /etc/nginx
|
||||||
COPY entrypoint.sh /
|
COPY entrypoint.sh /
|
||||||
|
RUN chmod +x /entrypoint.sh
|
||||||
RUN groupadd -g 999 bitwarden \
|
|
||||||
&& chmod +x /entrypoint.sh
|
|
||||||
|
|
||||||
ENTRYPOINT ["/entrypoint.sh"]
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
|
@ -1,37 +1,69 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Setup
|
||||||
|
|
||||||
|
GROUPNAME="bitwarden"
|
||||||
USERNAME="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}
|
LUID=${LOCAL_UID:-999}
|
||||||
|
|
||||||
# Step down from host root
|
# Step down from host root
|
||||||
|
|
||||||
|
if [ $LGID == 0 ]
|
||||||
|
then
|
||||||
|
LGID=999
|
||||||
|
fi
|
||||||
|
|
||||||
if [ $LUID == 0 ]
|
if [ $LUID == 0 ]
|
||||||
then
|
then
|
||||||
LUID=999
|
LUID=999
|
||||||
fi
|
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
|
then
|
||||||
usermod -u $LUID $USERNAME
|
usermod -u $LUID $USERNAME
|
||||||
elif [ $NOUSER == 1 ]
|
elif [ $NOUSER == 1 ]
|
||||||
then
|
then
|
||||||
useradd -r -u $LUID -g $USERNAME $USERNAME
|
useradd -r -u $LUID -g $GROUPNAME $USERNAME
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Make home directory for user
|
||||||
|
|
||||||
if [ ! -d "/home/$USERNAME" ]
|
if [ ! -d "/home/$USERNAME" ]
|
||||||
then
|
then
|
||||||
mkhomedir_helper $USERNAME
|
mkhomedir_helper $USERNAME
|
||||||
fi
|
fi
|
||||||
|
|
||||||
chown -R $USERNAME:$USERNAME /etc/bitwarden
|
# The rest...
|
||||||
|
|
||||||
|
chown -R $USERNAME:$GROUPNAME /etc/bitwarden
|
||||||
cp /etc/bitwarden/nginx/default.conf /etc/nginx/conf.d/default.conf
|
cp /etc/bitwarden/nginx/default.conf /etc/nginx/conf.d/default.conf
|
||||||
mkdir -p /etc/letsencrypt
|
mkdir -p /etc/letsencrypt
|
||||||
chown -R $USERNAME:$USERNAME /etc/letsencrypt
|
chown -R $USERNAME:$GROUPNAME /etc/letsencrypt
|
||||||
mkdir -p /etc/ssl
|
mkdir -p /etc/ssl
|
||||||
chown -R $USERNAME:$USERNAME /etc/ssl
|
chown -R $USERNAME:$GROUPNAME /etc/ssl
|
||||||
touch /var/run/nginx.pid
|
touch /var/run/nginx.pid
|
||||||
chown -R $USERNAME:$USERNAME /var/run/nginx.pid
|
chown -R $USERNAME:$GROUPNAME /var/run/nginx.pid
|
||||||
chown -R $USERNAME:$USERNAME /var/cache/nginx
|
chown -R $USERNAME:$GROUPNAME /var/cache/nginx
|
||||||
chown -R $USERNAME:$USERNAME /var/log/nginx
|
chown -R $USERNAME:$GROUPNAME /var/log/nginx
|
||||||
|
|
||||||
gosu $USERNAME:$USERNAME nginx -g 'daemon off;'
|
gosu $USERNAME:$GROUPNAME nginx -g 'daemon off;'
|
||||||
|
@ -9,8 +9,6 @@ RUN apt-get update \
|
|||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY obj/Docker/publish .
|
COPY obj/Docker/publish .
|
||||||
COPY entrypoint.sh /
|
COPY entrypoint.sh /
|
||||||
|
RUN chmod +x /entrypoint.sh
|
||||||
RUN groupadd -g 999 bitwarden \
|
|
||||||
&& chmod +x /entrypoint.sh
|
|
||||||
|
|
||||||
ENTRYPOINT ["/entrypoint.sh"]
|
ENTRYPOINT ["/entrypoint.sh"]
|
||||||
|
@ -1,35 +1,67 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Setup
|
||||||
|
|
||||||
|
GROUPNAME="bitwarden"
|
||||||
USERNAME="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}
|
LUID=${LOCAL_UID:-999}
|
||||||
|
|
||||||
# Step down from host root
|
# Step down from host root
|
||||||
|
|
||||||
|
if [ $LGID == 0 ]
|
||||||
|
then
|
||||||
|
LGID=999
|
||||||
|
fi
|
||||||
|
|
||||||
if [ $LUID == 0 ]
|
if [ $LUID == 0 ]
|
||||||
then
|
then
|
||||||
LUID=999
|
LUID=999
|
||||||
fi
|
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
|
then
|
||||||
usermod -u $LUID $USERNAME
|
usermod -u $LUID $USERNAME
|
||||||
elif [ $NOUSER == 1 ]
|
elif [ $NOUSER == 1 ]
|
||||||
then
|
then
|
||||||
useradd -r -u $LUID -g $USERNAME $USERNAME
|
useradd -r -u $LUID -g $GROUPNAME $USERNAME
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Make home directory for user
|
||||||
|
|
||||||
if [ ! -d "/home/$USERNAME" ]
|
if [ ! -d "/home/$USERNAME" ]
|
||||||
then
|
then
|
||||||
mkhomedir_helper $USERNAME
|
mkhomedir_helper $USERNAME
|
||||||
fi
|
fi
|
||||||
|
|
||||||
chown -R $USERNAME:$USERNAME /app
|
# The rest...
|
||||||
|
|
||||||
|
chown -R $USERNAME:$GROUPNAME /app
|
||||||
mkdir -p /bitwarden/env
|
mkdir -p /bitwarden/env
|
||||||
mkdir -p /bitwarden/docker
|
mkdir -p /bitwarden/docker
|
||||||
mkdir -p /bitwarden/ssl
|
mkdir -p /bitwarden/ssl
|
||||||
mkdir -p /bitwarden/letsencrypt
|
mkdir -p /bitwarden/letsencrypt
|
||||||
mkdir -p /bitwarden/identity
|
mkdir -p /bitwarden/identity
|
||||||
mkdir -p /bitwarden/nginx
|
mkdir -p /bitwarden/nginx
|
||||||
chown -R $USERNAME:$USERNAME /bitwarden
|
chown -R $USERNAME:$GROUPNAME /bitwarden
|
||||||
|
|
||||||
exec gosu $USERNAME:$USERNAME "$@"
|
exec gosu $USERNAME:$GROUPNAME "$@"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user