Skip to content

Commit

Permalink
⚡️ IMPROVE: rename docker compose files and update make command
Browse files Browse the repository at this point in the history
  • Loading branch information
asapdotid committed May 31, 2023
1 parent 95d5705 commit 82b12a7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
14 changes: 13 additions & 1 deletion .make/01-00-commands.mk
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
##@ [Commands]
##@ [Utility Commands]

# @see https://stackoverflow.com/a/43076457
.PHONY: execute-in-container
execute-in-container: ## Execute a command in a container. E.g. via "make execute-in-container DOCKER_SERVICE_NAME=traefik COMMAND="echo 'hello'"
@$(if $(DOCKER_SERVICE_NAME),,$(error DOCKER_SERVICE_NAME is undefined))
@$(if $(COMMAND),,$(error COMMAND is undefined))
$(EXECUTE_IN_ANY_CONTAINER) $(COMMAND)

.PHONY: traefik-shell
traefik-shell: ## Execute shell script in Traefik container with arguments ARGS="pwd"
@$(EXECUTE_IN_TRAEFIK_CONTAINER) $(ARGS);

.PHONY: logger-shell
logger-shell: ## Execute shell script in Logger container with arguments ARGS="pwd"
@$(EXECUTE_IN_LOGGER_CONTAINER) $(ARGS);

.PHONY: socket-shell
socket-shell: ## Execute shell script in Socket container with arguments ARGS="pwd"
@$(EXECUTE_IN_DOCKER_SOCKET_CONTAINER) $(ARGS);
7 changes: 4 additions & 3 deletions .make/02-00-docker.mk
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ DOCKER_SERVICE_NAME_LOGGER:=logger
DOCKER_DIR:=${PWD}/src
DOCKER_ENV_FILE:=$(DOCKER_DIR)/.env
DOCKER_COMPOSE_DIR:=$(DOCKER_DIR)/compose
DOCKER_COMPOSE_FILE:=$(DOCKER_COMPOSE_DIR)/docker-compose.yml
DOCKER_COMPOSE_FILE_ENV:=$(DOCKER_COMPOSE_DIR)/docker-compose.$(ENV).yml
DOCKER_COMPOSE_FILE:=$(DOCKER_COMPOSE_DIR)/compose.yml
DOCKER_COMPOSE_FILE_ENV:=$(DOCKER_COMPOSE_DIR)/compose.$(ENV).yml

# we need a couple of environment variables for docker-compose so we define a make-variable that we can
# then reference later in the Makefile without having to repeat all the environment variables
Expand Down Expand Up @@ -64,6 +64,7 @@ ifndef EXECUTE_IN_CONTAINER
endif
ifeq ($(EXECUTE_IN_CONTAINER),true)
EXECUTE_IN_ANY_CONTAINER:=$(DOCKER_COMPOSE) exec -T $(DOCKER_SERVICE_NAME)
EXECUTE_IN_TRAEFIK_CONTAINER:=$(DOCKER_COMPOSE) exec -T $(DOCKER_SERVICE_NAME_TRAEFIK)
EXECUTE_IN_DOCKER_SOCKET_CONTAINER:=$(DOCKER_COMPOSE) exec -T $(DOCKER_SERVICE_NAME_DOCKER_SOCKET)
EXECUTE_IN_LOGGER_CONTAINER:=$(DOCKER_COMPOSE) exec -T $(DOCKER_SERVICE_NAME_LOGGER)
endif
Expand Down Expand Up @@ -101,7 +102,7 @@ docker-build: docker-build-image ## Build the php image and then all other docke
docker-prune: ## Remove ALL unused docker resources, including volumes
@docker system prune -a -f --volumes

##@ [Docker Compose]
##@ [Docker: Compose]

.PHONY: compose-up
compose-up: validate-docker-variables ## Create and start all docker containers. To create/start only a specific container, use DOCKER_SERVICE_NAME=<service>
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 82b12a7

Please sign in to comment.