diff --git a/build.sh b/build.sh index 829da5701a..f27be8711c 100644 --- a/build.sh +++ b/build.sh @@ -18,6 +18,7 @@ then docker push bitwarden/attachments:$TAG docker push bitwarden/icons:$TAG docker push bitwarden/notifications:$TAG + docker push bitwarden/events:$TAG docker push bitwarden/admin:$TAG docker push bitwarden/nginx:$TAG docker push bitwarden/mssql:$TAG @@ -34,6 +35,7 @@ then docker tag bitwarden/attachments bitwarden/attachments:$TAG docker tag bitwarden/icons bitwarden/icons:$TAG docker tag bitwarden/notifications bitwarden/notifications:$TAG + docker tag bitwarden/events bitwarden/events:$TAG docker tag bitwarden/admin bitwarden/admin:$TAG docker tag bitwarden/nginx bitwarden/nginx:$TAG docker tag bitwarden/mssql bitwarden/mssql:$TAG @@ -63,6 +65,9 @@ else chmod u+x $DIR/src/Notifications/build.sh $DIR/src/Notifications/build.sh + chmod u+x $DIR/src/Events/build.sh + $DIR/src/Events/build.sh + chmod u+x $DIR/src/Admin/build.sh $DIR/src/Admin/build.sh diff --git a/src/Events/.dockerignore b/src/Events/.dockerignore new file mode 100644 index 0000000000..7e37ce5d99 --- /dev/null +++ b/src/Events/.dockerignore @@ -0,0 +1,4 @@ +* +!obj/Docker/publish/* +!obj/Docker/empty/ +!entrypoint.sh diff --git a/src/Events/Dockerfile b/src/Events/Dockerfile new file mode 100644 index 0000000000..1beede9d48 --- /dev/null +++ b/src/Events/Dockerfile @@ -0,0 +1,18 @@ +FROM mcr.microsoft.com/dotnet/core/aspnet:2.1.10 + +LABEL com.bitwarden.product="bitwarden" + +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + gosu \ + libcurl3 \ + && rm -rf /var/lib/apt/lists/* + +ENV ASPNETCORE_URLS http://+:5000 +WORKDIR /app +EXPOSE 5000 +COPY obj/Docker/publish/Events . +COPY entrypoint.sh / +RUN chmod +x /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/src/Events/build.sh b/src/Events/build.sh new file mode 100644 index 0000000000..5f0c30a989 --- /dev/null +++ b/src/Events/build.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +set -e + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +echo -e "\n## Building Events" + +echo -e "\nBuilding app" +echo ".NET Core version $(dotnet --version)" +echo "Restore" +dotnet restore $DIR/Events.csproj +echo "Clean" +dotnet clean $DIR/Events.csproj -c "Release" -o $DIR/obj/Docker/publish/Events +echo "Publish" +dotnet publish $DIR/Events.csproj -c "Release" -o $DIR/obj/Docker/publish/Events + +echo -e "\nBuilding docker image" +docker --version +docker build -t bitwarden/events $DIR/. diff --git a/src/Events/entrypoint.sh b/src/Events/entrypoint.sh new file mode 100644 index 0000000000..1f382295a2 --- /dev/null +++ b/src/Events/entrypoint.sh @@ -0,0 +1,41 @@ +#!/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/core +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/Events.dll diff --git a/util/Setup/Templates/DockerCompose.hbs b/util/Setup/Templates/DockerCompose.hbs index 555bd24ff6..155b57f723 100644 --- a/util/Setup/Templates/DockerCompose.hbs +++ b/util/Setup/Templates/DockerCompose.hbs @@ -118,6 +118,18 @@ services: - ../env/uid.env - ../env/global.override.env + events: + image: bitwarden/events:{{{CoreVersion}}} + container_name: bitwarden-events + restart: always + volumes: + - ../ca-certificates:/etc/bitwarden/ca-certificates + - ../logs/events:/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/Templates/NginxConfig.hbs b/util/Setup/Templates/NginxConfig.hbs index c12fab4789..88f76e0d56 100644 --- a/util/Setup/Templates/NginxConfig.hbs +++ b/util/Setup/Templates/NginxConfig.hbs @@ -113,6 +113,10 @@ server { proxy_set_header Connection $http_connection; } + location /events/ { + proxy_pass http://events:5000/; + } + location /admin { proxy_pass http://admin:5000; {{#if Ssl}}