From 1fd7f5dd035ca57469246db8b9fb3c17d2cedfe9 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Thu, 17 Aug 2017 22:28:56 -0400 Subject: [PATCH] mssql image with setup script on entrypoint --- build.ps1 | 1 + build.sh | 1 + docker/docker-compose.yml | 3 ++- util/MsSql/.dockerignore | 3 +++ util/MsSql/Dockerfile | 7 +++++++ util/MsSql/build.ps1 | 7 +++++++ util/MsSql/build.sh | 10 ++++++++++ util/MsSql/entrypoint.sh | 4 ++++ util/MsSql/setup.sql | 6 ++++++ 9 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 util/MsSql/.dockerignore create mode 100644 util/MsSql/Dockerfile create mode 100644 util/MsSql/build.ps1 create mode 100644 util/MsSql/build.sh create mode 100644 util/MsSql/entrypoint.sh create mode 100644 util/MsSql/setup.sql diff --git a/build.ps1 b/build.ps1 index 18359f1543..bcf03f7ed4 100644 --- a/build.ps1 +++ b/build.ps1 @@ -9,4 +9,5 @@ echo "==================" & $dir\util\Server\build.ps1 & $dir\util\Nginx\build.ps1 & $dir\util\Attachments\build.ps1 +& $dir\util\MsSql\build.ps1 & $dir\util\Setup\build.ps1 diff --git a/build.sh b/build.sh index ee0649ccb3..02fb93f902 100644 --- a/build.sh +++ b/build.sh @@ -11,4 +11,5 @@ $DIR/src/Identity/build.sh $DIR/util/Server/build.sh $DIR/util/Nginx/build.sh $DIR/util/Attachments/build.sh +$DIR/util/MsSql/build.sh $DIR/util/Setup/build.sh diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 17cd05ad0b..7966d4b969 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -2,7 +2,7 @@ version: '3' services: mssql: - image: microsoft/mssql-server-linux + image: bitwarden/mssql container_name: mssql restart: always ports: @@ -26,6 +26,7 @@ services: identity: image: bitwarden/identity container_name: identity + restart: always nginx: image: bitwarden/nginx diff --git a/util/MsSql/.dockerignore b/util/MsSql/.dockerignore new file mode 100644 index 0000000000..9dbc71be96 --- /dev/null +++ b/util/MsSql/.dockerignore @@ -0,0 +1,3 @@ +* +!entrypoint.sh +!setup.sql diff --git a/util/MsSql/Dockerfile b/util/MsSql/Dockerfile new file mode 100644 index 0000000000..d24112848a --- /dev/null +++ b/util/MsSql/Dockerfile @@ -0,0 +1,7 @@ +FROM microsoft/mssql-server-linux + +COPY setup.sql / + +COPY entrypoint.sh / +RUN chmod +x /entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] diff --git a/util/MsSql/build.ps1 b/util/MsSql/build.ps1 new file mode 100644 index 0000000000..2330caffa1 --- /dev/null +++ b/util/MsSql/build.ps1 @@ -0,0 +1,7 @@ +$dir = Split-Path -Parent $MyInvocation.MyCommand.Path + +echo "`n# Building MsSql" + +echo "`nBuilding docker image" +docker --version +docker build -t bitwarden/mssql $dir\. diff --git a/util/MsSql/build.sh b/util/MsSql/build.sh new file mode 100644 index 0000000000..9158f8ba93 --- /dev/null +++ b/util/MsSql/build.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +set -e + +DIR="$(dirname $(readlink -f $0))" + +echo -e "\n# Building MsSql" + +echo -e "\nBuilding docker image" +docker --version +docker build -t bitwarden/mssql $DIR/. diff --git a/util/MsSql/entrypoint.sh b/util/MsSql/entrypoint.sh new file mode 100644 index 0000000000..a049275c73 --- /dev/null +++ b/util/MsSql/entrypoint.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +/opt/mssql/bin/sqlservr +/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P ${SA_PASSWORD} -i /setup.sql diff --git a/util/MsSql/setup.sql b/util/MsSql/setup.sql new file mode 100644 index 0000000000..6595047587 --- /dev/null +++ b/util/MsSql/setup.sql @@ -0,0 +1,6 @@ +USE [master] +IF ((SELECT COUNT(1) FROM sys.databases WHERE [name] = 'vault') = 0) +BEGIN + CREATE DATABASE [vault] +END +GO