2019-05-12 13:58:14 +00:00
|
|
|
# This `Makefile` is intended for Cowrie developers.
|
2019-05-04 16:34:16 +00:00
|
|
|
|
2021-10-22 06:19:55 +00:00
|
|
|
|
2019-05-04 16:34:16 +00:00
|
|
|
# Dummy target `all`
|
2021-10-22 06:19:55 +00:00
|
|
|
.DEFAULT_GOAL := help
|
2021-03-29 16:47:45 +00:00
|
|
|
.PHONY: all
|
2021-10-22 06:19:55 +00:00
|
|
|
all: help
|
|
|
|
@echo $(COMMIT)--
|
|
|
|
|
|
|
|
help:
|
|
|
|
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
2019-05-04 16:34:16 +00:00
|
|
|
|
2021-03-29 16:47:45 +00:00
|
|
|
.PHONY: test
|
2019-05-12 17:38:49 +00:00
|
|
|
test:
|
|
|
|
tox
|
2019-05-04 16:34:16 +00:00
|
|
|
|
2021-03-29 16:47:45 +00:00
|
|
|
.PHONY: build
|
2019-05-04 16:34:16 +00:00
|
|
|
build:
|
|
|
|
python setup.py build sdist bdist
|
|
|
|
|
2021-03-29 16:47:45 +00:00
|
|
|
.PHONY: docs
|
2021-10-22 06:19:55 +00:00
|
|
|
docs: ## Create documentation
|
2019-05-04 16:34:16 +00:00
|
|
|
make -C docs html
|
2019-05-12 13:58:14 +00:00
|
|
|
|
2021-03-29 16:47:45 +00:00
|
|
|
.PHONY: lint
|
2021-10-22 06:19:55 +00:00
|
|
|
lint: ## Run lint checks
|
2019-05-12 17:38:49 +00:00
|
|
|
tox -e lint
|
2021-10-22 06:19:55 +00:00
|
|
|
hadolint docker/Dockerfile
|
2019-05-12 13:58:14 +00:00
|
|
|
|
2021-03-29 16:47:45 +00:00
|
|
|
.PHONY: clean
|
2021-10-22 06:19:55 +00:00
|
|
|
clean: ## Clean temporary files
|
2021-05-14 07:43:28 +00:00
|
|
|
rm -rf _trial_temp build dist src/_trial_temp src/Cowrie.egg-info
|
2021-05-03 15:42:25 +00:00
|
|
|
make -C docs clean
|
2019-05-12 13:58:14 +00:00
|
|
|
|
2021-03-29 16:47:45 +00:00
|
|
|
.PHONY: pre-commit
|
2021-10-22 06:19:55 +00:00
|
|
|
pre-commit: ## Run pre-commit checks
|
2021-03-29 16:47:45 +00:00
|
|
|
pre-commit run --all-files
|
|
|
|
|
|
|
|
.PHONY: pip-upgrade
|
2021-10-22 06:19:55 +00:00
|
|
|
pip-upgrade: ## Upgrade environment from requirements.txt
|
2019-05-12 13:58:14 +00:00
|
|
|
pip install --upgrade -r requirements.txt
|
|
|
|
|
2021-03-29 16:47:45 +00:00
|
|
|
.PHONY: pip-check
|
2021-10-22 06:19:55 +00:00
|
|
|
pip-check: ## Verify python packages
|
2019-05-12 13:58:14 +00:00
|
|
|
pip check
|
2019-05-29 01:17:45 +00:00
|
|
|
|
|
|
|
# This assumes two remotes, one is `origin`, your fork. The second is `cowrie` the main project
|
2021-03-29 16:47:45 +00:00
|
|
|
.PHONY: git-remote
|
2021-10-22 06:19:55 +00:00
|
|
|
git-remote: ## Add remote git configuration
|
2019-05-29 01:17:45 +00:00
|
|
|
git remote add cowrie https://github.com/cowrie/cowrie
|
|
|
|
|
2021-10-22 06:19:55 +00:00
|
|
|
.PHONY: pur
|
|
|
|
pip-pur: ## Upgrade dependencies based on latest packages
|
2019-05-29 01:17:45 +00:00
|
|
|
git checkout master
|
2021-01-24 03:14:19 +00:00
|
|
|
-git branch -D "dependency-upgrade-`date -u +%Y-%m-%d`"
|
2020-11-10 04:26:09 +00:00
|
|
|
git checkout -b "dependency-upgrade-`date -u +%Y-%m-%d`"
|
2020-07-03 07:24:45 +00:00
|
|
|
pur -r requirements.txt
|
|
|
|
pur -r requirements-dev.txt
|
2021-05-23 07:12:53 +00:00
|
|
|
pur -r requirements-output.txt
|
2020-11-10 04:26:09 +00:00
|
|
|
git commit -m "dependency upgrade `date -u`" requirements*.txt
|
2021-10-22 06:19:55 +00:00
|
|
|
# This Makefile is for developers and is not required to run Cowrie
|
|
|
|
|
|
|
|
# The binary to build (just the basename).
|
|
|
|
MODULE := cowrie
|
|
|
|
|
|
|
|
# Where to push the docker image.
|
|
|
|
#REGISTRY ?= docker.pkg.github.com/cowrie/cowrie
|
|
|
|
REGISTRY ?= cowrie
|
|
|
|
|
|
|
|
IMAGE := $(REGISTRY)/$(MODULE)
|
|
|
|
|
|
|
|
IMAGENAME := cowrie/cowrie
|
|
|
|
CONTAINERNAME := cowrie
|
|
|
|
|
|
|
|
BUILD_DATE = $(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
|
|
|
|
TAG=$(shell git rev-parse --short=8 HEAD)
|
|
|
|
|
|
|
|
.PHONY: docker-build
|
|
|
|
docker-build: docker/Dockerfile ## Build Docker image
|
|
|
|
#docker build -t ${IMAGENAME}:${TAG} --no-cache --build-arg TAG=${TAG} --build-arg BUILD_DATE=${BUILD_DATE} -f docker/Dockerfile .
|
|
|
|
docker build -t ${IMAGENAME}:${TAG} --build-arg BUILD_DATE=${BUILD_DATE} -f docker/Dockerfile .
|
|
|
|
|
|
|
|
.PHONY: docker-run
|
|
|
|
docker-run: docker-start ## Run Docker container
|
|
|
|
|
|
|
|
.PHONY: docker-push
|
|
|
|
docker-push: docker-build ## Push Docker image to Docker Hub
|
|
|
|
@echo "Pushing image to GitHub Docker Registry...\n"
|
|
|
|
docker push $(IMAGE):$(TAG)
|
|
|
|
docker tag $(IMAGE):$(TAG) $(IMAGE):latest
|
|
|
|
docker push $(IMAGE):latest
|
|
|
|
|
|
|
|
.PHONY: docker-start
|
|
|
|
docker-start: docker-create-volumes ## Start Docker container
|
|
|
|
docker run -p 2222:2222/tcp \
|
|
|
|
-p 2223:2223/tcp \
|
|
|
|
-v cowrie-etc:/cowrie/cowrie-git/etc \
|
|
|
|
-v cowrie-var:/cowrie/cowrie-git/var \
|
|
|
|
-d \
|
|
|
|
--cap-drop=ALL \
|
|
|
|
--read-only \
|
|
|
|
--name ${CONTAINERNAME} ${IMAGENAME}:${TAG}
|
|
|
|
|
|
|
|
.PHONY: docker-stop
|
|
|
|
docker-stop: ## Stop Docker Container
|
|
|
|
docker stop ${CONTAINERNAME}
|
|
|
|
|
|
|
|
.PHONY: docker-rm
|
|
|
|
docker-rm: docker-stop ## Delete Docker Container
|
|
|
|
docker rm ${CONTAINERNAME}
|
|
|
|
|
|
|
|
.PHONY: docker-clean
|
|
|
|
docker-clean: docker-rm ## Clean
|
|
|
|
docker rmi ${IMAGENAME}:${TAG}
|
|
|
|
|
|
|
|
.PHONY: docker-shell
|
|
|
|
docker-shell: ## Start shell in running Docker container
|
|
|
|
@docker exec -it ${CONTAINERNAME} bash
|
|
|
|
|
|
|
|
.PHONY: docker-logs
|
|
|
|
docker-logs: ## Show Docker container logs
|
|
|
|
@docker logs ${CONTAINERNAME}
|
|
|
|
|
|
|
|
.PHONY: docker-ps
|
|
|
|
docker-ps:
|
|
|
|
@docker ps -f name=${CONTAINERNAME}
|
|
|
|
|
|
|
|
.PHONY: docker-status
|
|
|
|
docker-status: docker-ps ## List running Docker containers
|
|
|
|
|
|
|
|
.PHONY: docker-ip
|
|
|
|
docker-ip: ## List IP of running Docker container
|
|
|
|
@docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${CONTAINERNAME}
|
|
|
|
|
|
|
|
.PHONY: docker-create-volumes
|
|
|
|
docker-create-volumes:
|
|
|
|
docker volume create cowrie-var
|
|
|
|
docker volume create cowrie-etc
|