Skip to content
Snippets Groups Projects
Makefile 2.59 KiB
Newer Older
Vincent Mazenod's avatar
Vincent Mazenod committed
BOLD    := \033[1m
RESET   := \033[0m
RED     := \033[31m
GREEN   := \033[32m
YELLOW  := \033[33m
BLUE    := \033[34m
MAGENTA := \033[35m

SHELL    := /bin/bash
Vincent Mazenod's avatar
Vincent Mazenod committed
IMAGES   := $(shell docker compose config --services)
Vincent Mazenod's avatar
Vincent Mazenod committed
TAG      := $(shell git rev-parse --short HEAD)
VOLUMES  := content/node_modules output

# Executables (local)
Vincent Mazenod's avatar
Vincent Mazenod committed
DOCKER_COMP   := docker compose
Vincent Mazenod's avatar
Vincent Mazenod committed
.DEFAULT_GOAL := help

# Docker containers
Vincent Mazenod's avatar
Vincent Mazenod committed
KERBEROS_CONT  := $(DOCKER_COMP) run kerberos
Vincent Mazenod's avatar
Vincent Mazenod committed

include .env

build: ## Build required docker compose images
	@$(DOCKER_COMP) build
.PHONY: build	

push: ## Push build docker compose images
Vincent Mazenod's avatar
Vincent Mazenod committed
	@TAG=$(shell git rev-parse --short HEAD)
Vincent Mazenod's avatar
Vincent Mazenod committed
	@docker login ${REGISTRY_URL}
Vincent Mazenod's avatar
Vincent Mazenod committed
	@docker push ${NAMESPACE}/${APP_NAME}_python:latest ;
	@docker tag ${NAMESPACE}/${APP_NAME}_python:latest ${NAMESPACE}/${APP_NAME}_python:${TAG} ;
	@docker push ${NAMESPACE}/${APP_NAME}_python:${TAG} ;
	@docker push ${NAMESPACE}/${APP_NAME}_kerberos:latest ;
	@docker tag ${NAMESPACE}/${APP_NAME}_kerberos:latest ${NAMESPACE}/${APP_NAME}_kerberos:${TAG} ;
	@docker push ${NAMESPACE}/${APP_NAME}_kerberos:${TAG} ;
Vincent Mazenod's avatar
Vincent Mazenod committed
.PHONY: push

up: ## Make required containers up
Vincent Mazenod's avatar
Vincent Mazenod committed
	@$(DOCKER_COMP) up --remove-orphans node
Vincent Mazenod's avatar
Vincent Mazenod committed
	@echo -e "⏰ ${BOLD}${GREEN}Wait for node to install needed js (there's no problem we're just wait)...${RESET}"
	@$(DOCKER_COMP) run dockerize -timeout 180s -wait-retry-interval 3s \
			-wait file:///tmp/content/node_modules/.yarn-integrity ;
	@echo -e "⏰ ${BOLD}${GREEN}Wait for pelican to generate content (there's no problem we're just wait)...${RESET}"
	@echo -e "${GREEN}${BOLD}up and running${RESET}"
	@echo -e " 🐳 blog in docker ${BLUE}${BOLD}http://localhost:${PORT}${RESET}"
Vincent Mazenod's avatar
Vincent Mazenod committed
	@$(DOCKER_COMP) up --remove-orphans python
Vincent Mazenod's avatar
Vincent Mazenod committed
.PHONY: up

down: ## Make required containers down
	@$(DOCKER_COMP) down
.PHONY: down

logs: ## Show live containers logs. Pass the parameter "c=" to see one specific container's logs, example: make logs c='frontend'
	@$(eval c ?=)
	@if [ -z "$(c)" ]; then \
		$(DOCKER_COMP) logs --follow; \
	else \
		$(DOCKER_COMP) logs --timestamps --follow $(c); \
	fi 
.PHONY: logs

errors: ## Show live container errors.
	@$(DOCKER_COMP) logs | grep error
.PHONY: errors

Vincent Mazenod's avatar
Vincent Mazenod committed
publish: ## Open bash on php container
	@$(KERBEROS_CONT) bash .docker/scripts/kerberos/command.dev.sh
.PHONY: publish
Vincent Mazenod's avatar
Vincent Mazenod committed

clean: ## Remove node and php folders and files
	@for volume in ${VOLUMES} ; do \
		sudo rm -rf $${volume} ; \
	done
.PHONY: clean

Vincent Mazenod's avatar
Vincent Mazenod committed
slides: ## Force slides refresh
	@sudo cp -R content/slides output/
.PHONY: slides

Vincent Mazenod's avatar
Vincent Mazenod committed
help:
	@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: help