Skip to content

Commit

Permalink
Merge pull request #86 from mostafahussein/docker-compose-v2
Browse files Browse the repository at this point in the history
Use docker compose v2 when available.
  • Loading branch information
sherifabdlnaby authored Nov 21, 2022
2 parents ab291a2 + bd25e6d commit 83de211
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
39 changes: 23 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,63 +13,70 @@ ELK_NODES := elasticsearch-1 elasticsearch-2
ELK_MAIN_SERVICES := ${ELK_SERVICES} ${ELK_MONITORING} ${ELK_TOOLS}
ELK_ALL_SERVICES := ${ELK_MAIN_SERVICES} ${ELK_NODES} ${ELK_LOG_COLLECTION}

compose_v2_not_supported = $(shell command docker compose 2> /dev/null)
ifeq (,$(compose_v2_not_supported))
DOCKER_COMPOSE_COMMAND = docker-compose
else
DOCKER_COMPOSE_COMMAND = docker compose
endif

# --------------------------
.PHONY: setup keystore certs all elk monitoring tools build down stop restart rm logs

keystore: ## Setup Elasticsearch Keystore, by initializing passwords, and add credentials defined in `keystore.sh`.
docker-compose -f docker-compose.setup.yml run --rm keystore
$(DOCKER_COMPOSE_COMMAND) -f docker-compose.setup.yml run --rm keystore

certs: ## Generate Elasticsearch SSL Certs.
docker-compose -f docker-compose.setup.yml run --rm certs
$(DOCKER_COMPOSE_COMMAND) -f docker-compose.setup.yml run --rm certs

setup: ## Generate Elasticsearch SSL Certs and Keystore.
@make certs
@make keystore

all: ## Start Elk and all its component (ELK, Monitoring, and Tools).
docker-compose ${COMPOSE_ALL_FILES} up -d --build ${ELK_MAIN_SERVICES}
$(DOCKER_COMPOSE_COMMAND) ${COMPOSE_ALL_FILES} up -d --build ${ELK_MAIN_SERVICES}

elk: ## Start ELK.
docker-compose up -d --build
$(DOCKER_COMPOSE_COMMAND) up -d --build

up:
@make elk
@echo "Visit Kibana: https://localhost:5601"

monitoring: ## Start ELK Monitoring.
@docker-compose ${COMPOSE_MONITORING} up -d --build ${ELK_MONITORING}
$(DOCKER_COMPOSE_COMMAND) ${COMPOSE_MONITORING} up -d --build ${ELK_MONITORING}

collect-docker-logs: ## Start Filebeat that collects all Host Docker Logs and ship it to ELK
@docker-compose ${COMPOSE_LOGGING} up -d --build ${ELK_LOG_COLLECTION}
$(DOCKER_COMPOSE_COMMAND) ${COMPOSE_LOGGING} up -d --build ${ELK_LOG_COLLECTION}

tools: ## Start ELK Tools (ElastAlert, Curator).
@docker-compose ${COMPOSE_TOOLS} up -d --build ${ELK_TOOLS}
$(DOCKER_COMPOSE_COMMAND) ${COMPOSE_TOOLS} up -d --build ${ELK_TOOLS}

nodes: ## Start Two Extra Elasticsearch Nodes
@docker-compose ${COMPOSE_NODES} up -d --build ${ELK_NODES}
$(DOCKER_COMPOSE_COMMAND) ${COMPOSE_NODES} up -d --build ${ELK_NODES}

build: ## Build ELK and all its extra components.
@docker-compose ${COMPOSE_ALL_FILES} build ${ELK_ALL_SERVICES}
$(DOCKER_COMPOSE_COMMAND) ${COMPOSE_ALL_FILES} build ${ELK_ALL_SERVICES}
ps: ## Show all running containers.
@docker-compose ${COMPOSE_ALL_FILES} ps
$(DOCKER_COMPOSE_COMMAND) ${COMPOSE_ALL_FILES} ps

down: ## Down ELK and all its extra components.
@docker-compose ${COMPOSE_ALL_FILES} down
$(DOCKER_COMPOSE_COMMAND) ${COMPOSE_ALL_FILES} down

stop: ## Stop ELK and all its extra components.
@docker-compose ${COMPOSE_ALL_FILES} stop ${ELK_ALL_SERVICES}
$(DOCKER_COMPOSE_COMMAND) ${COMPOSE_ALL_FILES} stop ${ELK_ALL_SERVICES}

restart: ## Restart ELK and all its extra components.
@docker-compose ${COMPOSE_ALL_FILES} restart ${ELK_ALL_SERVICES}
$(DOCKER_COMPOSE_COMMAND) ${COMPOSE_ALL_FILES} restart ${ELK_ALL_SERVICES}

rm: ## Remove ELK and all its extra components containers.
@docker-compose $(COMPOSE_ALL_FILES) rm -f ${ELK_ALL_SERVICES}
$(DOCKER_COMPOSE_COMMAND) $(COMPOSE_ALL_FILES) rm -f ${ELK_ALL_SERVICES}

logs: ## Tail all logs with -n 1000.
@docker-compose $(COMPOSE_ALL_FILES) logs --follow --tail=1000 ${ELK_ALL_SERVICES}
$(DOCKER_COMPOSE_COMMAND) $(COMPOSE_ALL_FILES) logs --follow --tail=1000 ${ELK_ALL_SERVICES}

images: ## Show all Images of ELK and all its extra components.
@docker-compose $(COMPOSE_ALL_FILES) images ${ELK_ALL_SERVICES}
$(DOCKER_COMPOSE_COMMAND) $(COMPOSE_ALL_FILES) images ${ELK_ALL_SERVICES}

prune: ## Remove ELK Containers and Delete ELK-related Volume Data (the elastic_elasticsearch-data volume)
@make stop && make rm
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Elastdocker differs from `deviantony/docker-elk` in the following points.
> **For Linux's docker hosts only**. By default virtual memory [is not enough](https://www.elastic.co/guide/en/elasticsearch/reference/current/vm-max-map-count.html) so run the next command as root `sysctl -w vm.max_map_count=262144`
3. Start Elastic Stack
```bash
$ make elk <OR> $ docker-compose up -d
$ make elk <OR> $ docker-compose up -d <OR> $ docker compose up -d
```
4. Visit Kibana at [https://localhost:5601](https://localhost:5601) or `https://<your_public_ip>:5601`
Expand Down Expand Up @@ -248,4 +248,4 @@ Copyright (c) 2020 Sherif Abdel-Naby
# Contribution
PR(s) are Open and Welcomed.
PR(s) are Open and Welcomed.

0 comments on commit 83de211

Please sign in to comment.