Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I restore a bacpac file to SQL Server linux docker container?

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?

like image 279
GraemeMiller Avatar asked Oct 16 '22 23:10

GraemeMiller


1 Answers

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

like image 67
GraemeMiller Avatar answered Oct 20 '22 18:10

GraemeMiller