1
0
mirror of https://github.com/bitwarden/server.git synced 2024-12-27 17:47:37 +01:00

Merge pull request #756 from bitwarden/docker-validate-volumes

Create missing container volume directories if/when docker-compose fails to
This commit is contained in:
Matt Portune 2020-05-31 20:19:26 -04:00 committed by GitHub
commit ab24257f11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 50 additions and 0 deletions

View File

@ -76,6 +76,7 @@ function Install() {
function Docker-Compose-Up {
Docker-Compose-Files
Docker-Compose-Volumes
Invoke-Expression ("docker-compose up -d{0}" -f $quietPullFlag)
}
@ -99,6 +100,30 @@ function Docker-Compose-Files {
$env:COMPOSE_HTTP_TIMEOUT = "300"
}
function Docker-Compose-Volumes {
Create-Dir "core"
Create-Dir "core/attachments"
Create-Dir "logs"
Create-Dir "logs/admin"
Create-Dir "logs/api"
Create-Dir "logs/events"
Create-Dir "logs/icons"
Create-Dir "logs/identity"
Create-Dir "logs/mssql"
Create-Dir "logs/nginx"
Create-Dir "logs/notifications"
Create-Dir "mssql/backups"
Create-Dir "mssql/data"
}
function Create-Dir($str) {
$outPath = "${outputDir}/$str"
if (!(Test-Path -Path $outPath )) {
Write-Line "Creating directory $outPath"
New-Item -ItemType directory -Path $outPath | Out-Null
}
}
function Docker-Prune {
docker image prune --all --force --filter="label=com.bitwarden.product=bitwarden" `
--filter="label!=com.bitwarden.project=setup"

View File

@ -85,6 +85,7 @@ function install() {
function dockerComposeUp() {
dockerComposeFiles
dockerComposeVolumes
docker-compose up -d
}
@ -108,6 +109,30 @@ function dockerComposeFiles() {
export COMPOSE_HTTP_TIMEOUT="300"
}
function dockerComposeVolumes() {
createDir "core"
createDir "core/attachments"
createDir "logs"
createDir "logs/admin"
createDir "logs/api"
createDir "logs/events"
createDir "logs/icons"
createDir "logs/identity"
createDir "logs/mssql"
createDir "logs/nginx"
createDir "logs/notifications"
createDir "mssql/backups"
createDir "mssql/data"
}
function createDir() {
if [ ! -d "${OUTPUT_DIR}/$1" ]
then
echo "Creating directory $OUTPUT_DIR/$1"
mkdir -p $OUTPUT_DIR/$1
fi
}
function dockerPrune() {
docker image prune --all --force --filter="label=com.bitwarden.product=bitwarden" \
--filter="label!=com.bitwarden.project=setup"