I have setup a GitHub Codespaces environment that includes a SQL Server container.
Inside /.devcontainer/docker-compose.yml
i have something like this;
# ... other containers configururation
db:
image: mcr.microsoft.com/mssql/server:2019-latest
restart: unless-stopped
environment:
ACCEPT_EULA: Y
The SQL Server spins-up, but I don't know how can I restore a database on that server. When I run a VS Code DevContainer locally on docker I can just copy the file to the SQL Server container with the docker cp
command, and then run the script to restore the database from there.
But I don't know how to approach this task with Codespaces.
Any ideas appreciated.
One option would be to use Spawn (disclaimer - I'm one of the devs working on it).
Spawn lets you create "data images" which represent readonly snapshots of a database at a point in time. These can be created from backups (including SQL Server backups - check out the docs).
Once done, you can create "data containers" which are instantly provisioned cloud-hosted copies of Spawn data images that can be consumed in any environment - including GitHub codespaces.
We've written about how to use Spawn data containers in GitHub Codespaces here.