TGIMBA TypeScript API Tuneup – Step 7 – Local SQL Server in Docker Container using Docker-Compose

Git  Code

This one turned out to be harder and simpler than I originally thought it would be.  Let me explain.

I was thinking this would be pretty fast since there are literally tons of dockerfile examples out there.  But many I tried just didn’t work for a variety of issues.  This is the harder part.  The simpler part was how uncomplicated the dockerfile that works is.

What eventually led me to getting this to work was to watch an excellent video by Eric Kang (reference #7).  He is a Microsoft Senior Program Manager.  In this video (first 10 minutes or so), he goes through some very basic and helpful steps I was not aware of.  However, the light didn’t really come on until I realized how the environment variables (3) were being set in the container.  Kinda a duh moment I will admit 🙂   Adding the ‘=’ for each environment variable (i.e. ENV ACCEPT_EULA=Y) was the secret.  In Mr. Kang’s docker file (and others) samples, it was listed as ENV ACCEPT_EULA Y.   The clue was that my automated tests couldn’t log in even though I had specified the correct password.  Adding the ‘=’ sign did the trick.

The process I used is:

  • Create a docker file similar to Mr. Kang’s

Screen Shot 2018-01-21 at 5.30.23 PM

  • Update my existing docker-compose.yml file

Screen Shot 2018-01-21 at 5.30.36 PM

  • Clean out all my previous docker containers and images

Screen Shot 2018-01-21 at 5.28.46 PM

  • Run docker-compose up -d

Screen Shot 2018-01-21 at 5.29.27 PM

  • Confirm the containers were up and running

Screen Shot 2018-01-21 at 5.30.43 PM

  • Run my integration tests

Screen Shot 2018-01-21 at 5.31.36 PM

Next, I will create a test set of tables in my production SQL Server instance and spin up a Dynamo Db instance and run these in the AWS code pipeline so that if any tests fail, the deploy will be stopped.

Stay tuned!

References

  1. https://hub.docker.com/r/militellovinx/mssql-server-linux/~/dockerfile/
  2. https://github.com/Microsoft/mssql-docker/issues/22
  3. https://github.com/erickangMSFT/sqldevops/blob/master/docker_cluster/mssql_unittest/Dockerfile
  4. https://github.com/Microsoft/mssql-docker/issues/22
  5. https://hub.docker.com/r/ericskang/unittestdb/
  6. https://github.com/erickangMSFT/sqldevops/blob/master/docker_cluster/docker-compose/docker-compose.yml
  7. https://docs.microsoft.com/en-us/sql/linux/quickstart-install-connect-docker
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s