forked from enriquecatala/mssql-server-samplesdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile-2019
88 lines (65 loc) · 3.98 KB
/
Dockerfile-2019
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
FROM mcr.microsoft.com/mssql/server:2019-CU8-ubuntu-16.04
EXPOSE 1433
# You must set this variable with --build-arg INCLUDE_ALL_DATABASES=1 in case you want to restore all databases
ARG INCLUDE_ALL_DATABASES=0
# Depending on the value of the ARG, the bash script will try to restore/attach
ENV INCLUDE_ALL_DATABASES $INCLUDE_ALL_DATABASES
LABEL "MAINTAINER" "Enrique Catalá Bañuls <[email protected]>"
LABEL "Project" "Microsoft SQL Server image with sample databases"
# Since SQL Server 2019 is non-root container, we need to force this to install packages
USER root
RUN apt-get update && apt-get install -y \
curl \
apt-transport-https \
p7zip-full
# Create the local_mountpoint folder where the restores will be happening
# This is critical if you want to use this as a local mountpoint to enable stateful deployments
RUN mkdir -p /var/opt/mssql/data
RUN chown 10001:0 /var/opt/mssql/data
RUN chmod +rwx /var/opt/mssql/data
# Get to the default user (mssql = 10001)
USER 10001
RUN mkdir -p /var/opt/mssql/shared_folder
RUN mkdir -p /var/opt/mssql/backup
WORKDIR /var/opt/mssql/backup
##############################################################
# DATABASES SECTION
# 1) Add here the databases you want to have in your image
# 2) Edit setup.sql and include the RESTORE commands
#
# Local .bak files
#
COPY ./Backups/Pubs.bak ./
COPY ./Backups/Northwind.bak ./
RUN curl -L -o WideWorldImporters-Full.bak https://github.com/Microsoft/sql-server-samples/releases/download/wide-world-importers-v1.0/WideWorldImporters-Full.bak
RUN curl -L -o AdventureWorks2017.bak https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorks2017.bak
## The rest of the databases can be added-dropped manually
RUN if [ "$INCLUDE_ALL_DATABASES" = "1" ] ; then curl -L -o AdventureWorks2016.bak https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorks2016.bak ; else echo 'AdventureWorks2016 skipped since INCLUDE_ALL_DATABASES=0'; fi
RUN if [ "$INCLUDE_ALL_DATABASES" = "1" ] ; then curl -L -o AdventureWorks2014.bak https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorks2014.bak ; else echo 'AdventureWorks2014 skipped since INCLUDE_ALL_DATABASES=0'; fi
RUN if [ "$INCLUDE_ALL_DATABASES" = "1" ] ; then curl -L -o AdventureWorks2012.bak https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorks2012.bak ; else echo 'AdventureWorks2012 skipped since INCLUDE_ALL_DATABASES=0'; fi
## BIG DATABASES
#
RUN if [ "$INCLUDE_ALL_DATABASES" = "1" ] ; then curl -L -o AdventureWorksDW2017.bak https://github.com/Microsoft/sql-server-samples/releases/download/adventureworks/AdventureWorksDW2017.bak; else echo 'AdventureWorksDW2017 skipped since INCLUDE_ALL_DATABASES=0'; fi
RUN if [ "$INCLUDE_ALL_DATABASES" = "1" ] ; then curl -L -o WideWorldImportersDW-Full.bak https://github.com/Microsoft/sql-server-samples/releases/download/wide-world-importers-v1.0/WideWorldImportersDW-Full.bak; else echo 'WideWorldImportersDW-Full skipped since INCLUDE_ALL_DATABASES=0'; fi
# StackOverflow2010
#
RUN if [ "$INCLUDE_ALL_DATABASES" = "1" ] ; then curl -L -o StackOverflow2010.7z http://downloads.brentozar.com.s3.amazonaws.com/StackOverflow2010.7z; else echo 'StackOverflow2010 skipped since INCLUDE_ALL_DATABASES=0'; fi
# This is going to unzip the 10Gb StackOverflow sample database
#
RUN if [ "$INCLUDE_ALL_DATABASES" = "1" ] ; then 7za x StackOverflow2010.7z -o/var/opt/mssql/data/; fi
##############################################################
RUN mkdir -p /usr/config
WORKDIR /usr/config/
COPY setup.* ./
COPY entrypoint.sh ./
# Since SQL Server 2019 is non-root container, we need to force this to install packages
USER root
RUN chown -R 10001:0 setup.sh
RUN chown -R 10001:0 entrypoint.sh
# Get to the default user
USER 10001
RUN chmod +x setup.sh
RUN chmod +x entrypoint.sh
# This entrypoint start sql server, restores data and waits infinitely
ENTRYPOINT ["./entrypoint.sh"]
CMD ["sleep infinity"]