1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-21 12:05:42 +01:00

Use Azure SQL Edge for development (#1709)

This commit is contained in:
Oscar Hinton 2021-11-24 19:08:36 +01:00 committed by GitHub
parent fa3f1ad0ce
commit 0ae9e28884
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 9 deletions

View File

@ -1,3 +1,5 @@
COMPOSE_PROJECT_NAME=BitwardenServer
# Ensure the MSSQL_PASSWORD is complex and follows the password policy defined at
# https://docs.microsoft.com/en-us/sql/relational-databases/security/password-policy?view=sql-server-ver15
MSSQL_PASSWORD=SET_A_PASSWORD_HERE_123
MAILCATCHER_PORT=1080

View File

@ -2,14 +2,14 @@ version: "3.9"
services:
mssql:
image: mcr.microsoft.com/mssql/server:2017-latest
image: mcr.microsoft.com/azure-sql-edge:latest
restart: always
environment:
ACCEPT_EULA: Y
SA_PASSWORD: ${MSSQL_PASSWORD}
MSSQL_SA_PASSWORD: ${MSSQL_PASSWORD}
MSSQL_PID: Developer
volumes:
- mssql_dev_data:/var/opt/mssql/data
- edgesql_dev_data:/var/opt/mssql
- ../util/Migrator:/mnt/migrator/
- ./helpers/mssql:/mnt/helpers
- ./.data/mssql:/mnt/data
@ -40,4 +40,4 @@ services:
- mail
volumes:
mssql_dev_data:
edgesql_dev_data:

8
dev/helpers/mssql/run_migrations.sh Normal file → Executable file
View File

@ -7,10 +7,10 @@ sleep 0.1;
MIGRATE_DIRECTORY="/mnt/migrator/DbScripts"
LAST_MIGRATION_FILE="/mnt/data/last_migration"
SERVER='localhost'
SERVER='mssql'
DATABASE="vault_dev"
USER="SA"
PASSWD=$SA_PASSWORD
PASSWD=$MSSQL_PASSWORD
if [ ! -f "$LAST_MIGRATION_FILE" ]; then
echo "$LAST_MIGRATION_FILE not found!"
@ -43,9 +43,9 @@ if [ -n "$RERUN" ]; then
fi
# Create database if it does not already exist
QUERY="IF NOT EXISTS (SELECT * FROM sys.databases WHERE name = 'vault_dev')
QUERY="IF NOT EXISTS (SELECT * FROM sys.databases WHERE name = '$DATABASE')
BEGIN
CREATE DATABASE vault_dev;
CREATE DATABASE $DATABASE;
END;"
/opt/mssql-tools/bin/sqlcmd -S $SERVER -d master -U $USER -P $PASSWD -I -Q "$QUERY"

16
dev/migrate.ps1 Normal file → Executable file
View File

@ -1,4 +1,18 @@
#!/usr/bin/env pwsh
# Creates the vault_dev database, and runs all the migrations.
docker-compose --profile mssql exec mssql bash /mnt/helpers/run_migrations.sh @args
# Due to azure-edge-sql not containing the mssql-tools on ARM, we manually use
# the mssql-tools container which runs under x86_64. We should monitor this
# in the future and investigate if we can migrate back.
# docker-compose --profile mssql exec mssql bash /mnt/helpers/run_migrations.sh @args
docker run `
-v "$(pwd)/helpers/mssql:/mnt/helpers" `
-v "$(pwd)/../util/Migrator:/mnt/migrator/" `
-v "$(pwd)/.data/mssql:/mnt/data" `
--env-file .env `
--network=bitwardenserver_default `
--rm `
-it `
mcr.microsoft.com/mssql-tools `
/mnt/helpers/run_migrations.sh @args