Created
October 11, 2019 22:58
-
-
Save yaredc/6e0598bc3d433973e3125fe712fa06a6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.PHONY:up down build install uninstall clean dist | |
SHELL:=/bin/sh | |
ENV?=dev | |
TIMESTAMP:=$(shell date +"%Y.%m.%d.%H.%M.%S") | |
DIR_DIST:=$(shell pwd)/dist | |
TAR_DIST:=$(shell pwd)/dist.$(ENV).$(shell date +%s).tar.gz | |
DIR_ROOT:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) | |
DIR_MAKE:=$(shell mkdir -p $(shell pwd)/.make) | |
RUNNING_CONTAINERS_IDS:=$(shell docker-compose ps -q) | |
BUILD_PRE:=docker-compose.yaml $(shell ls -d .docker/dev/*) | |
up: .make/.build | |
ifeq ($(RUNNING_CONTAINERS_IDS),) | |
docker-compose up -d | |
docker-compose exec php composer config --global github-oauth.github.com TOKEN | |
else | |
@echo "docker-compose daemon IS running." | |
endif | |
down: | |
ifeq ($(RUNNING_CONTAINERS_IDS),) | |
@echo "docker-compose daemon IS NOT running." | |
else | |
docker-compose down | |
endif | |
.make/.build: $(BUILD_PRE) | |
docker-compose build | |
touch .make/.build | |
build: .make/.build #ALIAS | |
@echo "build ~ .make/.build" | |
install: up | |
docker-compose exec php composer --no-interaction validate | |
docker-compose run node npm install | |
ifeq ($(ENV),dev) | |
docker-compose exec php composer --no-interaction install | |
docker-compose run node npm run build:dev | |
else | |
docker-compose exec php composer --no-suggest --no-dev --classmap-authoritative --optimize-autoloader --no-interaction install | |
docker-compose run node npm run build:prod | |
endif | |
cp -rf ${DIR_ROOT}/.config/$(ENV)/* ${DIR_ROOT} | |
uninstall: up | |
docker-compose exec php rm -rf ./vendor | |
docker-compose run node rm -rf ./node_modules | |
clean: up | |
docker-compose exec php rm -rf ./data | |
docker-compose exec php mkdir -p ./data/cache | |
find ${DIR_ROOT} -maxdepth 1 -name "dist*tar.gz" -type f -delete | |
rm -rf ${DIR_DIST} | |
dist: | |
find . -maxdepth 1 -name "dist*tar.gz" -type f -delete | |
rm -rf ${DIR_DIST} | |
mkdir -p ${DIR_DIST} | |
rsync -az --exclude ".*" \ | |
--exclude "/data" \ | |
--exclude "/dist" \ | |
--exclude "/test" \ | |
--exclude "/node_modules" \ | |
--exclude "/composer.json" \ | |
--exclude "/composer.lock" \ | |
--exclude "/package.json" \ | |
--exclude "/package-lock.json" \ | |
--exclude "/readme.md" \ | |
--exclude "/build.xml" \ | |
--exclude "/makefile" \ | |
--exclude "/build" \ | |
--exclude "/tsconfig.json" \ | |
--exclude "/docker-compose.yaml" \ | |
--exclude "/webpack.config.js" \ | |
--exclude "*.log" \ | |
-- "${DIR_ROOT}/" ${DIR_DIST} | |
tar -C ${DIR_DIST} -zcf ${TAR_DIST} . |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment