Makefile Template for docker-compose of the Devilbox
To install mk-lib run command
curl -sL https://git.io/JJU2I | sh
To upgrade existing mk-lib run command
make mk-upgrade
Common
make console
- open PHP container's console
From Makefile.minimal.mk - samples
make up
- start all containers in foregroundmake start
- start all containers in backgroundmake start
c=php - start only php containermake stop
- stop all containersmake stop
c=php - stop only php containermake restart
- restart all containersmake restart
c="httpd php" - restart httpd and php containersmake status
- show list of containers with statusesmake down
- stop all containers and removes containers, networks, volumes, and images created by up or startmake compose
- configure the full stack containersmake compose
c="elk" - configure the stack with all default and elk containersmake compose
DEVILBOX_COMPOSE_DIR=/path/to/compose_files c="revealjs portainer" - configure the stack with all default and revealjs plus portainer containers
From this library
make help
- show help (see above)make mk-upgrade
- check for updates of mk-libmake mk-version
- show the current version of mk-lib
- ROOT_DIR - full path to dir with Makefile
- MK_DIR - fill path to .mk-lib dir
- DOCKER_COMPOSE - docker-compose executable command
- DOCKER_COMPOSE_FILE - docker-compose.yml file
- DOCKER_COMPOSE_OVERRIDE_FILE - docker-compose.override.yml file
Basic commands (you can copy and paste it into your Makefile)
# REQUIRED SECTION
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
include $(ROOT_DIR)/.mk-lib/common.mk
# END OF REQUIRED SECTION
.PHONY: help up down start stop restart status console compose
up: ## Start all or c=<name> containers in foreground
@$(DOCKER_COMPOSE) $(strip -f $(DOCKER_COMPOSE_FILE) -f $(DOCKER_COMPOSE_OVERRIDE_FILE) $(foreach container,$(filter-out $(DEVILBOX_MAIN_CONTAINERS),$(DEVILBOX_CONTAINERS)),-f $(DEVILBOX_COMPOSE_DIR)/$(DEVILBOX_COMPOSE_FILE_PATTERN)$(container))) up $(c)
down: ## Stop all containers and removes containers, networks, volumes, and images created by up or start
@$(DOCKER_COMPOSE) $(strip -f $(DOCKER_COMPOSE_FILE) -f $(DOCKER_COMPOSE_OVERRIDE_FILE) $(foreach container,$(filter-out $(DEVILBOX_MAIN_CONTAINERS),$(DEVILBOX_CONTAINERS)),-f $(DEVILBOX_COMPOSE_DIR)/$(DEVILBOX_COMPOSE_FILE_PATTERN)$(container))) down --remove-orphans
start: ## Start all or c=<name> containers in background
@$(DOCKER_COMPOSE) $(strip -f $(DOCKER_COMPOSE_FILE) -f $(DOCKER_COMPOSE_OVERRIDE_FILE) $(foreach container,$(filter-out $(DEVILBOX_MAIN_CONTAINERS),$(DEVILBOX_CONTAINERS)),-f $(DEVILBOX_COMPOSE_DIR)/$(DEVILBOX_COMPOSE_FILE_PATTERN)$(container))) up -d $(c)
stop: ## Stop all or c=<name> containers
@$(DOCKER_COMPOSE) $(strip -f $(DOCKER_COMPOSE_FILE) -f $(DOCKER_COMPOSE_OVERRIDE_FILE) $(foreach container,$(filter-out $(DEVILBOX_MAIN_CONTAINERS),$(DEVILBOX_CONTAINERS)),-f $(DEVILBOX_COMPOSE_DIR)/$(DEVILBOX_COMPOSE_FILE_PATTERN)$(container))) stop $(c)
restart: ## Restart all or c=<name> containers
@$(DOCKER_COMPOSE) $(strip -f $(DOCKER_COMPOSE_FILE) -f $(DOCKER_COMPOSE_OVERRIDE_FILE) $(foreach container,$(filter-out $(DEVILBOX_MAIN_CONTAINERS),$(DEVILBOX_CONTAINERS)),-f $(DEVILBOX_COMPOSE_DIR)/$(DEVILBOX_COMPOSE_FILE_PATTERN)$(container))) stop $(c)
@$(DOCKER_COMPOSE) $(strip -f $(DOCKER_COMPOSE_FILE) -f $(DOCKER_COMPOSE_OVERRIDE_FILE) $(foreach container,$(filter-out $(DEVILBOX_MAIN_CONTAINERS),$(DEVILBOX_CONTAINERS)),-f $(DEVILBOX_COMPOSE_DIR)/$(DEVILBOX_COMPOSE_FILE_PATTERN)$(container))) up -d $(c)
status: ## Show status of containers
@$(DOCKER_COMPOSE) $(strip -f $(DOCKER_COMPOSE_FILE) -f $(DOCKER_COMPOSE_OVERRIDE_FILE) $(foreach container,$(filter-out $(DEVILBOX_MAIN_CONTAINERS),$(DEVILBOX_CONTAINERS)),-f $(DEVILBOX_COMPOSE_DIR)/$(DEVILBOX_COMPOSE_FILE_PATTERN)$(container))) ps
console: ## Enter the php container
@$(DOCKER_COMPOSE) exec --user devilbox php bash -l
compose: ## Configure the stack containers with c=<name> list
@$(file > $(MAKE_ENV),DEVILBOX_CONTAINERS=$(strip $(c)))
@echo Devilbox Stack is composed. $(MAKE_ENV) file was updated.
You can create .make.env file in the directory with Makefile or the current directory.
Available variables
- DEVILBOX_CONTAINERS = default containers to execute; Main containers {httpd php mysql pgsql redis memcd mongo} by default.
See CHANGELOG
MIT (see LICENSE)
Laurent Laville Lead Dev of this project