Skip to content

Instantly share code, notes, and snippets.

@gtramontina
Last active August 29, 2015 14:18
Show Gist options
  • Save gtramontina/e5766c9de4458f66cc9d to your computer and use it in GitHub Desktop.
Save gtramontina/e5766c9de4458f66cc9d to your computer and use it in GitHub Desktop.
Given a git repository with a `Dockerfile`, this runs the given command within the container in the context of your repository.
#!/usr/bin/env bash -e
if [[ -z "$1" ]]
then
echo "Please specify a command to run inside the container."
exit 1
fi
COMMAND=$1
IMAGE=`git rev-parse HEAD`
WORKSPACE=/opt/workspace
docker build -t $IMAGE .
docker run --rm -v `pwd`:${WORKSPACE} ${IMAGE} ${WORKSPACE}/${COMMAND}
docker rmi $IMAGE
@gtramontina
Copy link
Author

To run:

curl -Ls http://bit.ly/1NRiAQS | bash -s <YOUR_COMMAND>

(the bit.ly url is just a short for the raw file)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment