2019-07-07 18:18:27 +02:00
|
|
|
#!/bin/sh
|
2017-10-22 19:08:50 +02:00
|
|
|
|
2019-07-07 18:18:27 +02:00
|
|
|
DIR=`dirname "$0"`
|
|
|
|
DIR=`exec 2>/dev/null;(cd -- "$DIR") && cd -- "$DIR"|| cd "$DIR"; unset PWD; /usr/bin/pwd || /bin/pwd || pwd`
|
2020-09-10 21:36:44 +02:00
|
|
|
BW_VERSION="$(curl --silent https://raw.githubusercontent.com/bitwarden/server/master/scripts/bitwarden.sh | grep 'COREVERSION="' | sed 's/^[^"]*"//; s/".*//')"
|
|
|
|
|
|
|
|
echo "Building BitBetter for BitWarden version $BW_VERSION"
|
2019-06-19 15:34:33 +02:00
|
|
|
|
2019-07-07 18:18:27 +02:00
|
|
|
# If there aren't any keys, generate them first.
|
|
|
|
[ -e "$DIR/.keys/cert.cert" ] || "$DIR/.keys/generate-keys.sh"
|
2017-10-29 17:57:49 +01:00
|
|
|
|
2019-07-07 18:18:27 +02:00
|
|
|
[ -e "$DIR/src/bitBetter/.keys" ] || mkdir "$DIR/src/bitBetter/.keys"
|
2017-10-29 17:57:49 +01:00
|
|
|
|
2019-07-07 18:18:27 +02:00
|
|
|
cp "$DIR/.keys/cert.cert" "$DIR/src/bitBetter/.keys"
|
2017-10-29 17:57:49 +01:00
|
|
|
|
2021-08-31 10:18:29 +02:00
|
|
|
docker run --rm -v "$DIR/src/bitBetter:/bitBetter" -w=/bitBetter mcr.microsoft.com/dotnet/sdk:5.0 sh build.sh
|
2017-10-29 17:57:49 +01:00
|
|
|
|
2020-09-20 00:36:15 +02:00
|
|
|
docker build --no-cache --build-arg BITWARDEN_TAG=bitwarden/api:$BW_VERSION --label com.bitwarden.product="bitbetter" -t bitbetter/api "$DIR/src/bitBetter" # --squash
|
|
|
|
docker build --no-cache --build-arg BITWARDEN_TAG=bitwarden/identity:$BW_VERSION --label com.bitwarden.product="bitbetter" -t bitbetter/identity "$DIR/src/bitBetter" # --squash
|
2019-05-26 00:12:10 +02:00
|
|
|
|
2020-09-10 21:36:44 +02:00
|
|
|
docker tag bitbetter/api bitbetter/api:latest
|
|
|
|
docker tag bitbetter/identity bitbetter/identity:latest
|
|
|
|
docker tag bitbetter/api bitbetter/api:$BW_VERSION
|
|
|
|
docker tag bitbetter/identity bitbetter/identity:$BW_VERSION
|
2017-10-29 17:57:49 +01:00
|
|
|
|
2020-09-20 00:36:15 +02:00
|
|
|
# Remove old instances of the image after a successful build.
|
|
|
|
ids=$( docker images bitbetter/* | grep -E -v -- "CREATED|latest|${BW_VERSION}" | awk '{ print $3 }' )
|
|
|
|
[ -n "$ids" ] && docker rmi $ids || true
|