Adding docker compose for ms-sql with products, tasks table setup.
This commit is contained in:
parent
49d2796f8e
commit
09d83dea39
|
@ -0,0 +1,9 @@
|
||||||
|
FROM mcr.microsoft.com/mssql/server
|
||||||
|
|
||||||
|
ENV ACCEPT_EULA=Y
|
||||||
|
ENV SA_PASSWORD=Passw0rd
|
||||||
|
|
||||||
|
COPY ./data /
|
||||||
|
|
||||||
|
ENTRYPOINT [ "/bin/bash", "entrypoint.sh" ]
|
||||||
|
CMD [ "/opt/mssql/bin/sqlservr" ]
|
|
@ -0,0 +1,24 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
if [ "$1" = '/opt/mssql/bin/sqlservr' ]; then
|
||||||
|
# If this is the container's first run, initialize the application database
|
||||||
|
if [ ! -f /tmp/app-initialized ]; then
|
||||||
|
# Initialize the application database asynchronously in a background process. This allows a) the SQL Server process to be the main process in the container, which allows graceful shutdown and other goodies, and b) us to only start the SQL Server process once, as opposed to starting, stopping, then starting it again.
|
||||||
|
function initialize_app_database() {
|
||||||
|
# Wait a bit for SQL Server to start. SQL Server's process doesn't provide a clever way to check if it's up or not, and it needs to be up before we can import the application database
|
||||||
|
sleep 30s
|
||||||
|
|
||||||
|
echo "RUNNING BUDIBASE SETUP"
|
||||||
|
|
||||||
|
#run the setup script to create the DB and the schema in the DB
|
||||||
|
/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P Passw0rd -i setup.sql
|
||||||
|
|
||||||
|
# Note that the container has been initialized so future starts won't wipe changes to the data
|
||||||
|
touch /tmp/app-initialized
|
||||||
|
}
|
||||||
|
initialize_app_database &
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec "$@"
|
|
@ -0,0 +1,34 @@
|
||||||
|
USE master;
|
||||||
|
|
||||||
|
IF OBJECT_ID ('dbo.products', 'U') IS NOT NULL
|
||||||
|
DROP TABLE products;
|
||||||
|
GO
|
||||||
|
CREATE TABLE products
|
||||||
|
(
|
||||||
|
id int IDENTITY(1,1),
|
||||||
|
name varchar (20),
|
||||||
|
description varchar(30)
|
||||||
|
);
|
||||||
|
IF OBJECT_ID ('dbo.tasks', 'U') IS NOT NULL
|
||||||
|
DROP TABLE tasks;
|
||||||
|
GO
|
||||||
|
CREATE TABLE tasks
|
||||||
|
(
|
||||||
|
taskid int IDENTITY(1,1),
|
||||||
|
taskname varchar (20)
|
||||||
|
);
|
||||||
|
|
||||||
|
INSERT products
|
||||||
|
(name, description)
|
||||||
|
VALUES
|
||||||
|
('Bananas', 'Fruit thing');
|
||||||
|
|
||||||
|
INSERT products
|
||||||
|
(name, description)
|
||||||
|
VALUES
|
||||||
|
('Meat', 'Animal thing');
|
||||||
|
|
||||||
|
INSERT tasks
|
||||||
|
(taskname)
|
||||||
|
VALUES
|
||||||
|
('Processing');
|
|
@ -0,0 +1,12 @@
|
||||||
|
version: "3.8"
|
||||||
|
services:
|
||||||
|
# password: Passw0rd
|
||||||
|
# user: sa
|
||||||
|
# database: master
|
||||||
|
mssql:
|
||||||
|
image: bb/mssql
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: data/Dockerfile
|
||||||
|
ports:
|
||||||
|
- "1433:1433"
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/bash
|
||||||
|
docker-compose down
|
||||||
|
docker volume prune -f
|
Loading…
Reference in New Issue