-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMakefile
263 lines (212 loc) · 8.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
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
##########################################################################################
# starts: definitions, need to care in especial.
# domain of self-hosting bluesky (care TLD, otherwise get failure, ie: NG=>mysky.local)
DOMAIN ?=mysky.local.com
# FQDN of your self hosting bsky components. DO NOT CHANGE THOSE, FOR USUAL CASES.
# CHANGING THESE WITHOUT UNDERSTANDING WHAT YOU DOING, GETTING TROUBLES.
# - these parameters aim to intergration test for your hosting env and official bluesky components, like fediverse.
# - it is strongly recommended that FQDNs should be renamed only if the components provided by the fediverse/integration partner.
# - take care for avoiding confusion, you may need to change other codes according to your trial.
bgsFQDN ?=bgs.${DOMAIN}
bskyFQDN ?=bsky.${DOMAIN}
feedgenFQDN ?=feed-generator.${DOMAIN}
jetstreamFQDN ?=jetstream.${DOMAIN}
ozoneFQDN ?=ozone.${DOMAIN}
palomarFQDN ?=palomar.${DOMAIN}
pdsFQDN ?=pds.${DOMAIN}
plcFQDN ?=plc.${DOMAIN}
publicApiFQDN ?=public.api.${DOMAIN}
socialappFQDN ?=social-app.${DOMAIN}
# email address to get public-signed certs ("internal" for self-signed certs by caddy)
EMAIL4CERTS ?=internal
# mail account, which PDS wants.
PDS_EMAIL_SMTP_URL ?= smtps://change:[email protected]
# feed-generator account in bluesky to send posts ( last part may need to be equal to PDS_HOSTNAME)
FEEDGEN_PUBLISHER_HANDLE ?=feedgen.${pdsFQDN}
FEEDGEN_EMAIL [email protected]
# ozone account in bluesky for moderation
OZONE_ADMIN_HANDLE ?=ozone-admin.${pdsFQDN}
OZONE_ADMIN_EMAIL [email protected]
# datetime to distinguish docker images and sources (date in %Y-%m-%d or 'latest' in docker image naming manner)
asof ?=latest
#asof ?=2024-04-03
#asof ?=$(shell date +'%Y-%m-%d')
ifeq ($(EMAIL4CERTS), internal)
GOINSECURE :=${DOMAIN},*.${DOMAIN}
NODE_TLS_REJECT_UNAUTHORIZED :=0
else
GOINSECURE ?=
NODE_TLS_REJECT_UNAUTHORIZED ?=1
endif
# ends: definitions, need to care in especial.
##########################################################################################
##########################################################################################
# other definitions
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
# paths for folders and files
# top level folder
wDir ?=${PWD}
# data folder to persist container's into filesystem
dDir ?=${wDir}/data
# account folder (for feed-generator and others, created with bluesky API during ops).
aDir ?=${dDir}/accounts
# top level repos folder
rDir ?=${wDir}/repos
# file path to store generated passwords with openssl, during ops.
passfile ?=${wDir}/config/secrets-passwords.env
# docker-compose file
f ?=${wDir}/docker-compose.yaml
#f ?=${wDir}/docker-compose-builder.yaml
# folders of repos
#_nrepo ?=atproto indigo social-app feed-generator did-method-plc pds ozone jetstream
_nrepo ?=atproto indigo social-app ozone
repoDirs ?=$(addprefix ${rDir}/, ${_nrepo})
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
# other parameters
# prefix of github (https://github.com/ | [email protected]:)
gh ?=$(addsuffix /, https://github.com)
gh_git ?=$(addsuffix :, [email protected])
# origin repo prefix to clone source, points code owner(org). DO NOT CHANGE THESE, FOR USUAL CASES. these are features for experts.
origin_repo_bsky_prefix ?=${gh}bluesky-social/
origin_repo_did_prefix ?=${gh}did-method-plc/
fork_repo_prefix ?=
#fork_repo_prefix =${gh_git}itaru2622/bluesky-
# default log level.
LOG_LEVEL_DEFAULT ?=debug
# services to start in N-step ops, with single docker-compose file.
# by these parameters, you can tune which components to start
# - no need to edit this file. just set environment as below before execute ops.
# - following three lines allow you try-out integration/fediverse with official PLC and public CA(lets encrypt).
# export plcFQDN=plc.directory
# export EMAIL4CERTS=YOUR-VALID-EMAIL-ADDRESS
# export Sdep='caddy caddy-sidecar database redis opensearch test-wss test-ws test-indigo pgadmin'
# # no plc in Sdep, comparing below line.
#
Sdep ?=caddy caddy-sidecar database redis opensearch plc test-wss test-ws test-indigo pgadmin
Sbsky ?=pds bgs bsky social-app palomar
Sfeed ?=feed-generator
#Sozone ?=ozone ozone-daemon
Sozone ?=ozone-standalone
Sjetstream ?=jetstream
# load passfile content as Makefile variables if exists
ifeq ($(shell test -e ${passfile} && echo -n exists),exists)
include ${passfile}
endif
##########################################################################################
##########################################################################################
# starts: targets for operations
# get all sources from github
cloneAll: ${repoDirs}
${rDir}/atproto:
git clone ${origin_repo_bsky_prefix}atproto.git $@
ifneq ($(fork_repo_prefix),)
-(cd $@; git remote add fork ${fork_repo_prefix}atproto.git; git remote update fork)
endif
${rDir}/indigo:
git clone ${origin_repo_bsky_prefix}indigo.git $@
ifneq ($(fork_repo_prefix),)
-(cd $@; git remote add fork ${fork_repo_prefix}indigo.git; git remote update fork)
endif
${rDir}/social-app:
git clone ${origin_repo_bsky_prefix}social-app.git $@
ifneq ($(fork_repo_prefix),)
-(cd $@; git remote add fork ${fork_repo_prefix}social-app.git; git remote update fork)
endif
${rDir}/feed-generator:
git clone ${origin_repo_bsky_prefix}feed-generator.git $@
ifneq ($(fork_repo_prefix),)
-(cd $@; git remote add fork ${fork_repo_prefix}feed-generator.git; git remote update fork)
endif
${rDir}/pds:
git clone ${origin_repo_bsky_prefix}pds.git $@
ifneq ($(fork_repo_prefix),)
-(cd $@; git remote add fork ${fork_repo_prefix}pds.git; git remote update fork)
endif
${rDir}/ozone:
git clone ${origin_repo_bsky_prefix}ozone.git $@
ifneq ($(fork_repo_prefix),)
-(cd $@; git remote add fork ${fork_repo_prefix}ozone.git; git remote update fork)
endif
${rDir}/did-method-plc:
git clone ${origin_repo_did_prefix}did-method-plc.git $@
ifneq ($(fork_repo_prefix),)
-(cd $@; git remote add fork ${fork_repo_prefix}did-method-plc.git; git remote update fork)
endif
${rDir}/jetstream:
git clone ${origin_repo_bsky_prefix}jetstream.git $@
ifneq ($(fork_repo_prefix),)
-(cd $@; git remote add fork ${fork_repo_prefix}jetstream.git; git remote update fork)
endif
# delete all repos.
delRepoDirAll:
rm -rf ${rDir}/[a-z]*
# generate secrets for test env
genSecrets: ${passfile}
${passfile}: ./config/gen-secrets.sh
wDir=${wDir} ./config/gen-secrets.sh > $@
cat $@
@echo "secrets generated and stored in $@"
setupdir:
mkdir -p ${aDir}
################################
# include other ops.
################################
include ops/git.mk
include ops/certs.mk
include ops/docker.mk
include ops/patch.mk
include ops/api-bsky.mk
# execute the command under folders (one or multiple).
# HINT: make exec under=./repos/* cmd='git status | cat' => show git status for all repos.
# HINT: make exec under=./repos/* cmd='git branch --show-current | cat' => show current branch for all repos
# HINT: make exec under=./repos/* cmd='git log --decorate=full | head -3 | cat ' => show last commit log for all repos
# HINT: make exec under=./repos/* cmd='git remote update fork | cat' => update remote named fork for all repos
# HINT: make exec under=./repos/* cmd='git checkout work | cat' => checkout to work branch for all repos.
# HINT: make exec under=./repos/* cmd='git push fork --tags | cat' => push tags to remote named fork
exec: ${under}
for d in ${under}; do \
r=`basename $${d})`; \
echo "############ exec cmd @ $${d} $${r} ########################################" ;\
(cd $${d}; ${cmd} ); \
done;
# to show ops configurations
# HINT: make echo
echo:
@echo ""
@echo "########## >>>>>>>>>>>>>>"
@echo "DOMAIN: ${DOMAIN}"
@echo "asof: ${asof}"
@echo ""
@echo "bgsFQDN ${bgsFQDN}"
@echo "bskyFQDN ${bskyFQDN}"
@echo "feedgenFQDN ${feedgenFQDN}"
@echo "jetstreamFQDN ${jetstreamFQDN}"
@echo "ozoneFQDN ${ozoneFQDN}"
@echo "palomarFQDN ${palomarFQDN}"
@echo "pdsFQDN ${pdsFQDN}"
@echo "plcFQDN ${plcFQDN}"
@echo "publicApiFQDN ${publicApiFQDN}"
@echo "socialappFQDN ${socialappFQDN}"
@echo ""
@echo "EMAIL4CERTS: ${EMAIL4CERTS}"
@echo "PDS_EMAIL_SMTP_URL: ${PDS_EMAIL_SMTP_URL}"
@echo "FEEDGEN_EMAIL: ${FEEDGEN_EMAIL}"
@echo "FEEDGEN_PUBLISHER_HANDLE: ${FEEDGEN_PUBLISHER_HANDLE}"
@echo "FEEDGEN_PUBLISHER_PASSWORD: ${FEEDGEN_PUBLISHER_PASSWORD}"
@echo "OZONE_ADMIN_EMAIL: ${OZONE_ADMIN_EMAIL}"
@echo "OZONE_ADMIN_HANDLE: ${OZONE_ADMIN_HANDLE}"
@echo "OZONE_ADMIN_PASSWORD: ${OZONE_ADMIN_PASSWORD}"
@echo ""
@echo "wDir: ${wDir}"
@echo "passfile: ${passfile}"
@echo "dDir: ${dDir}"
@echo "aDir: ${aDir}"
@echo "rDir: ${rDir}"
@echo "_nrepo: ${_nrepo}"
@echo "repoDirs: ${repoDirs}"
@echo "f: ${f}"
@echo "gh: ${gh}"
@echo "fork_repo_prefix: ${fork_repo_prefix}"
@echo ""
@echo "LOG_LEVEL_DEFAULT=${LOG_LEVEL_DEFAULT}"
@echo "########## <<<<<<<<<<<<<<"