5

I am trying to setup an integration testing environment for Docker. We need to restore a bacpac to our mssql-server-linux:latest image so we can run tests based on the dataset.

My compose file looks like:

version: '3'

services:
    projectweb:
        image: projectweb
        build:
            context: .
            dockerfile: Project\Dockerfile
        depends_on:
            - db
    db:
        image: "microsoft/mssql-server-linux"
        environment:
            SA_PASSWORD: "MyVerySecurePassword"
            ACCEPT_EULA: "Y"        
        volumes:
            - ./database:/tmp

I don't need the changes to the database to be persisted past the life of the container. I just need to script getting the data into it. I don't have a lot of experience with docker or SQL Server for Linux. I assume I need to wait for the container to be initilizsed and DB setup and started, then execute a script that reads the database bacpac from tmp folder. As far as I understand I should use sqlpackage but this doesn't appear to be in the container? Do I need another container with this SSDT/sqlpackage in it? Can I install splpackage into the container?

What is the best way to do import bacpac data?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
GraemeMiller
  • 11,973
  • 8
  • 57
  • 111
  • `sqlpackage.exe` requires windows so you'll need a Windows container (or other Windows machine) to deploy a bacpac to SQL Server on Linux or Linux container. You could restore from a database backup instead of using a bacpac to avoid the Windows dependency. – Dan Guzman Jan 23 '18 at 13:20
  • Ok. bak file won't work for us really - as it is SQL Azure for the data - and pretty sure we can't get bak file from it. However guess there must be other option instead of bacpac – GraemeMiller Jan 23 '18 at 13:28
  • @DanGuzman Just so I am clear - there used to be a way to do this via sqlpackage on linux? http://reverentgeek.com/sql-server-for-linux-how-to-move-a-database-from-one-docker-container-to-another/ that MS have currently removed according to the github thread? – GraemeMiller Jan 23 '18 at 13:32
  • There may have been a Linux version available at one time but it's not currently available. Microsoft is beefing up open-source cross-platform database tooling support but it's still work in progress. I expect sqlpackage or it's equivalent to be available for Linux in the future but when it's anyone's guess as to when. For now, Windows is needed for sqlpackage. – Dan Guzman Jan 23 '18 at 14:06

1 Answers1

3

This has now been resolved. Microsoft have a proper sql package for Linux. This can be installed into a custom image. https://learn.microsoft.com/en-us/sql/tools/sqlpackage?view=sql-server-2017

GraemeMiller
  • 11,973
  • 8
  • 57
  • 111