diff --git a/build.sh b/build.sh index eb880a8106..829da5701a 100644 --- a/build.sh +++ b/build.sh @@ -17,6 +17,7 @@ then docker push bitwarden/server:$TAG docker push bitwarden/attachments:$TAG docker push bitwarden/icons:$TAG + docker push bitwarden/notifications:$TAG docker push bitwarden/admin:$TAG docker push bitwarden/nginx:$TAG docker push bitwarden/mssql:$TAG @@ -32,6 +33,7 @@ then docker tag bitwarden/server bitwarden/server:$TAG docker tag bitwarden/attachments bitwarden/attachments:$TAG docker tag bitwarden/icons bitwarden/icons:$TAG + docker tag bitwarden/notifications bitwarden/notifications:$TAG docker tag bitwarden/admin bitwarden/admin:$TAG docker tag bitwarden/nginx bitwarden/nginx:$TAG docker tag bitwarden/mssql bitwarden/mssql:$TAG @@ -58,6 +60,9 @@ else chmod u+x $DIR/src/Icons/build.sh $DIR/src/Icons/build.sh + chmod u+x $DIR/src/Notifications/build.sh + $DIR/src/Notifications/build.sh + chmod u+x $DIR/src/Admin/build.sh $DIR/src/Admin/build.sh diff --git a/src/Icons/.dockerignore b/src/Icons/.dockerignore index 95837a862d..7e37ce5d99 100644 --- a/src/Icons/.dockerignore +++ b/src/Icons/.dockerignore @@ -2,4 +2,3 @@ !obj/Docker/publish/* !obj/Docker/empty/ !entrypoint.sh -!iconserver.sha256 diff --git a/src/Icons/entrypoint.sh b/src/Icons/entrypoint.sh index 5879381587..5d7ac5623e 100644 --- a/src/Icons/entrypoint.sh +++ b/src/Icons/entrypoint.sh @@ -30,5 +30,11 @@ mkhomedir_helper $USERNAME # The rest... chown -R $USERNAME:$GROUPNAME /app +mkdir -p /etc/bitwarden/logs +mkdir -p /etc/bitwarden/ca-certificates +chown -R $USERNAME:$GROUPNAME /etc/bitwarden + +cp /etc/bitwarden/ca-certificates/*.crt /usr/local/share/ca-certificates/ >/dev/null 2>&1 \ + && update-ca-certificates exec gosu $USERNAME:$GROUPNAME dotnet /app/Icons.dll diff --git a/src/Notifications/.dockerignore b/src/Notifications/.dockerignore new file mode 100644 index 0000000000..7e37ce5d99 --- /dev/null +++ b/src/Notifications/.dockerignore @@ -0,0 +1,4 @@ +* +!obj/Docker/publish/* +!obj/Docker/empty/ +!entrypoint.sh diff --git a/src/Notifications/Dockerfile b/src/Notifications/Dockerfile new file mode 100644 index 0000000000..904b4a67b6 --- /dev/null +++ b/src/Notifications/Dockerfile @@ -0,0 +1,17 @@ +FROM microsoft/dotnet:2.1.2-aspnetcore-runtime + +LABEL com.bitwarden.product="bitwarden" + +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + gosu \ + && rm -rf /var/lib/apt/lists/* + +ENV ASPNETCORE_URLS http://+:5000 +WORKDIR /app +EXPOSE 5000 +COPY obj/Docker/publish . +COPY entrypoint.sh / +RUN chmod +x /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/src/Notifications/build.sh b/src/Notifications/build.sh new file mode 100644 index 0000000000..218aef9a8f --- /dev/null +++ b/src/Notifications/build.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +set -e + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +echo -e "\n## Building Notifications" + +echo -e "\nBuilding app" +echo ".NET Core version $(dotnet --version)" +echo "Restore" +dotnet restore $DIR/Notifications.csproj +echo "Clean" +dotnet clean $DIR/Notifications.csproj -c "Release" -o $DIR/obj/Docker/publish +echo "Publish" +dotnet publish $DIR/Notifications.csproj -c "Release" -o $DIR/obj/Docker/publish + +echo -e "\nBuilding docker image" +docker --version +docker build -t bitwarden/notifications $DIR/. diff --git a/src/Notifications/entrypoint.sh b/src/Notifications/entrypoint.sh new file mode 100644 index 0000000000..84874e2447 --- /dev/null +++ b/src/Notifications/entrypoint.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +# Setup + +GROUPNAME="bitwarden" +USERNAME="bitwarden" + +LUID=${LOCAL_UID:-0} +LGID=${LOCAL_GID:-0} + +# Step down from host root to well-known nobody/nogroup user + +if [ $LUID -eq 0 ] +then + LUID=65534 +fi +if [ $LGID -eq 0 ] +then + LGID=65534 +fi + +# Create user and group + +groupadd -o -g $LGID $GROUPNAME >/dev/null 2>&1 || +groupmod -o -g $LGID $GROUPNAME >/dev/null 2>&1 +useradd -o -u $LUID -g $GROUPNAME -s /bin/false $USERNAME >/dev/null 2>&1 || +usermod -o -u $LUID -g $GROUPNAME -s /bin/false $USERNAME >/dev/null 2>&1 +mkhomedir_helper $USERNAME + +# The rest... + +chown -R $USERNAME:$GROUPNAME /app +mkdir -p /etc/bitwarden/logs +mkdir -p /etc/bitwarden/ca-certificates +chown -R $USERNAME:$GROUPNAME /etc/bitwarden + +cp /etc/bitwarden/ca-certificates/*.crt /usr/local/share/ca-certificates/ >/dev/null 2>&1 \ + && update-ca-certificates + +exec gosu $USERNAME:$GROUPNAME dotnet /app/Notifications.dll diff --git a/util/Setup/DockerComposeBuilder.cs b/util/Setup/DockerComposeBuilder.cs index 56eff7815b..90c1640435 100644 --- a/util/Setup/DockerComposeBuilder.cs +++ b/util/Setup/DockerComposeBuilder.cs @@ -186,9 +186,24 @@ services: image: bitwarden/icons:{CoreVersion} container_name: bitwarden-icons restart: always + volumes: + - ../ca-certificates:/etc/bitwarden/ca-certificates + - ../logs/icons:/etc/bitwarden/logs env_file: - ../env/uid.env + notifications: + image: bitwarden/notifications:{CoreVersion} + container_name: bitwarden-notifications + restart: always + volumes: + - ../ca-certificates:/etc/bitwarden/ca-certificates + - ../logs/notifications:/etc/bitwarden/logs + env_file: + - global.env + - ../env/uid.env + - ../env/global.override.env + nginx: image: bitwarden/nginx:{CoreVersion} container_name: bitwarden-nginx diff --git a/util/Setup/NginxConfigBuilder.cs b/util/Setup/NginxConfigBuilder.cs index 203455618e..269207a692 100644 --- a/util/Setup/NginxConfigBuilder.cs +++ b/util/Setup/NginxConfigBuilder.cs @@ -172,6 +172,10 @@ server {{ proxy_pass http://icons:5000/; }} + location /notifications/ {{ + proxy_pass http://notifications:5000/; + }} + location /admin {{ proxy_pass http://admin:5000; }}