hlfshell Keith Chester

docker

scaffold + toolbox: local environments as Go services

Scaffold logo

About a year ago I updated docker-harness, a tool I’ve used in several of my golang projects in order to generate realistic integration tests by making it easy to create complex environmental stacks locally. The idea was simple - at some point you have to test the SQL you write against a real database. Or the network call against the real service. If you can self host it easily in a reusable wrapper, why not?

After updating it, I realized that maybe I could take it from a test-focused library to a generic environmental one, where I dive deeper on the unique idea I kind of played with in docker-harness. Maybe it could be a useful enough tool that local clones of environments could be quickly deployable?

So I started playing with the idea, extending the idea of a set of stacks that are modular and composable; a common theme across my work apparently. The result is scaffold - a Go library for composing environments and stacks out of smaller pieces / services. A service has a small lifecycle: create it, clean it up, and read its logs. A stack groups those services into an environment an application or developer tool can manage. I’ve been using it to emulate a super complicated distributed microservice platform with lots of disparate pieces to unlock easy local development for my coworkers.

scaffold-toolbox was created as an addendum, supplying premade stacks to build from. Each toolbox entry is its own Go module. View it as a LEGO set to start building your quick launch envs.

docker-harness got a mini-makeover

Just pushed a pretty significant update to docker-harness. It was a tool I created originally to power some of my Docker containerized database tests.

I pulled out the dependencies for each database to modularize it a bit. Each database module (MySQL, PostgreSQL, Redis, Memcached) now has its own go.mod and go.sum, which means you only pull in the dependencies for the databases you actually need.

Also added some dependency updates, taking out old dependencies that weren’t needed anymore, while also ensuring that anything that has been deprecated or abandoned wasn’t being used.

Golang Docker Harness

tldr; Sometimes you just need to call out to a database instead of mocking it; to that end I created this module to allow one to quickly create and dispose of docker containers for tests. The Problem Generally when writing unit or …

Read article →