Skip to content

Instantly share code, notes, and snippets.

@forbesmyester
Last active December 24, 2015 10:54
Show Gist options
  • Save forbesmyester/4ef096dcda52351db8c3 to your computer and use it in GitHub Desktop.
Save forbesmyester/4ef096dcda52351db8c3 to your computer and use it in GitHub Desktop.
Quick Unit Tests in Docker
#!/bin/bash
# Run tests (or anything else) in Docker by doing a tagged build and then run, which should make things much faster.
#
# @author forbesmyester
# @license MIT
DOCKER_TAG=$(echo $PWD | tr '[:upper:]' '[:lower:]' | sed 's/^\///' | sed 's/\//-/g')
echo ""
echo "== USING DOCKER TAG: test-$DOCKER_TAG =========================="
echo ""
DOCKERFILE="./Dockerfile.docker-test"
if [ "$#" -gt 0 ] ; then
echo "HERE"
DOCKERFILE=$1
fi
docker build -t "test-${DOCKER_TAG}" -f $DOCKERFILE . && docker run "test-${DOCKER_TAG}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment