Skip to content

Instantly share code, notes, and snippets.

@sagikazarmark
Last active April 20, 2017 22:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sagikazarmark/2232c06b90f0f76212a1cafe8038530b to your computer and use it in GitHub Desktop.
Save sagikazarmark/2232c06b90f0f76212a1cafe8038530b to your computer and use it in GitHub Desktop.
Makefile with Docker support
DOCKER_IMAGE = your/image
.PHONY = target target2 docker
target:
# Do something here
target2:
# Do something here
docker: ## Execute commands inside a Docker container
docker run --rm -it -v $$PWD:/app -w /app $(DOCKER_IMAGE) make $(filter-out docker, $(MAKECMDGOALS))
@printf "\033[36mExiting with non-zero status code to abort make. If you see this message your command successfully ran.\033[0m\n"
exit 1

Usage

$ make docker target # This will run `make target` inside the container
$ make docker target target2 # This will run `make target target2` inside the container
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment