#!/usr/bin/make

SHELL = /bin/sh

USER_UID := $(shell id -u)
USER_UNAME := $(shell id -un)
USER_GID := $(shell id -g)
USER_GNAME := $(shell id -gn)
DATE_NOW := $(shell date '+%Y-%m-%d_%H%M%S')

export USER_UID
export USER_UNAME
export USER_GID
export USER_GNAME
# export DATE_NOW


pull:
		docker-compose pull

build:
		docker-compose build --build-arg USER_UID=$(USER_UID) --build-arg USER_UNAME=$(USER_UNAME) --build-arg USER_GID=$(USER_GID) --build-arg USER_GNAME=$(USER_GNAME)

buildnc:
		docker-compose build --no-cache --build-arg USER_UID=$(USER_UID) --build-arg USER_UNAME=$(USER_UNAME) --build-arg USER_GID=$(USER_GID) --build-arg USER_GNAME=$(USER_GNAME)

build_php:
		docker-compose build --build-arg USER_UID=$(USER_UID) --build-arg USER_UNAME=$(USER_UNAME) --build-arg USER_GID=$(USER_GID) --build-arg USER_GNAME=$(USER_GNAME) php

buildnc_php:
		docker-compose build --no-cache --build-arg USER_UID=$(USER_UID) --build-arg USER_UNAME=$(USER_UNAME) --build-arg USER_GID=$(USER_GID) --build-arg USER_GNAME=$(USER_GNAME) php

buildnc_mysql:
		docker-compose build --no-cache --build-arg USER_UID=$(USER_UID) --build-arg USER_UNAME=$(USER_UNAME) --build-arg USER_GID=$(USER_GID) --build-arg USER_GNAME=$(USER_GNAME) mysql

downbuildup: down build up

up:
		docker-compose up -d

ps:
		docker-compose ps

logs:
		docker-compose logs -f

restart_php:
		docker-compose restart php


d9_maj_config: d9_crd d9_ext d9_composer_install d9_updb d9_cim d9_sync_struct d9_cr d9_pag

d9_crd:
		docker exec eql-php-1 /bin/bash -c "vendor/bin/drush cache-clear drush"

d9_ext:
		docker exec eql-php-1 /bin/bash -c "vendor/bin/drush cdi1 config/sync/core.extension.yml"

d9_composer_install:
		docker exec eql-php-1 /bin/bash -c "composer install"

d9_cr:
		docker exec eql-php-1 /bin/bash -c "vendor/bin/drush cr"

d9_updb:
		docker exec eql-php-1 /bin/bash -c "vendor/bin/drush updb -y"

d9_cim:
		docker exec eql-php-1 /bin/bash -c "vendor/bin/drush config-import -y"

d9_sync_struct:
		docker exec eql-php-1 /bin/bash -c "vendor/bin/drush im --choice full && vendor/bin/drush ib --choice full & vendor/bin/drush it --choice full"

d9_pag:
		docker exec eql-php-1 /bin/bash -c "vendor/bin/drush pag all canonical_entities:node && vendor/bin/drush pag all canonical_entities:taxonomy_term"


down:
		docker-compose down

exec_nginx:
		docker exec -it eql-nginx-1 bash

exec_php:
		docker exec -it eql-php-1 bash

exec_mysql:
		docker exec -it eql-mysql-1 bash

dump_d9_db:
	docker exec eql-mysql-1 sh -c 'exec mysqldump -uroot -peql eql' > ./ressources/eql-$(DATE_NOW)-local.sql
