Using Docker to create a local development environment for Azure SQL Database
At Mimo, we’re hosting all of our production data in Azure SQL Database. It’s pretty useful to use a copy of that production data for local development, to match the local environment as closely as possible to the production environment.
Since most of our developers work on a Macbook, it’s not possible to just install a local instance of SQL Server and run the development database on that. For that reason, we host a SQL Server instance inside a Docker image of SQL Server on Linux, create a snapshot of the production database and restore that into a new Docker image.
Restoring the database snapshot into a Docker image allows us to easily share the image between all developers and also enables a painless restore flow if you want to reset your local development database.
Here is a Gist of the Dockerfile
that we’re using:
Since SqlPackage, which is used to restore .bacpac
files (the backup file format that Azure Sql Database uses) is not installed, we’re using a preview version posted in this Github thread. After that the relevant .bacpac
file is copied into the image, SQL Server is started and the import process started.
With a bit of hacking around with Azure automation, this file can be used to automatically create a new Docker image every day from a snapshot of the production database so developers always get the latest data every day.