From ca496b0b49e1cda6f67e1c17bc9dd869c406b683 Mon Sep 17 00:00:00 2001 From: Marc Cataford Date: Fri, 15 Dec 2023 15:17:36 -0500 Subject: [PATCH] feat(bitwarden): move Bitwarden setup to task model fix: newline escape --- .../Dockerfile-bitwarden-app} | 0 .../{ => bitwarden}/Dockerfile-bitwarden-db | 0 services/bitwarden/build.sh | 6 +++++ services/bitwarden/constants.sh | 8 +++++++ services/bitwarden/start.sh | 23 +++++++++++++++++++ services/bitwarden/stop.sh | 6 +++++ 6 files changed, 43 insertions(+) rename services/{Dockerfile-bitwarden => bitwarden/Dockerfile-bitwarden-app} (100%) rename services/{ => bitwarden}/Dockerfile-bitwarden-db (100%) create mode 100644 services/bitwarden/build.sh create mode 100644 services/bitwarden/constants.sh create mode 100644 services/bitwarden/start.sh create mode 100644 services/bitwarden/stop.sh diff --git a/services/Dockerfile-bitwarden b/services/bitwarden/Dockerfile-bitwarden-app similarity index 100% rename from services/Dockerfile-bitwarden rename to services/bitwarden/Dockerfile-bitwarden-app diff --git a/services/Dockerfile-bitwarden-db b/services/bitwarden/Dockerfile-bitwarden-db similarity index 100% rename from services/Dockerfile-bitwarden-db rename to services/bitwarden/Dockerfile-bitwarden-db diff --git a/services/bitwarden/build.sh b/services/bitwarden/build.sh new file mode 100644 index 0000000..59dd88f --- /dev/null +++ b/services/bitwarden/build.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +source constants.sh + +docker build -t $DB_IMAGE_NAME:dev -f Dockerfile-bitwarden-db . +docker build -t $APP_IMAGE_NAME:dev -f Dockerfile-bitwarden-app . diff --git a/services/bitwarden/constants.sh b/services/bitwarden/constants.sh new file mode 100644 index 0000000..2df6d9c --- /dev/null +++ b/services/bitwarden/constants.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +export APP_NAME="bitwarden" +export APP_CONTAINER_NAME=$APP_NAME-app +export APP_IMAGE_NAME=$CONTAINER_NAME_PREFIX-$APP_CONTAINER_NAME +export DB_CONTAINER_NAME=$APP_NAME-db +export DB_IMAGE_NAME=$CONTAINER_NAME_PREFIX-$DB_CONTAINER_NAME +export NETWORK_NAME=$APP_NAME-local diff --git a/services/bitwarden/start.sh b/services/bitwarden/start.sh new file mode 100644 index 0000000..a281880 --- /dev/null +++ b/services/bitwarden/start.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +source constants.sh + +docker network create $NETWORK_NAME || echo "Network $NETWORK_NAME already exists" + +docker run \ + --detach \ + --network $NETWORK_NAME \ + --name $DB_CONTAINER_NAME \ + --env-file $ENV_FILE_DIR/bitwarden-db.env \ + --mount type=bind,source=$APP_DATA_DIR/bitwarden/db,target=/var/lib/mysql \ + $DB_IMAGE_NAME:dev + +docker run \ + --detach \ + --network $NETWORK_NAME \ + --name $APP_CONTAINER_NAME \ + --env-file $ENV_FILE_DIR/bitwarden-web.env \ + --publish 8080:8080 \ + --mount type=bind,source=$APP_DATA_DIR/bitwarden/config,target=/etc/bitwarden \ + --mount type=bind,source=$APP_DATA_DIR/bitwarden/logs,target=/var/log/bitwarden \ + $APP_IMAGE_NAME:dev diff --git a/services/bitwarden/stop.sh b/services/bitwarden/stop.sh new file mode 100644 index 0000000..62c5c50 --- /dev/null +++ b/services/bitwarden/stop.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +source constants.sh + +docker rm -f $APP_CONTAINER_NAME +docker rm -f $DB_CONTAINER_NAME