87 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			Makefile
		
	
	
	
	
	
			
		
		
	
	
			87 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			Makefile
		
	
	
	
	
	
.DEFAULT_GOAL := help
 | 
						|
 | 
						|
.PHONY: help
 | 
						|
help:  ## Show help
 | 
						|
	@grep -E '^[\.a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
 | 
						|
	| awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
 | 
						|
 | 
						|
.PHONY: env_file
 | 
						|
env_file:  ## Generate .gen.env file from env with "LENOCHKA_" prefix.
 | 
						|
	touch .gen.env && env | grep -E '^LENOCHKA_' > ".gen.env" || echo "No env vars"
 | 
						|
	test -f .env && cat .env > .gen.env || echo ".env file not found"
 | 
						|
 | 
						|
.PHONY: build
 | 
						|
build: env_file ## Build docker container image.
 | 
						|
	docker-compose \
 | 
						|
	-f ./deploy/docker-compose.yml \
 | 
						|
	--project-directory . \
 | 
						|
	build --pull lenochka
 | 
						|
 | 
						|
.PHONY: build_test
 | 
						|
build-test: ## Build image for tests.
 | 
						|
	docker-compose \
 | 
						|
	-f ./deploy/docker-compose.test.yml \
 | 
						|
	--project-directory . \
 | 
						|
	build --no-cache test_lenochka
 | 
						|
 | 
						|
.PHONY: flake8
 | 
						|
flake8:  ## Run flake8 check
 | 
						|
	docker-compose \
 | 
						|
	-f ./deploy/docker-compose.test.yml \
 | 
						|
	--project-directory . \
 | 
						|
	run test_lenochka flake8 --count .
 | 
						|
 | 
						|
.PHONY: black
 | 
						|
black:  ## Run black check
 | 
						|
	docker-compose \
 | 
						|
	-f ./deploy/docker-compose.test.yml \
 | 
						|
	--project-directory . \
 | 
						|
	run test_lenochka black --check .
 | 
						|
 | 
						|
.PHONY: mypy
 | 
						|
mypy: ## Run pytest tests
 | 
						|
	docker-compose \
 | 
						|
	-f ./deploy/docker-compose.test.yml \
 | 
						|
	--project-directory . \
 | 
						|
	run test_lenochka mypy .
 | 
						|
 | 
						|
.PHONY: pytest
 | 
						|
pytest: ## Run pytest tests
 | 
						|
	docker-compose \
 | 
						|
	-f ./deploy/docker-compose.test.yml \
 | 
						|
	--project-directory . \
 | 
						|
	run test_lenochka pytest -v --cov=lenochka
 | 
						|
 | 
						|
.PHONY: push
 | 
						|
push: env_file ## Push container to the registry.
 | 
						|
	docker-compose \
 | 
						|
	-f ./deploy/docker-compose.yml \
 | 
						|
	--project-directory . \
 | 
						|
	push lenochka
 | 
						|
 | 
						|
.PHONY: pull
 | 
						|
pull: env_file  ## Download images from docker hub.
 | 
						|
	docker-compose \
 | 
						|
	    -f deploy/docker-compose.yml \
 | 
						|
	    --project-directory . \
 | 
						|
	    pull --ignore-pull-failures lenochka \
 | 
						|
	|| \
 | 
						|
	docker-compose \
 | 
						|
	    -f deploy/docker-compose.yml \
 | 
						|
	    --project-directory . \
 | 
						|
	    pull lenochka
 | 
						|
 | 
						|
.PHONY: deploy-prod
 | 
						|
deploy-prod: pull  ## deploy container in production.
 | 
						|
	docker-compose \
 | 
						|
	-f ./deploy/docker-compose.yml \
 | 
						|
	--project-directory . \
 | 
						|
	up -d
 | 
						|
 | 
						|
.PHONY: clear-test
 | 
						|
clear-test:  ## Remove containers and images for test
 | 
						|
	docker-compose \
 | 
						|
	-f ./deploy/docker-compose.test.yml \
 | 
						|
	--project-directory . \
 | 
						|
	down --rmi=all
 |