php-env/makefile
2025-08-21 11:35:28 +03:00

49 lines
1.2 KiB
Makefile

.DEFAULT_GOAL := help
UID = $(shell id -u)
GID = $(shell id -g)
DOCKER_HUB_USER ?= username
IMAGE_NAME ?= php
IMAGE_TAG ?= 8.4
BUILD_TAG ?= $(DOCKER_HUB_USER)/$(IMAGE_NAME):$(IMAGE_TAG)
CONTAINER_NAME ?= $(DOCKER_HUB_USER)-$(IMAGE_NAME)-$(IMAGE_TAG)
DOCKER_COMPOSE = docker-compose -f docker/docker-compose.yaml
help: ## Show this help.
@awk 'BEGIN {FS = ":.*##";} /^[a-zA-Z]/ && !/\?=/ {printf " \033[32m%-15s\033[90m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
install: ## Install docker-compose.
@make up
@${DOCKER_COMPOSE} exec app bash -c "composer install"
up: ## Start dev environment.
@${DOCKER_COMPOSE} up -d --build
down: ## Stop dev environment.
@${DOCKER_COMPOSE} down
restart: ## Restart dev environment.
@${DOCKER_COMPOSE} restart
exec: ## Container shell
@${DOCKER_COMPOSE} exec app bash
build: clear ## Build image.
@docker build --tag="$(BUILD_TAG)" --build-arg UID=$(UID) --build-arg GID=$(GID) -f docker/dockerfile .
push: build ## Publish image
@docker logout
@docker login --username=$(DOCKERHUB_USER)
@docker push $(BUILD_TAG)
clear: ## Cleanup.
@docker rmi -f $(BUILD_TAG)
@docker rm -vf $(CONTAINER_NAME)
vscode-xdebug: ## Publish vscode xdebug config.
@mkdir -p .vscode
@cp docker/conf/launch.json .vscode/launch.json