forked from cowrie/cowrie
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
142 lines (108 loc) · 4.13 KB
/
Makefile
File metadata and controls
142 lines (108 loc) · 4.13 KB
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
139
140
141
142
# This `Makefile` is intended for Cowrie developers.
# Set default docker binary to docker in path if not specified.
# This allows you to use other container runtimes (such as podman)
# For example, to build with podman: DOCKER=podman make docker-build
DOCKER?=docker
# 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 -m build
.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
python -m pip install --upgrade -r requirements.txt
.PHONY: pip-check
pip-check: ## Verify python packages
python -m 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
# 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)
CONTAINERNAME := cowrie
PLATFORM := linux/amd64,linux/arm64
BUILD_DATE = $(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
TAG=$(shell git rev-parse --short=8 HEAD)
export SETUPTOOLS_SCM_PRETEND_VERSION_FOR_COWRIE := $(shell python -m setuptools_scm --force-write-version-files)
.PHONY: docker-build
docker-build: docker/Dockerfile ## Build Docker image
-$(DOCKER) buildx create --append --name cowrie-builder
$(DOCKER) buildx use cowrie-builder
$(DOCKER) buildx build --sbom=true --provenance=true --platform ${PLATFORM} -t ${IMAGE}:${TAG} -t ${IMAGE}:latest --build-arg BUILD_DATE=${BUILD_DATE} -f docker/Dockerfile .
.PHONY: docker-load
docker-load: docker-build ## Load Docker image
-$(DOCKER) buildx create --append --name cowrie-builder
$(DOCKER) buildx use cowrie-builder
$(DOCKER) buildx build --load -t ${IMAGE}:${TAG} -t ${IMAGE}:latest --build-arg BUILD_DATE=${BUILD_DATE} -f docker/Dockerfile .
.PHONY: docker-build ## Push Docker image
docker-push: ## Push Docker image to Docker Hub
-$(DOCKER) buildx create --append --name cowrie-builder
@echo "Pushing image to GitHub Docker Registry...\n"
$(DOCKER) buildx use cowrie-builder
$(DOCKER) buildx build --sbom=true --provenance=true --platform ${PLATFORM} -t ${IMAGE}:${TAG} -t ${IMAGE}:latest --build-arg BUILD_DATE=${BUILD_DATE} -f docker/Dockerfile --push .
.PHONY: docker-run
docker-run: docker-start ## Run Docker container
.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} ${IMAGE}:${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 ${IMAGE}:${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