@@ -37,7 +37,7 @@ func (m *bacpac) BringOnline(
3737 m .setDefaultDatabaseToMaster (options .Username , query )
3838
3939 m .RunCommand ([]string {
40- "./root/ .dotnet/tools/sqlpackage" ,
40+ "./.dotnet/tools/sqlpackage" ,
4141 "/Diagnostics:true" ,
4242 "/Action:import" ,
4343 "/SourceFile:" + m .CopyToLocation () + "/" + options .Filename ,
@@ -63,12 +63,28 @@ func (m *bacpac) installSqlPackage() {
6363 }
6464
6565 //BUG(stuartpa): Can this be done in the mssql user, don't think it needs root
66- m .RunCommand ([]string {"wget" , "https://dot.net/v1/dotnet-install.sh" , "-O" , "dotnet-install.sh" })
67- m .RunCommand ([]string {"chmod" , "+x" , "./dotnet-install.sh" })
68- m .RunCommand ([]string {"./dotnet-install.sh" })
69- m .RunCommand ([]string {"/root/.dotnet/dotnet" , "tool" , "install" , "-g" , "microsoft.sqlpackage" })
66+ m .RunCommand ([]string {"wget" , "https://dot.net/v1/dotnet-install.sh" , "-O" , "/tmp/dotnet-install.sh" })
67+ m .RunCommand ([]string {"chmod" , "+x" , "/tmp/dotnet-install.sh" })
68+ m .RunCommand ([]string {"/tmp/dotnet-install.sh" , "--install-dir" , "/opt/dotnet" })
69+
70+ // The SQL Server container doesn't have a /home/mssql directory (which is ~), this
71+ // causes all sorts of things to break in the container that expect to create .toolname folders
72+ m .RunCommandAsRoot ([]string {"mkdir" , "-p" , "/home/mssql" })
73+ m .RunCommandAsRoot ([]string {"chown" , "mssql:root" , "/home/mssql" })
74+
75+ m .RunCommand ([]string {"touch" , "/home/mssql/.bashrc" })
76+ m .RunCommand ([]string {"sed" , "-i" , "$ a/export DOTNET_ROOT=/opt/dotnet" , "/home/mssql/.bashrc" })
77+ m .RunCommand ([]string {"sed" , "-i" , "$ a/export PATH=$PATH:$DOTNET_ROOT:~/.dotnet/tools" , "/home/mssql/.bashrc" })
78+ m .RunCommand ([]string {"/opt/dotnet/dotnet" , "tool" , "install" , "-g" , "microsoft.sqlpackage" })
7079}
7180
7281func (m * bacpac ) RunCommand (s []string ) ([]byte , []byte ) {
73- return m .controller .RunCmdInContainer (m .containerId , s )
82+ return m .controller .RunCmdInContainer (m .containerId , s , container.ExecOptions {})
83+ }
84+
85+ func (m * bacpac ) RunCommandAsRoot (s []string ) ([]byte , []byte ) {
86+ return m .controller .RunCmdInContainer (m .containerId , s , container.ExecOptions {
87+ User : "root" ,
88+ Env : nil ,
89+ })
7490}
0 commit comments