forked from cowrie/cowrie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
138 lines (107 loc) · 3.68 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# This `Makefile` is intended for Cowrie developers.
# Dummy target `all`
.DEFAULT_GOAL := help
.PHONY: all
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}'
.PHONY: test
test:
tox
.PHONY: build
build:
python setup.py build sdist bdist
.PHONY: docs
docs: ## Create documentation
make -C docs html
.PHONY: lint
lint: ## Run lint checks
tox -e lint
hadolint docker/Dockerfile
.PHONY: clean
clean: ## Clean temporary files
rm -rf _trial_temp build dist src/_trial_temp src/Cowrie.egg-info
make -C docs clean
.PHONY: pre-commit
pre-commit: ## Run pre-commit checks
pre-commit run --all-files
.PHONY: pip-upgrade
pip-upgrade: ## Upgrade environment from requirements.txt
pip install --upgrade -r requirements.txt
.PHONY: pip-check
pip-check: ## Verify python packages
pip check
# This assumes two remotes, one is `origin`, your fork. The second is `cowrie` the main project
.PHONY: git-remote
git-remote: ## Add remote git configuration
git remote add cowrie https://github.com/cowrie/cowrie
.PHONY: pur
pip-pur: ## Upgrade dependencies based on latest packages
git checkout master
-git branch -D "dependency-upgrade-`date -u +%Y-%m-%d`"
git checkout -b "dependency-upgrade-`date -u +%Y-%m-%d`"
pur -r requirements.txt
pur -r requirements-dev.txt
pur -r requirements-output.txt
git commit -m "dependency upgrade `date -u`" requirements*.txt
# 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