Skip to content

Commit 6b61c7d

Browse files
adding MSSQL support
1 parent 8315a38 commit 6b61c7d

6 files changed

Lines changed: 53 additions & 1 deletion

File tree

docker-compose.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,20 @@ services:
156156
ports:
157157
- "${MYSQL_PORT}:3306"
158158

159+
### MsSQL Container #########################################
160+
161+
mssql:
162+
build:
163+
context: ./mssql
164+
environment:
165+
- MSSQL_DATABASE=${MSSQL_DATABASE}
166+
- SA_PASSWORD=${MSSQL_PASSWORD}
167+
- ACCEPT_EULA=Y
168+
volumes:
169+
- mssql:/var/lib/mysql
170+
ports:
171+
- "${MSSQL_PORT}:1433"
172+
159173
### MariaDB Container #######################################
160174

161175
mariadb:
@@ -381,6 +395,8 @@ services:
381395
volumes:
382396
mysql:
383397
driver: "local"
398+
mssql:
399+
driver: "local"
384400
postgres:
385401
driver: "local"
386402
memcached:

env-example

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,17 @@ MYSQL_PASSWORD=secret
6969
MYSQL_PORT=3306
7070
MYSQL_ROOT_PASSWORD=root
7171

72+
### MSSQL Container
73+
MSSQL_DATABASE=homestead
74+
MSSQL_PASSWORD=yourStrong(!)Password
75+
MSSQL_PORT=1433
76+
7277
### MARIADB Container
7378
MARIADB_DATABASE=default
7479
MARIADB_USER=default
7580
MARIADB_PASSWORD=secret
7681
MARIADB_PORT=3306
7782

78-
7983
### POSTGRES Container
8084
POSTGRES_DB=default
8185
POSTGRES_USER=default

mssql/Dockerfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM microsoft/mssql-server-linux
2+
3+
# Create config directory
4+
# an set it as WORKDIR
5+
RUN mkdir -p /usr/src/app
6+
WORKDIR /usr/src/app
7+
8+
# Bundle app source
9+
COPY . /usr/src/app
10+
11+
RUN chmod +x /usr/src/app/create_table.sh
12+
13+
ENV MSSQL_DATABASE=$MSSQL_DATABASE
14+
ENV ACCEPT_EULA=Y
15+
ENV SA_PASSWORD=$MSSQL_PASSWORD
16+
17+
VOLUME /var/opt/mssql
18+
19+
EXPOSE 1433
20+
21+
CMD /bin/bash ./entrypoint.sh

mssql/create_table.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#wait for the SQL Server to come up
2+
sleep 45s
3+
4+
#run the setup script to create the DB and the schema in the DB
5+
/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P $SA_PASSWORD -d master -i setup.sql

mssql/entrypoint.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#start SQL Server, start the script to create the DB and import the data, start the app
2+
/opt/mssql/bin/sqlservr.sh & /usr/src/app/create_table.sh & tail -f /dev/null

mssql/setup.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
CREATE DATABASE $(MSSQL_DATABASE);
2+
GO
3+
USE $(MSSQL_DATABASE);
4+
GO

0 commit comments

Comments
 (0)