CI_COMPOSE=FIXUID=$(shell id -u) FIXGID=$(shell id -g) docker-compose -f docker-compose.yml
HYDRA_SQL_SHELL_USER ?= www-data:
DOCKER_CMD ?=
DOCKER_IMAGE_NAME ?= login-app-sql_hydra-sql
up:
	FIXUID=$(shell id -u) FIXGID=$(shell id -g) docker-compose up --build

down:
	docker-compose down -v

purge:
	docker-compose down -v --remove-orphans --rmi local

hydra-sql-shell:
	$(CI_COMPOSE) exec \
		-u "$(HYDRA_SQL_SHELL_USER)" \
		hydra-sql \
		/bin/bash


APP_LOCALES ?= fr,en
HYDRA_ADMIN_BASE_URL ?= http://hydra:4445
TRUSTED_PROXIES ?= 127.0.0.1,REMOTE_ADDR,localhost
ISSUER_URL ?= http://localhost:8000
BASE_URL ?= http://localhost:8080
DB_USER ?= lasql
DB_PASSWORD ?= lasql
DEFAULT_LOCALE ?= fr
BDD ?= postgres
DSN_REMOTE_DATABASE=mysql:host=mariadb;port=3306;dbname=lasql

up-mysql:
	docker run \
		-it --rm \
		-p 8080:80 \
		-e APP_LOCALES=$(APP_LOCALES) \
		-e HYDRA_ADMIN_BASE_URL=$(HYDRA_ADMIN_BASE_URL) \
		-e TRUSTED_PROXIES=$(TRUSTED_PROXIES) \
		-e ISSUER_URL=$(ISSUER_URL) \
		-e BASE_URL=$(BASE_URL) \
		-e DB_USER=$(DB_USER) \
		-e DB_PASSWORD=$(DB_PASSWORD) \
		-e DEFAULT_LOCALE=$(DEFAULT_LOCALE) \
		-e DSN_REMOTE_DATABASE=$(DSN_REMOTE_DATABASE) \
		$(DOCKER_IMAGE_NAME):latest \
		$(DOCKER_CMD)