Skip to content

Instantly share code, notes, and snippets.

@fhuitelec
Last active January 4, 2018 14:34
Show Gist options
  • Save fhuitelec/ea9a83ffcc1ac01004d3c69f6757c519 to your computer and use it in GitHub Desktop.
Save fhuitelec/ea9a83ffcc1ac01004d3c69f6757c519 to your computer and use it in GitHub Desktop.
[Makefile skeleton] #makefile #skeleton #php
PHP_VERSION=7.1
PROJECT_NAME="Your project name here"
FORMATTED_PROJECT_NAME=your-project-name-here
# ######### #
# VARIABLES #
# ######### #
# Load global environment variables from .env
include .env
export $(shell sed 's/=.*//' .env)
# ####### #
# TARGETS #
# ####### #
.PHONY: a-cool-target
a-cool-target:
@echo Project ID: $(PROJECT_ID)
@echo PHP version: $(PHP_VERSION)
toto:
@echo toto
# ######### #
# INTERNALS #
# ######### #
# Some logic to get a unique project identifier - for docker-compose jobs for example:
# - to avoid container name collision
# - but to keep meaningful name
# Example: your-project-name_run-tests_0b23a
export RANDOM_SLUG = $(shell LC_ALL=C tr -dc 'a-f0-9' </dev/urandom | head -c 5 ; echo)
export FORMATTED_CURRENT_TARGET = $(shell echo $(MAKECMDGOALS) | tr '[ ]' -)
export PROJECT_ID = $(FORMATTED_PROJECT_NAME)_$(FORMATTED_CURRENT_TARGET)_$(RANDOM_SLUG)
# Docker partial commands
export COMPOSER_COMPOSE_EXEC = docker-compose -f infrastructure/dev/composer.docker-compose.yaml
export DOCKER_EXEC = docker run -ti --rm --name ${PROJECT_NAME} --volume ${PWD}:/app --workdir /app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment