Browse Source

revamping the build scripts (#1620)

pull/1625/head
Joseph Flinn 4 years ago committed by GitHub
parent
commit
ee7b608a46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      .gitignore
  2. 4
      bitwarden_license/src/Sso/build.sh
  3. 48
      scripts/build
  4. 93
      scripts/build-docker
  5. 42
      scripts/deploy-qa
  6. 6
      src/Admin/appsettings.QA.json
  7. 4
      src/Admin/build.sh
  8. 6115
      src/Admin/package-lock.json
  9. 6
      src/Api/appsettings.QA.json
  10. 4
      src/Api/build.sh
  11. 6
      src/Billing/appsettings.QA.json
  12. 6
      src/Events/appsettings.QA.json
  13. 4
      src/Events/build.sh
  14. 6
      src/EventsProcessor/appsettings.QA.json
  15. 7
      src/EventsProcessor/build.sh
  16. 6
      src/Icons/appsettings.QA.json
  17. 7
      src/Icons/build.sh
  18. 6
      src/Identity/appsettings.QA.json
  19. 4
      src/Identity/build.sh
  20. 6
      src/Notifications/appsettings.QA.json
  21. 7
      src/Notifications/build.sh
  22. 10
      util/Attachments/build.sh
  23. 10
      util/MsSql/build.sh
  24. 16
      util/Nginx/build.sh
  25. 4
      util/Server/build.sh
  26. 4
      util/Setup/build.sh

10
.gitignore vendored

@ -215,3 +215,13 @@ bitwarden_license/src/Sso/wwwroot/css @@ -215,3 +215,13 @@ bitwarden_license/src/Sso/wwwroot/css
**/CoverageOutput/
.idea/*
**/**.swp
src/Admin/Admin.zip
src/Api/Api.zip
src/Billing/Billing.zip
src/Events/Events.zip
src/EventsProcessor/EventsProcessor.zip
src/Identity/Identity.zip
src/Notifications/Notifications.zip
bitwarden_license/src/Portal/Portal.zip
bitwarden_license/src/Sso/Sso.zip

4
bitwarden_license/src/Sso/build.sh

@ -19,7 +19,3 @@ cd "$CUR_DIR" @@ -19,7 +19,3 @@ cd "$CUR_DIR"
gulp --gulpfile "$DIR/gulpfile.js" build
echo "Publish"
dotnet publish "$DIR/Sso.csproj" -c "Release" -o "$DIR/obj/build-output/publish"
echo -e "\nBuilding docker image"
docker --version
docker build -t bitwarden/sso "$DIR/."

48
scripts/build

@ -0,0 +1,48 @@ @@ -0,0 +1,48 @@
#!/bin/bash
##############################
# Builds a specified service
# Arguments:
# 1: Project to build
# 2: Project path
##############################
build() {
local project=$1
local project_dir=$2
echo "Building $project"
echo "Build Path: $project_dir"
echo "=================="
chmod u+x "$project_dir/build.sh"
"$project_dir/build.sh"
}
# Get Project
PROJECT=$1; shift
case "$PROJECT" in
"api" | "Api") build Api $PWD/src/Api ;;
"admin" | "Admin") build Admin $PWD/src/Admin ;;
"identity" | "Identity") build Identity $PWD/src/Identity ;;
"events" | "Events") build Events $PWD/src/Events ;;
"billing" | "Billing") build Billing $PWD/src/Billing ;;
"sso" | "Sso") build Sso $PWD/bitwarden_license/src/Sso ;;
"server" | "Server") build Server $PWD/util/Server ;;
"icons" | "Icons") build Icons $PWD/src/Icons ;;
"notifications" | "Notifications") build Notifications $PWD/src/Notifications ;;
"setup" | "Setup") build Setup $PWD/util/Setup ;;
"eventsprocessor" | "EventsProcessor") build EventsProcessor $PWD/src/EventsProcessor ;;
"")
build Api $PWD/src/Api
build Admin $PWD/src/Admin
build Identity $PWD/src/Identity
build Events $PWD/src/Events
build Billing $PWD/src/Billing
build Sso $PWD/bitwarden_license/src/Sso
build Server $PWD/util/Server
build Icons $PWD/src/Icons
build Notifications $PWD/src/Notifications
build EventsProcessor $PWD/src/EventsProcessor
;;
esac

93
scripts/build-docker

@ -0,0 +1,93 @@ @@ -0,0 +1,93 @@
#!/bin/bash
##############################
# Builds the docker image from a pre-built build directory
# Arguments:
# 1: Project Name
# 2: Project Directory
# 3: Docker Tag
# 4: Docker push
# Outputs:
# Output to STDOUT or STDERR.
# Returns:
# Returned values other than the default exit status of the last command run.
##############################
docker_build() {
local project_name=$1
local project_dir=$2
local docker_tag=$3
local docker_push=$4
local project_name_lower=$(echo "$project_name" | awk '{print tolower($0)}')
echo "Building docker image: bitwarden/$project_name_lower:$docker_tag"
echo "=============================="
if [ "$project_name_lower" == "k8s-proxy" ]; then
docker build -f $project_dir/Dockerfile-k8s -t bitwarden/$project_name_lower:$docker_tag $project_dir
fi
docker build -t bitwarden/$project_name_lower:$docker_tag $project_dir
if [ "$docker_push" == "1" ]; then
docker push bitwarden/$project_name_lower:$docker_tag $project_dir
fi
}
# Get Project
PROJECT=$1; shift
# Get Params
TAG="latest"
PUSH=0
while [ ! $# -eq 0 ]; do
case "$1" in
-t | --tag)
if [[ $2 ]]; then
TAG="$2"
shift
else
exp "--tag requires a value"
fi
;;
--push) PUSH=1 ;;
-h | --help ) usage && exit ;;
*) usage && exit ;;
esac
shift
done
case "$PROJECT" in
"api" | "Api") docker_build Api $PWD/src/Api $TAG $PUSH ;;
"admin" | "Admin") docker_build Admin $PWD/src/Admin $TAG $PUSH ;;
"identity" | "Identity") docker_build Identity $PWD/src/Identity $TAG $PUSH ;;
"events" | "Events") docker_build Events $PWD/src/Events $TAG $PUSH ;;
#"billing" | "Billing") docker_build Billing $PWD/src/Billing $TAG $PUSH ;;
"sso" | "Sso") docker_build Sso $PWD/bitwarden_license/src/Sso $TAG $PUSH ;;
"server" | "Server") docker_build Server $PWD/util/Server $TAG $PUSH ;;
"nginx" | "Nginx") docker_build Nginx $PWD/util/Nginx $TAG $PUSH ;;
"k8s-proxy" | "K8s-Proxy") docker_build K8s-Proxy $PWD/util/Nginx $TAG $PUSH ;;
"attachments" | "Attachments") docker_build Attachemnts $PWD/util/Attachments $TAG $PUSH ;;
"icons" | "Icons") docker_build Icons $PWD/src/Icons $TAG $PUSH ;;
"notifications" | "Notifications") docker_build Notifications $PWD/src/Notifications $TAG $PUSH ;;
"mssql" | "MsSql" | "Mssql") docker_build MsSql $PWD/util/MsSql $TAG $PUSH ;;
"seteup" | "Setup") docker_build Setup $PWD/util/Setup $TAG $PUSH
"eventsprocessor" | "EventsProcessor") docker_build EventsProcessor $PWD/src/EventsProcessor $TAG $PUSH
"")
docker_build Api $PWD/src/Api $TAG $PUSH
docker_build Admin $PWD/src/Admin $TAG $PUSH
docker_build Identity $PWD/src/Identity $TAG $PUSH
docker_build Events $PWD/src/Events $TAG $PUSH
#docker_build Billing $PWD/src/Billing $TAG $PUSH
docker_build Sso $PWD/bitwarden_license/src/Sso $TAG $PUSH
docker_build Server $PWD/util/Server $TAG $PUSH
docker_build Nginx $PWD/util/Nginx $TAG $PUSH
docker_build Attachemnts $PWD/util/Attachments $TAG $PUSH
docker_build Icons $PWD/src/Icons $TAG $PUSH
docker_build Notifications $PWD/src/Notifications $TAG $PUSH
docker_build MsSql $PWD/util/MsSql $TAG $PUSH$TAG $PUSH
docker_build Setup $PWD/util/Setup $TAG $PUSH
docker_build EventsProcessor $PWD/src/EventsProcessor $TAG $PUSH
;;
esac

42
scripts/deploy-qa

@ -0,0 +1,42 @@ @@ -0,0 +1,42 @@
#!/bin/bash
##############################
# Builds the docker image from a pre-built build directory
# Arguments:
# 1: Project Name
# 2: Project Directory
# 3: Docker Tag
# 4: Docker push
##############################
deploy_app_service() {
local project_name=$1
local project_dir=$2
local project_name_lower=$(echo "$project_name" | awk '{print tolower($0)}')
local webapp_name=$(az keyvault secret show --vault-name bitwarden-qa-kv --name appservices-$project_name_lower-webapp-name --query value --output tsv)
cd $project_dir/obj/build-output/publish
zip -r $project_name.zip .
mv $project_name.zip ../../../
#az webapp deploy --resource-group bw-qa-env --name $webapp_name \
# --src-path $project_name.zip --verbose --type zip --restart true --subscription "Bitwarden Test"
}
PROJECT=$1; shift
case "$PROJECT" in
"api" | "Api") deploy_app_service Api $PWD/src/Api ;;
"admin" | "Admin") deploy_app_service Admin $PWD/src/Admin ;;
"identity" | "Identity") deploy_app_service Identity $PWD/src/Identity ;;
"events" | "Events") deploy_app_service Events $PWD/src/Events ;;
"billing" | "Billing") deploy_app_service Billing $PWD/src/Billing ;;
"sso" | "Sso") deploy_app_service Sso $PWD/bitwarden_license/src/Sso ;;
"")
deploy_app_service Api $PWD/src/Api
deploy_app_service Admin $PWD/src/Admin
deploy_app_service Identity $PWD/src/Identity
deploy_app_service Events $PWD/src/Events
deploy_app_service Billing $PWD/src/Billing
deploy_app_service Sso $PWD/bitwarden_license/src/Sso
;;
esac

6
src/Admin/appsettings.QA.json

@ -28,9 +28,9 @@ @@ -28,9 +28,9 @@
"Console": {
"IncludeScopes": true,
"LogLevel": {
"Default": "Warning",
"System": "Warning",
"Microsoft": "Warning",
"Default": "Debug",
"System": "Debug",
"Microsoft": "Debug",
"Microsoft.Hosting.Lifetime": "Information"
}
}

4
src/Admin/build.sh

@ -19,7 +19,3 @@ cd "$CUR_DIR" @@ -19,7 +19,3 @@ cd "$CUR_DIR"
gulp --gulpfile "$DIR/gulpfile.js" build
echo "Publish"
dotnet publish "$DIR/Admin.csproj" -c "Release" -o "$DIR/obj/build-output/publish"
echo -e "\nBuilding docker image"
docker --version
docker build -t bitwarden/admin "$DIR/."

6115
src/Admin/package-lock.json generated

File diff suppressed because it is too large Load Diff

6
src/Api/appsettings.QA.json

@ -31,9 +31,9 @@ @@ -31,9 +31,9 @@
"Console": {
"IncludeScopes": true,
"LogLevel": {
"Default": "Warning",
"System": "Warning",
"Microsoft": "Warning",
"Default": "Debug",
"System": "Debug",
"Microsoft": "Debug",
"Microsoft.Hosting.Lifetime": "Information"
}
}

4
src/Api/build.sh

@ -13,7 +13,3 @@ echo "Clean" @@ -13,7 +13,3 @@ echo "Clean"
dotnet clean "$DIR/Api.csproj" -c "Release" -o "$DIR/obj/build-output/publish"
echo "Publish"
dotnet publish "$DIR/Api.csproj" -c "Release" -o "$DIR/obj/build-output/publish"
echo -e "\nBuilding docker image"
docker --version
docker build -t bitwarden/api "$DIR/."

6
src/Billing/appsettings.QA.json

@ -37,9 +37,9 @@ @@ -37,9 +37,9 @@
"Console": {
"IncludeScopes": true,
"LogLevel": {
"Default": "Warning",
"System": "Warning",
"Microsoft": "Warning",
"Default": "Debug",
"System": "Debug",
"Microsoft": "Debug",
"Microsoft.Hosting.Lifetime": "Information"
}
}

6
src/Events/appsettings.QA.json

@ -25,9 +25,9 @@ @@ -25,9 +25,9 @@
"Console": {
"IncludeScopes": true,
"LogLevel": {
"Default": "Warning",
"System": "Warning",
"Microsoft": "Warning",
"Default": "Debug",
"System": "Debug",
"Microsoft": "Debug",
"Microsoft.Hosting.Lifetime": "Information"
}
}

4
src/Events/build.sh

@ -13,7 +13,3 @@ echo "Clean" @@ -13,7 +13,3 @@ echo "Clean"
dotnet clean "$DIR/Events.csproj" -c "Release" -o "$DIR/obj/build-output/publish"
echo "Publish"
dotnet publish "$DIR/Events.csproj" -c "Release" -o "$DIR/obj/build-output/publish"
echo -e "\nBuilding docker image"
docker --version
docker build -t bitwarden/events "$DIR/."

6
src/EventsProcessor/appsettings.QA.json

@ -9,9 +9,9 @@ @@ -9,9 +9,9 @@
"Console": {
"IncludeScopes": true,
"LogLevel": {
"Default": "Warning",
"System": "Warning",
"Microsoft": "Warning",
"Default": "Debug",
"System": "Debug",
"Microsoft": "Debug",
"Microsoft.Hosting.Lifetime": "Information"
}
}

7
src/EventsProcessor/build.sh

@ -13,10 +13,3 @@ echo "Clean" @@ -13,10 +13,3 @@ echo "Clean"
dotnet clean "$DIR/EventsProcessor.csproj" -c "Release" -o "$DIR/obj/build-output/publish"
echo "Publish"
dotnet publish "$DIR/EventsProcessor.csproj" -c "Release" -o "$DIR/obj/build-output/publish"
if [ "$1" != "nodocker" ]
then
echo -e "\nBuilding docker image"
docker --version
docker build -t bitwarden/event-processor:rc "$DIR/."
fi

6
src/Icons/appsettings.QA.json

@ -9,9 +9,9 @@ @@ -9,9 +9,9 @@
"Console": {
"IncludeScopes": true,
"LogLevel": {
"Default": "Warning",
"System": "Warning",
"Microsoft": "Warning",
"Default": "Debug",
"System": "Debug",
"Microsoft": "Debug",
"Microsoft.Hosting.Lifetime": "Information"
}
}

7
src/Icons/build.sh

@ -13,10 +13,3 @@ echo "Clean" @@ -13,10 +13,3 @@ echo "Clean"
dotnet clean "$DIR/Icons.csproj" -c "Release" -o "$DIR/obj/build-output/publish"
echo "Publish"
dotnet publish "$DIR/Icons.csproj" -c "Release" -o "$DIR/obj/build-output/publish"
if [ "$1" != "nodocker" ]
then
echo -e "\nBuilding docker image"
docker --version
docker build -t bitwarden/icons "$DIR/."
fi

6
src/Identity/appsettings.QA.json

@ -28,9 +28,9 @@ @@ -28,9 +28,9 @@
"Console": {
"IncludeScopes": true,
"LogLevel": {
"Default": "Warning",
"System": "Warning",
"Microsoft": "Warning",
"Default": "Debug",
"System": "Debug",
"Microsoft": "Debug",
"Microsoft.Hosting.Lifetime": "Information"
}
}

4
src/Identity/build.sh

@ -13,7 +13,3 @@ echo "Clean" @@ -13,7 +13,3 @@ echo "Clean"
dotnet clean "$DIR/Identity.csproj" -c "Release" -o "$DIR/obj/build-output/publish"
echo "Publish"
dotnet publish "$DIR/Identity.csproj" -c "Release" -o "$DIR/obj/build-output/publish"
echo -e "\nBuilding docker image"
docker --version
docker build -t bitwarden/identity "$DIR/."

6
src/Notifications/appsettings.QA.json

@ -25,9 +25,9 @@ @@ -25,9 +25,9 @@
"Console": {
"IncludeScopes": true,
"LogLevel": {
"Default": "Warning",
"System": "Warning",
"Microsoft": "Warning",
"Default": "Debug",
"System": "Debug",
"Microsoft": "Debug",
"Microsoft.Hosting.Lifetime": "Information"
}
}

7
src/Notifications/build.sh

@ -13,10 +13,3 @@ echo "Clean" @@ -13,10 +13,3 @@ echo "Clean"
dotnet clean "$DIR/Notifications.csproj" -c "Release" -o "$DIR/obj/build-output/publish"
echo "Publish"
dotnet publish "$DIR/Notifications.csproj" -c "Release" -o "$DIR/obj/build-output/publish"
if [ "$1" != "nodocker" ]
then
echo -e "\nBuilding docker image"
docker --version
docker build -t bitwarden/notifications "$DIR/."
fi

10
util/Attachments/build.sh

@ -1,10 +0,0 @@ @@ -1,10 +0,0 @@
#!/usr/bin/env bash
set -e
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo -e "\n## Building Attachments"
echo -e "\nBuilding docker image"
docker --version
docker build -t bitwarden/attachments "$DIR/."

10
util/MsSql/build.sh

@ -1,10 +0,0 @@ @@ -1,10 +0,0 @@
#!/usr/bin/env bash
set -e
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo -e "\n## Building MsSql"
echo -e "\nBuilding docker image"
docker --version
docker build -t bitwarden/mssql "$DIR/."

16
util/Nginx/build.sh

@ -1,16 +0,0 @@ @@ -1,16 +0,0 @@
#!/usr/bin/env bash
set -e
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo -e "\n## Building Nginx"
echo -e "\nBuilding docker image"
docker --version
docker build -t bitwarden/nginx "$DIR/."
echo -e "\n## Building k8s-proxy"
echo -e "\nBuilding docker image"
docker build -f $DIR/Dockerfile-k8s -t bitwarden/k8s-proxy "$DIR/."

4
util/Server/build.sh

@ -13,7 +13,3 @@ echo "Clean" @@ -13,7 +13,3 @@ echo "Clean"
dotnet clean "$DIR/Server.csproj" -c "Release" -o "$DIR/obj/build-output/publish"
echo "Publish"
dotnet publish "$DIR/Server.csproj" -c "Release" -o "$DIR/obj/build-output/publish"
echo -e "\nBuilding docker image"
docker --version
docker build -t bitwarden/server "$DIR/."

4
util/Setup/build.sh

@ -13,7 +13,3 @@ echo "Clean" @@ -13,7 +13,3 @@ echo "Clean"
dotnet clean "$DIR/Setup.csproj" -c "Release" -o "$DIR/obj/build-output/publish"
echo "Publish"
dotnet publish "$DIR/Setup.csproj" -c "Release" -o "$DIR/obj/build-output/publish"
echo -e "\nBuilding docker image"
docker --version
docker build -t bitwarden/setup "$DIR/."

Loading…
Cancel
Save