-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
145 lines (122 loc) · 6.68 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
CERTS_DIR := $(PWD)/certs
FRED_VERSION := 0.2.19
.PHONY: all
all: client/client.img satellite/satellite.img origin/origin.img nameservice/nase.img orchestrator/orchestrator.img
${CERTS_DIR}/ca.key:
@mkdir -p ${CERTS_DIR}
@openssl genrsa -out $@ 2048
${CERTS_DIR}/ca.crt: ${CERTS_DIR}/ca.key
@mkdir -p ${CERTS_DIR}
@openssl req -x509 -new -nodes -key $< -days 1825 -sha512 -out $@ -subj "/C=DE/L=Berlin/O=OpenFogStack/OU=komet"
${CERTS_DIR}/nase.key ${CERTS_DIR}/nase.crt: ${CERTS_DIR}/ca.crt
@mkdir -p ${CERTS_DIR}
./gen-fred-cert.sh ${CERTS_DIR} nase 127.0.0.1
${CERTS_DIR}/client.key ${CERTS_DIR}/client.crt: ${CERTS_DIR}/ca.crt
@mkdir -p ${CERTS_DIR}
./gen-fred-cert.sh ${CERTS_DIR} client 127.0.0.1 172.18.0.1
${CERTS_DIR}/fred.key ${CERTS_DIR}/fred.crt: ${CERTS_DIR}/ca.crt
@mkdir -p ${CERTS_DIR}
./gen-fred-cert.sh ${CERTS_DIR} fred 127.0.0.1
satellite/alexandra.bin: # download alexandra from image
docker create --name alexandra-tmp git.tu-berlin.de:5000/mcc-fred/fred/alexandra:v${FRED_VERSION}
docker cp alexandra-tmp:/alexandra $@
docker rm -f alexandra-tmp
orchestrator/proto/client_pb2.py orchestrator/proto/client_pb2_grpc.py: # download proto from gitlab
mkdir -p orchestrator/proto
curl -sSL https://github.com/OpenFogStack/FReD/archive/refs/tags/v${FRED_VERSION}.tar.gz --output /tmp/fred.tar.gz
tar -xvf /tmp/fred.tar.gz -C /tmp/
mv /tmp/FReD-${FRED_VERSION}/proto/client/client_pb2*.py orchestrator/proto/
rm -rf /tmp/FReD-${FRED_VERSION}
shortmedia.csv: mediacounts.2024-04-28.v00.tsv shortmediacounts.py
python3 shortmediacounts.py
client/client.bin: client/client.go client/go.mod
cd $(@D) && GOOS=linux GOARCH=amd64 go build -o $(@F) $(<F)
client/client.img: client/client.sh client/client.bin client/client-base.sh shortmedia.csv
@docker run -it --platform=linux/amd64 --rm \
-v $(abspath $(@D))/client.sh:/app.sh \
-v $(abspath $(@D))/client-base.sh:/base.sh \
-v $(abspath $(@D))/client.bin:/files/client.bin \
-v $(PWD)/shortmedia.csv:/files/shortmedia.csv \
-v $(PWD):/opt/code \
--privileged rootfsbuilder $@
orchestrator/%.zip: ${CERTS_DIR}/client.crt ${CERTS_DIR}/client.key ${CERTS_DIR}/ca.crt orchestrator/%.py
mkdir -p orchestrator/$*
cp orchestrator/$*.py orchestrator/$*/fn.py
docker run --platform linux/amd64 --rm -v ${PWD}/orchestrator/$*:/app -w / python:3.11-alpine python3 -m pip install grpcio==1.56.0 protobuf==4.23.3 requests --target /app
# docker run --platform linux/amd64 --rm -v ${PWD}/orchestrator/$*:/app -w / python:3.11-alpine python3 -m pip install grpcio==1.56.0 protobuf==4.23.3 --target /app
cp ${CERTS_DIR}/client.crt orchestrator/$*/cert.crt
cp ${CERTS_DIR}/client.key orchestrator/$*/cert.key
cp ${CERTS_DIR}/ca.crt orchestrator/$*/ca.crt
curl -sSL https://github.com/OpenFogStack/FReD/archive/refs/tags/v${FRED_VERSION}.tar.gz --output /tmp/fred.tar.gz
tar -xvf /tmp/fred.tar.gz -C /tmp/
mv /tmp/FReD-${FRED_VERSION}/proto/client/client_pb2.py orchestrator/$*
mv /tmp/FReD-${FRED_VERSION}/proto/client/client_pb2_grpc.py orchestrator/$*
rm -rf /tmp/FReD-${FRED_VERSION}
cd orchestrator/$* && zip -r ../$*.zip .
rm -rf orchestrator/$*
satellite/fred.bin: # download fred from image
docker create --name fred-tmp git.tu-berlin.de:5000/mcc-fred/fred/fred:v${FRED_VERSION}
docker cp fred-tmp:/fred $@
docker rm -f fred-tmp
orchestrator/orchestrator.img: orchestrator/orchestrator.sh orchestrator/orchestrator-base.sh orchestrator/orchestrator.py ${CERTS_DIR}/client.crt ${CERTS_DIR}/client.key ${CERTS_DIR}/ca.crt orchestrator/func.zip orchestrator/func2.zip orchestrator/proto/client_pb2.py orchestrator/proto/client_pb2_grpc.py
@docker run -it --platform=linux/amd64 --rm \
-v $(abspath $(@D))/orchestrator.sh:/app.sh \
-v $(abspath $(@D))/orchestrator-base.sh:/base.sh \
-v $(abspath $(@D))/orchestrator.py:/files/orchestrator.py \
-v $(abspath $(@D))/proto/client_pb2.py:/files/client_pb2.py \
-v $(abspath $(@D))/proto/client_pb2_grpc.py:/files/client_pb2_grpc.py \
-v ${CERTS_DIR}/client.crt:/files/client.crt \
-v ${CERTS_DIR}/client.key:/files/client.key \
-v ${CERTS_DIR}/ca.crt:/files/ca.crt \
-v $(abspath $(@D))/func.zip:/files/func.zip \
-v $(abspath $(@D))/func2.zip:/files/func2.zip \
-v $(PWD):/opt/code \
--privileged rootfsbuilder $@
satellite/satellite.img: satellite/satellite.sh satellite/satellite-base.sh ${CERTS_DIR}/fred.crt ${CERTS_DIR}/fred.key ${CERTS_DIR}/client.crt ${CERTS_DIR}/client.key ${CERTS_DIR}/ca.crt satellite/fred.bin satellite/alexandra.bin satellite/tf-linux-amd64.bin
@docker run -it --platform=linux/amd64 --rm \
-v $(abspath $(@D))/satellite.sh:/app.sh \
-v $(abspath $(@D))/satellite-base.sh:/base.sh \
-v $(abspath $(@D))/fred.bin:/files/fred \
-v $(abspath $(@D))/alexandra.bin:/files/alexandra \
-v $(abspath $(@D))/tf-linux-amd64.bin:/files/tf-linux-amd64 \
-v ${CERTS_DIR}/fred.crt:/files/fred.crt \
-v ${CERTS_DIR}/fred.key:/files/fred.key \
-v ${CERTS_DIR}/client.crt:/files/client.crt \
-v ${CERTS_DIR}/client.key:/files/client.key \
-v ${CERTS_DIR}/ca.crt:/files/ca.crt \
-v $(PWD):/opt/code \
--privileged rootfsbuilder $@
origin/origin.bin: origin/origin.go
GOOS=linux GOARCH=amd64 go build -o $@ $<
origin/origin.img: origin/origin.sh origin/origin-base.sh shortmedia.csv origin/origin.bin
@docker run -it --platform=linux/amd64 --rm \
-v $(abspath $(@D))/origin.sh:/app.sh \
-v $(abspath $(@D))/origin-base.sh:/base.sh \
-v $(abspath $(@D))/origin.bin:/files/origin.bin \
-v $(PWD)/shortmedia.csv:/files/shortmedia.csv \
-v $(PWD):/opt/code \
--privileged rootfsbuilder $@
nameservice/etcd.bin: # download etcd
curl -SL https://github.com/etcd-io/etcd/releases/download/v3.5.7/etcd-v3.5.7-linux-amd64.tar.gz --output /tmp/etcd-v3.5.7-linux-amd64.tar.gz
tar -xvf /tmp/etcd-v3.5.7-linux-amd64.tar.gz -C /tmp
mv /tmp/etcd-v3.5.7-linux-amd64/etcd $@
# rm -rf /tmp/etcd-v3.5.7-linux-amd64
# rm /tmp/etcd-v3.5.7-linux-amd64.tar.gz
nameservice/nase.img: nameservice/nase.sh nameservice/nase-base.sh ${CERTS_DIR}/nase.crt ${CERTS_DIR}/nase.key ${CERTS_DIR}/ca.crt nameservice/etcd.bin
@docker run -it --platform=linux/amd64 --rm \
-v $(abspath $(@D))/nase.sh:/app.sh \
-v $(abspath $(@D))/nase-base.sh:/base.sh \
-v $(abspath $(@D))/etcd.bin:/files/etcd \
-v ${CERTS_DIR}/nase.crt:/files/nase.crt \
-v ${CERTS_DIR}/nase.key:/files/nase.key \
-v ${CERTS_DIR}/ca.crt:/files/ca.crt \
-v $(PWD):/opt/code \
--privileged rootfsbuilder $@
traj.zip: config.toml
@docker run --rm -v $(PWD):/app satgen-docker /app/$< /app/$@
traj-full.zip: config-full.toml
@docker run --rm -v $(PWD):/app satgen-docker /app/$< /app/$@
traj-small.zip: config-small.toml
@docker run --rm -v $(PWD):/app satgen-docker /app/$< /app/$@
traj-smaller.zip: config-smaller.toml
@docker run --rm -v $(PWD):/app satgen-docker /app/$< /app/$@