Browse Source

[PM-368] Setup container attaches itself to docker_internal network during database update (#300)

* fix: db migration connectivity issues when using an external db

* Update run.ps1

Co-authored-by: Justin Baur <19896123+justindbaur@users.noreply.github.com>

* rm semicolon in case connection this is at the end of the connection string

* fix: 'no such image: mssql' when mssql container is not present

---------

Co-authored-by: Justin Baur <19896123+justindbaur@users.noreply.github.com>
pull/303/head
tangowithfoxtrot 1 year ago committed by GitHub
parent
commit
a25133b7e9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 12
      run.ps1
  2. 11
      run.sh

12
run.ps1

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
param (
[string]$outputDir = "../.",
[string]$outputDir = "..\.",
[string]$coreVersion = "latest",
[string]$webVersion = "latest",
[string]$keyConnectorVersion = "latest",
@ -18,6 +18,7 @@ param ( @@ -18,6 +18,7 @@ param (
# Setup
$dockerDir = "${outputDir}\docker"
$envDir = "${outputDir}\env"
$setupQuiet = 0
$qFlag = ""
$quietPullFlag = ""
@ -167,8 +168,15 @@ function Force-Update-Lets-Encrypt { @@ -167,8 +168,15 @@ function Force-Update-Lets-Encrypt {
function Update-Database {
Pull-Setup
Docker-Compose-Files
# only use container network driver if using the included mssql image
$dockerNetworkArgs = ""
if (Select-String -Path ${envDir}\global.override.env -Pattern 'Data Source=tcp:mssql,1433') {
$mssqlId = docker-compose ps -q mssql
docker run -it --rm --name setup --network container:$mssqlId `
$dockerNetworkArgs = "--network container:$mssqlId"
}
docker run -it --rm --name setup $dockerNetworkArgs `
-v ${outputDir}:/bitwarden bitwarden/setup:$coreVersion `
dotnet Setup.dll -update 1 -db 1 -os win -corev $coreVersion -webv $webVersion `
-keyconnectorv $keyConnectorVersion -q $setupQuiet

11
run.sh

@ -187,8 +187,15 @@ function forceUpdateLetsEncrypt() { @@ -187,8 +187,15 @@ function forceUpdateLetsEncrypt() {
function updateDatabase() {
pullSetup
dockerComposeFiles
# only use container network driver if using the included mssql image
if grep -q 'Data Source=tcp:mssql,1433' "$ENV_DIR/global.override.env"
then
MSSQL_ID=$($dccmd ps -q mssql)
docker run -i --rm --name setup --network container:$MSSQL_ID \
local docker_network_args="--network container:$MSSQL_ID"
fi
docker run -i --rm --name setup $docker_network_args \
-v $OUTPUT_DIR:/bitwarden --env-file $ENV_DIR/uid.env bitwarden/setup:$COREVERSION \
dotnet Setup.dll -update 1 -db 1 -os $OS -corev $COREVERSION -webv $WEBVERSION -keyconnectorv $KEYCONNECTORVERSION
echo "Database update complete"
@ -250,7 +257,6 @@ function uninstall() { @@ -250,7 +257,6 @@ function uninstall() {
read UNINSTALL_ACTION
fi
if [ "$UNINSTALL_ACTION" == "y" ]
then
echo "Uninstalling Bitwarden..."
@ -272,7 +278,6 @@ function uninstall() { @@ -272,7 +278,6 @@ function uninstall() {
dockerPrune
echo -e -n "${CYAN}Bitwarden uninstall complete! ${NC}"
fi
}
function printEnvironment() {

Loading…
Cancel
Save