mirror of
https://github.com/bitwarden/server.git
synced 2024-11-22 12:15:36 +01:00
fefda383d1
* Updated run.sh to support default override This is equivalent to run docker-compose in the directory of the project (here "docker"). See: https://docs.docker.com/compose/extends/ Override allows to change some paramaters and extend the original compose file to your own environment (network config, CPU/RAM caps,...) * Updated run.ps1 to support docker override file Same as run.sh * Added conditionals for override file absence I misunderstood the documentation, that file must exist if file is specified on command line, added conditionals to support that case * Update run.ps1 to test for override file presence Same as .sh
111 lines
2.8 KiB
PowerShell
111 lines
2.8 KiB
PowerShell
param (
|
|
[string]$outputDir = "../.",
|
|
[string]$coreVersion = "latest",
|
|
[string]$webVersion = "latest",
|
|
[switch] $start,
|
|
[switch] $restart,
|
|
[switch] $stop,
|
|
[switch] $pull,
|
|
[switch] $updatedb,
|
|
[switch] $update
|
|
)
|
|
|
|
# Setup
|
|
|
|
$dockerDir="${outputDir}\docker"
|
|
|
|
# Functions
|
|
|
|
function Docker-Compose-Up {
|
|
if(Test-Path -Path "${dockerDir}\docker-compose.override.yml" -PathType leaf) {
|
|
docker-compose -f ${dockerDir}\docker-compose.yml -f ${dockerDir}\docker-compose.override.yml up -d
|
|
}
|
|
else {
|
|
docker-compose -f ${dockerDir}\docker-compose.yml up -d
|
|
}
|
|
}
|
|
|
|
function Docker-Compose-Down {
|
|
if(Test-Path -Path "${dockerDir}\docker-compose.override.yml" -PathType leaf) {
|
|
docker-compose -f ${dockerDir}\docker-compose.yml -f ${dockerDir}\docker-compose.override.yml down
|
|
}
|
|
else {
|
|
docker-compose -f ${dockerDir}\docker-compose.yml down
|
|
}
|
|
}
|
|
|
|
function Docker-Compose-Pull {
|
|
if(Test-Path -Path "${dockerDir}\docker-compose.override.yml" -PathType leaf) {
|
|
docker-compose -f ${dockerDir}\docker-compose.yml -f ${dockerDir}\docker-compose.override.yml pull
|
|
}
|
|
else {
|
|
docker-compose -f ${dockerDir}\docker-compose.yml pull
|
|
}
|
|
|
|
}
|
|
|
|
function Docker-Prune {
|
|
docker image prune -f
|
|
}
|
|
|
|
function Update-Lets-Encrypt {
|
|
if(Test-Path -Path "${outputDir}\letsencrypt\live") {
|
|
docker pull certbot/certbot
|
|
docker run -it --rm --name certbot -p 443:443 -p 80:80 -v $outputDir/letsencrypt:/etc/letsencrypt/ certbot/certbot `
|
|
renew --logs-dir /etc/letsencrypt/logs
|
|
}
|
|
}
|
|
|
|
function Update-Database {
|
|
Pull-Setup
|
|
docker run -it --rm --name setup --network container:bitwarden-mssql -v ${outputDir}:/bitwarden bitwarden/setup:$coreVersion `
|
|
dotnet Setup.dll -update 1 -db 1 -os win -corev $coreVersion -webv $webVersion
|
|
echo "Database update complete"
|
|
}
|
|
|
|
function Update {
|
|
Pull-Setup
|
|
docker run -it --rm --name setup -v ${outputDir}:/bitwarden bitwarden/setup:$coreVersion `
|
|
dotnet Setup.dll -update 1 -os win -corev $coreVersion -webv $webVersion
|
|
}
|
|
|
|
function Print-Environment {
|
|
Pull-Setup
|
|
docker run -it --rm --name setup -v ${outputDir}:/bitwarden bitwarden/setup:$coreVersion `
|
|
dotnet Setup.dll -printenv 1 -os win -corev $coreVersion -webv $webVersion
|
|
}
|
|
|
|
function Restart {
|
|
Docker-Compose-Down
|
|
Docker-Compose-Pull
|
|
Update-Lets-Encrypt
|
|
Docker-Compose-Up
|
|
Docker-Prune
|
|
Print-Environment
|
|
}
|
|
|
|
function Pull-Setup {
|
|
docker pull bitwarden/setup:$coreVersion
|
|
}
|
|
|
|
# Commands
|
|
|
|
if($start -Or $restart) {
|
|
Restart
|
|
}
|
|
elseif($pull) {
|
|
Docker-Compose-Pull
|
|
}
|
|
elseif($stop) {
|
|
Docker-Compose-Down
|
|
}
|
|
elseif($updatedb) {
|
|
Update-Database
|
|
}
|
|
elseif($update) {
|
|
Docker-Compose-Down
|
|
Update
|
|
Restart
|
|
Update-Database
|
|
}
|