-
Notifications
You must be signed in to change notification settings - Fork 7
/
upgrade-database-scripts.dockerfile
40 lines (31 loc) · 1.18 KB
/
upgrade-database-scripts.dockerfile
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
# take image with [SqlDatabaseDemo] version 1.0
FROM sqldatabase/mssql-server-linux-demo:create AS build
# copy scripts
COPY upgrade-database-scripts/ /sql-scripts/
# switch to root
USER root
# install .net 8.0 sdk
RUN apt-get update && \
apt-get install -y apt-transport-https && \
apt-get update && \
apt-get install -y dotnet-sdk-8.0
# install SqlDatabase.GlobalTool
RUN dotnet tool install --global SqlDatabase.GlobalTool
# upgrade [SqlDatabaseDemo] database to version 2.0 from sql-scripts
# 1. start mssql server in the background and wait 20 secs
# 2. upgrade database
# 3. shatdown mssql server
RUN /opt/mssql/bin/sqlservr & \
export PATH="$PATH:/root/.dotnet/tools" && \
SqlDatabase upgrade \
"-database=Data Source=.;Initial Catalog=SqlDatabaseDemo;User Id=sa;Password=P@ssw0rd;ConnectRetryCount=20;ConnectRetryInterval=1" \
-from=/sql-scripts && \
pkill sqlservr
# set mssql user as SqlServer files owner
RUN chown -R mssql /var/opt/mssql/data
FROM mcr.microsoft.com/mssql/server:latest AS runtime
ENV ACCEPT_EULA=Y \
SA_PASSWORD=P@ssw0rd \
MSSQL_PID=Express
# copy mssql server content
COPY --from=build /var/opt/mssql/data/* /var/opt/mssql/data/