-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
67 lines (51 loc) · 1.87 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
#
# Copyright (c) 2020, Pixels Camp
#
ifneq (,$(wildcard ./.make))
include .make
export
endif
#
# To configure SSH access for the deployment host, create a ".make" file
# in the same directory as this Makefile setting these three variables.
#
SSH_USER ?= pixel
SSH_HOST ?= red-october.pixels.camp
SSH_PORT ?= 22
# This can also be set from the ".env" file...
TRIGGER_TEXT ?= Sean Connery
RESPONSE_FILE ?= data/sean_connery.txt
LOG_FILE ?= /dev/stdout
# Must be evaluated on assignment, or trouble will ensue...
DOCKER_LABEL := $(shell date +%Y%m%d-%H%M%S)-$(shell git rev-parse --short HEAD)
SSH_HOST_CMD := ssh -q -l $(SSH_USER) $(SSH_HOST) -p $(SSH_PORT)
all: test build # ...do not deploy, to avoid accidents.
update-images:
awk '/^FROM[[:space:]]+/ {print $$2}' Dockerfile | xargs -I{} docker pull {}
clean:
find . -name '*~' -type f -delete
find . -name '*.pyc' -type f -delete
find . -name '__pycache__' -type d -delete
find . -name '*.egg-info' -type d -delete
build:
flake8 src
docker build -t ping-responder:latest -f Dockerfile .
push: build
docker save ping-responder:latest | gzip | $(SSH_HOST_CMD) -- ' \
gunzip | docker load; \
docker tag ping-responder:latest ping-responder:$(DOCKER_LABEL); \
'
deploy: push
$(SSH_HOST_CMD) -- ' \
docker container stop ping-responder >/dev/null 2>&1 || true; \
docker container rm ping-responder >/dev/null 2>&1 || true; \
docker run -d --restart=always --init --name=ping-responder \
--memory-swap=64m --memory=64m --cpus=0.25 \
--mount type=bind,source=/var/log/ping-responder,target=/var/log/ping-responder \
--read-only --net=host ping-responder:latest \
./ping-responder.py -i eth0 \
-t "$(TRIGGER_TEXT)" -z \
-f "$(RESPONSE_FILE)" -r \
-l "$(LOG_FILE)"; \
'
.PHONY: all build deploy update-images clean