-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
68 lines (50 loc) · 1.91 KB
/
Copy pathMakefile
File metadata and controls
68 lines (50 loc) · 1.91 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
SHELL := /bin/sh
COMPOSE_FILES := -f docker-compose.yml -f docker-compose.generated.yml
PROJECT_NAME ?= multi-mitmproxy
COMPOSE := docker compose -p $(PROJECT_NAME) $(COMPOSE_FILES)
DOCKER_REPO ?= luckybill/multi-mitmproxy-service
.PHONY: generate check build up down restart ps logs clean hash dockerhub-login dockerhub-build dockerhub-push
generate:
@python3 tools/gen_compose.py
check: generate
python3 -m py_compile tools/gen_compose.py
$(COMPOSE) config >/dev/null
build: generate
$(COMPOSE) build
up: generate
@$(COMPOSE) up -d || ( $(COMPOSE) down --remove-orphans >/dev/null 2>&1 || true; $(COMPOSE) up -d )
down:
$(COMPOSE) down
restart: generate
$(COMPOSE) up -d --build
ps:
$(COMPOSE) ps
logs:
$(COMPOSE) logs -f --tail=100
clean:
rm -f docker-compose.generated.yml
# Generate Argon2id hash for PASSWORD
hash:
@if [ -z "$(PASSWORD)" ]; then echo "Usage: make hash PASSWORD=yourpass"; exit 1; fi
@docker run --rm python:3.12-slim sh -lc "pip install -q argon2-cffi && python -c \"from argon2 import PasswordHasher; ph=PasswordHasher(time_cost=3, memory_cost=4096, parallelism=1, hash_len=32); print(ph.hash('$(PASSWORD)'))\""
# Docker Hub helpers
dockerhub-login:
docker login
dockerhub-build:
@VCS=$$(git rev-parse --short HEAD || echo unknown); \
DATE=$$(date -u +%Y-%m-%dT%H:%M:%SZ); \
V=$(VERSION); \
docker build \
--build-arg VERSION=$$V \
--build-arg VCS_REF=$$VCS \
--build-arg BUILD_DATE=$$DATE \
-t $(DOCKER_REPO):latest \
-t $(DOCKER_REPO):$$V .
dockerhub-push:
@if [ -z "$(VERSION)" ]; then echo "Usage: make dockerhub-push VERSION=x.y.z DOCKER_REPO=repo/name"; exit 1; fi
docker push $(DOCKER_REPO):latest
docker push $(DOCKER_REPO):$(VERSION)
# 推送镜像到 Docker Hub
# make dockerhub-build DOCKER_REPO=luckybill/multi-mitmproxy-service VERSION=v1.0.4
# make dockerhub-push DOCKER_REPO=luckybill/multi-mitmproxy-service VERSION=v1.0.4
# git tag v1.0.4 && git push origin v1.0.4