File tree Expand file tree Collapse file tree 6 files changed +68
-16
lines changed Expand file tree Collapse file tree 6 files changed +68
-16
lines changed Original file line number Diff line number Diff line change
1
+ # Set COMPOSE_PROFILES to one of the following: postgres, mysql, mssql
2
+ COMPOSE_PROFILES = mssql
Original file line number Diff line number Diff line change
1
+ # You can easily switch between different databases by changing the value of COMPOSE_PROFILES in the .env file.
1
2
services :
2
- test :
3
- image : debian:stable-slim
4
- volumes :
5
- - .:/var/www
6
- depends_on :
7
- - db
8
- environment :
9
- DATABASE_URL : ${DB:-postgres}://root:secret@db/sqlpage
10
3
web :
11
4
build : { context: "." }
12
5
ports :
13
6
- " 8080:8080"
14
7
volumes :
15
8
- .:/var/www
16
9
depends_on :
17
- - db
10
+ - ${COMPOSE_PROFILES-postgres}
18
11
environment :
19
- DATABASE_URL : ${DB:-postgres}://root:secret@db/sqlpage
20
- db : # The DB environment variable can be set to "mariadb" or "postgres" to test the code with different databases
21
- ports :
22
- - " 5432:5432"
23
- - " 3306:3306"
24
- image : ${DB:-postgres}
12
+ DATABASE_URL : ${COMPOSE_PROFILES-postgres}://root:secret@${COMPOSE_PROFILES:-postgres}/sqlpage
13
+ postgres :
14
+ profiles : ["postgres"]
15
+ ports : ["5432:5432"]
16
+ image : postgres
25
17
environment :
26
18
POSTGRES_USER : root
27
19
POSTGRES_DB : sqlpage
28
20
POSTGRES_PASSWORD : secret
21
+ mysql :
22
+ profiles : ["mysql"]
23
+ ports : ["3306:3306"]
24
+ image : mysql
25
+ environment :
29
26
MYSQL_ROOT_PASSWORD : secret
30
- MYSQL_DATABASE : sqlpage
27
+ MYSQL_DATABASE : sqlpage
28
+ mssql :
29
+ profiles : ["mssql"]
30
+ ports : ["1433:1433"]
31
+ build : { context: "mssql" }
Original file line number Diff line number Diff line change
1
+ ARG VERSION=2019-latest
2
+ FROM mcr.microsoft.com/mssql/server:${VERSION}
3
+
4
+ # Create a config directory
5
+ RUN mkdir -p /usr/config
6
+ WORKDIR /usr/config
7
+
8
+ # Bundle config source
9
+ COPY entrypoint.sh /usr/config/entrypoint.sh
10
+ COPY configure-db.sh /usr/config/configure-db.sh
11
+ COPY setup.sql /usr/config/setup.sql
12
+
13
+ # Grant permissions for to our scripts to be executable
14
+ USER root
15
+ RUN chmod +x /usr/config/entrypoint.sh
16
+ RUN chmod +x /usr/config/configure-db.sh
17
+ RUN chown 10001 /usr/config/entrypoint.sh
18
+ RUN chown 10001 /usr/config/configure-db.sh
19
+ USER 10001
20
+
21
+ ENV SA_PASSWORD="Password123!"
22
+ ENV ACCEPT_EULA="Y"
23
+
24
+ ENTRYPOINT ["/usr/config/entrypoint.sh" ]
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ # Wait 15 seconds for SQL Server to start up
4
+ sleep 15
5
+
6
+ # Run the setup script to create the DB and the schema in the DB
7
+ /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P " $SA_PASSWORD " -d master -i setup.sql
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ # Start the script to create the DB and user
4
+ /usr/config/configure-db.sh &
5
+
6
+ # Start SQL Server
7
+ /opt/mssql/bin/sqlservr
Original file line number Diff line number Diff line change
1
+ IF DB_ID (' sqlpage' ) IS NULL
2
+ BEGIN
3
+ CREATE DATABASE sqlpage ;
4
+ END ;
5
+ GO
6
+
7
+ USE sqlpage;
8
+ GO
9
+
10
+ CREATE USER root WITH PASSWORD = ' secret' ;
11
+ GO
You can’t perform that action at this time.
0 commit comments