NAME 			=learnsteam/learnsteam-quiz
ECR				=384080715421.dkr.ecr.ap-northeast-2.amazonaws.com
REPOSITORY=$(ECR)/$(NAME)
VERSION		=v1.0.0
BUILD 		=1
TAG 			=$(VERSION)-$(BUILD)
TIMESTAMP =`date +%s`
PLATFORM	=linux/amd64


default: help

env.local: ## env for local
	@cp .env.local.sample .env

env.dev: ## env for development
	@cp .env.dev.sample .env

env.prod:	## env for production
	@cp .env.prod.sample .env

run: env.local	## run local
	@echo "\033[32mRunning ...\033[0m"
	@yarn dev
.PHONY: run

build: env.prod	## build for production
	@echo "\033[32mBuilding ...\033[0m"
	@yarn build

build.prod: env.prod	## build for production with env
	@echo "\033[32mBuilding ... for production\033[0m"
	@yarn build


docker.build.local: ## build docker for local running
	@echo "\033[32mDocker for local ...\033[0m"
	@docker compose -f docker/local/docker-compose.yml build --no-cache
	@docker compose -f docker/local/docker-compose.yml create
.PHONY: docker.build.local

docker.start.local: ## start docker for local
	@echo "\033[32mDocker start ...\033[0m"
	@docker compose -f docker/local/docker-compose.yml up -d
.PHONY: docker.start.local

docker.stop.local:    ## stop docker for local
	@echo "\033[32mDocker stop ...\033[0m"
	@docker compose -f docker/local/docker-compose.yml down
.PHONY: docker.stop.local


docker.build.dev: ## build docker for development
	@echo "\033[32mDocker for development ...\033[0m"
	@docker compose -f docker/dev/docker-compose.yml build --no-cache
	@docker compose -f docker/dev/docker-compose.yml create
.PHONY: docker.build.dev

docker.start.dev: ## start docker for development
	@echo "\033[32mDocker start for development...\033[0m"
	@docker compose -f docker/dev/docker-compose.yml up -d
.PHONY: docker.start.dev

docker.stop.dev: ## stop docker for development
	@echo "\033[32mDocker stop for development...\033[0m"
	@docker compose -f docker/dev/docker-compose.yml down
.PHONY: docker.stop.dev


docker.build.prod: ## build docker for production
	@echo "\033[32mDocker for production ...\033[0m"
	@docker compose -f docker/prod/docker-compose.yml build --no-cache
	@docker compose -f docker/prod/docker-compose.yml create
.PHONY: docker.build.prod

docker.start.prod: ## start docker for production
	@echo "\033[32mDocker start for production...\033[0m"
	@docker compose -f docker/prod/docker-compose.yml up -d
.PHONY: docker.start.prod

docker.stop.prod: ## stop docker for production
	@echo "\033[32mDocker stop for production...\033[0m"
	@docker compose -f docker/prod/docker-compose.yml down
.PHONY: docker.stop.prod


clean:
	@echo "\033[32mCleaning...\033[0m"
	@rm -rf .next
.PHONY: clean

help: ## Show help for each of the Makefile recipes.
	@grep -E '^[a-zA-Z0-9 -.]+:.*#'  $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: help