Using Magic with the SQL Server Docker image
For way too long I have postponed this article, since I personally prefer MySQL. But since SQL Server now works just as well on Linux and Mac, it's time for it
Join the DZone community and get the full member experience.Join For Free
If you want to see a video where I am showing you the process, you can watch the following video where I walk you through most of the things required to get Magic up running.
The default "docker-compose.yml" file for Magic will create a MySQL Docker container. If you instead want to use SQL Server, you'll need a slightly modified "docker-compose.yml" file. Below is a complete docker-compose file, except it spawns up a SQL Server database instance image, and not a MySQL image.
If you create a file named "docker-compose.yml" and save it to any directory on your machine with the above content, for then to run the following command in that same directory, this should start an SQL Server instance on your machine. Notice, this should work transparently on both Windows, Linux, and OS X.
Notice - If you already have the default "docker-compose.yml" file's containers running, you'll have to stop these containers, since the above file uses the same ports on your host operating system as the MySQL file file does. To do this, go to the folder where you have your MySQL "docker-compose.yml" file using a terminal window and type docker-compose down.
When your Docker images are up running, you can visit localhost:5555 and you should come to the Magic Dashboard. Login with "root"/"root" and configure Magic as described below. The most important difference of course being that you need to use the "mssql" database type and the following connection string.
Magic Docker internals
The above "docker-compose.yml" file creates 3 containers.
- The Magic Dashboard
- The Magic Backend
- A Microsoft SQL Server instance
The Magic dashboard and backend are images I maintain and update every time I create a release of Magic. If you want to update these in the future as I create new releases, all you need to do is to write docker pull servergardens/magic-frontend:latest and docker pull servergardens/magic-backend:latest in any terminal window. This works since Docker uses a local "repository of images" on your host machine.
To stop the containers you need to go to the same folder you saved your "docker-compose.yml" file in, and type docker-compose down.
When you configure Magic, you'll need to choose the "mssql" database type. Afterwards you'll need to paste the following into its connection string settings.
Notice - When just playing around on your local development machine, the password is not really that important, since Docker will not expose your SQL Server instance outside of the virtualised Docker network. So the above password, although obviously not good enough for a real world production environment, would be more than enough to secure your development machine.
The rest of the process is similar to the MySQL equivalent, and implies crudifying your backend, creating a key pair, and running the assumptions. Just remember to type your name and email address into the identity and email textboxes as Magic asks you for this.
Notice - You also obviously need to have Docker installed on your development machine.
In this micro-tutorial we used Docker to configure Magic to use Microsoft SQL Server instead of MySQL. To create a more resilient production ready environment, you'd probably benefit from reading more about Docker by finding tutorials related to this online.
Published at DZone with permission of Thomas Hansen. See the original article here.
Opinions expressed by DZone contributors are their own.