Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
92 lines (77 loc) · 2.86 KB
/
Copy pathMakefile
File metadata and controls
92 lines (77 loc) · 2.86 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
.DEFAULT_GOAL := up
MODE ?= docker
COMPOSE ?= docker compose
UV ?= uv
ARGS ?=
ifeq ($(MODE),docker)
CONFIG_TEMPLATE := config.example.toml
RUN := $(COMPOSE) run --rm -T dank
SCRAPE := $(RUN) scrape --headless
WEB := $(COMPOSE) up --build --wait
X_LOGIN := bash src/dank/run_x_login.sh $(COMPOSE) --
YOUTUBE_LOGIN := python3 src/dank/run_youtube_login.py $(COMPOSE) --
else ifeq ($(MODE),native)
CONFIG_TEMPLATE := config.native.example.toml
RUN := $(UV) run
SCRAPE := $(RUN) scrape
WEB := $(RUN) web --no-reload
X_LOGIN := $(RUN) x-login
YOUTUBE_LOGIN := $(RUN) youtube-login
else
$(error MODE must be docker or native)
endif
.PHONY: help config up web down logs scrape process query embed download-model x-login youtube-login youtube-compare
help:
@printf '%s\n' \
'Usage: make <target> [MODE=docker|native] [ARGS=...]' \
'Docker is the default. Native mode uses uv on the host.' \
'' \
' up, web Start the viewer (Docker stack or native foreground)' \
' scrape Collect sources; save output under logs/scrape/' \
' x-login Sign in to X and save the session for collection' \
' youtube-login Sign in to Google using 1Password' \
' youtube-compare Compare browser and yt-dlp recommendations' \
' process Process posts/assets; save output under logs/process/' \
' query Run clickhouse-query; pass -q and SQL through ARGS' \
' embed Run embed-text; pass quoted text through ARGS' \
' download-model Cache an embedding model' \
' config Create missing config.toml for the selected mode' \
' down, logs Stop or view logs for the Docker stack' \
'' \
'ARGS goes to the application command, or to Compose for Docker up/web.' \
'Existing configuration is preserved; MODE does not convert it.'
config:
@set -e; if [ ! -e config.toml ]; then \
(umask 077; cp -n $(CONFIG_TEMPLATE) config.toml); \
printf '%s\n' 'Created config.toml for $(MODE). Edit sources there before scraping.'; \
fi
# Preserve literal dollar signs in arguments, including regex end anchors.
up web: config
$(WEB) $(value ARGS)
scrape: config
@bash src/dank/run_logged.sh scrape $(MODE) $(SCRAPE) $(value ARGS)
x-login: config
$(X_LOGIN) $(value ARGS)
youtube-login: config
$(YOUTUBE_LOGIN) $(value ARGS)
youtube-compare: config
$(RUN) youtube-compare $(value ARGS)
process: config
@bash src/dank/run_logged.sh process $(MODE) $(RUN) process $(value ARGS)
query: config
$(RUN) clickhouse-query $(value ARGS)
embed: config
$(RUN) embed-text $(value ARGS)
download-model: config
$(RUN) download-embedding-model $(value ARGS)
ifeq ($(MODE),docker)
down:
$(COMPOSE) down $(value ARGS)
logs:
$(COMPOSE) logs --follow $(value ARGS)
else
down logs:
@printf '%s\n' '$@ manages Docker services; use MODE=docker.' >&2
@printf '%s\n' 'For native runs, stop the viewer with Ctrl+C and use its configured log file.' >&2
@exit 2
endif