Last active
October 15, 2018 12:46
-
-
Save B-Galati/8fa6ba00a5c7d5fbd5f32750cecc6ff8 to your computer and use it in GitHub Desktop.
Rebuild docker images only when they are modified
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DOCKER_COMPOSE?=docker-compose | |
DOCKER_FILES=$(shell find ./docker/dev/ -type f -name '*') | |
.DEFAULT_GOAL := help | |
.PHONY: help | |
help: | |
@grep -E '(^[a-zA-Z_-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m##/[33m/' | |
## | |
## Project setup | |
##--------------------------------------------------------------------------- | |
.PHONY: start | |
start: build up ## Start docker containers | |
.PHONY: stop | |
stop: ## Remove and stop docker containers | |
$(DOCKER_COMPOSE) kill | |
$(DOCKER_COMPOSE) rm -v --force | |
.PHONY: reset | |
reset: stop clear start | |
.PHONY: clear | |
clear: | |
rm -f docker-dev.lock | |
## | |
# Internal rules | |
## | |
.PHONY: build | |
build: docker-dev.lock | |
docker-dev.lock: $(DOCKER_FILES) | |
$(DOCKER_COMPOSE) pull --parallel --ignore-pull-failures | |
$(DOCKER_COMPOSE) build --pull --force-rm | |
touch docker-dev.lock | |
.PHONY: up | |
up: | |
$(DOCKER_COMPOSE) up -d --remove-orphans |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment