-
Notifications
You must be signed in to change notification settings - Fork 14
/
docker-compose.yml
208 lines (198 loc) · 6.83 KB
/
docker-compose.yml
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
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2022-2023 Dell Inc, or its subsidiaries.
---
version: '3.7'
include:
- docker-compose.dpu.yml
services:
bootstrap:
image: docker.io/opiproject/sztpd:0.0.15
depends_on:
setup-cert:
condition: service_completed_successfully
volumes:
- server-certs:/certs
- ./images:/media
- ./config:/mnt
- ./scripts/docker-entrypoint.sh:/usr/local/bin/docker-entrypoint.sh
entrypoint: /usr/local/bin/docker-entrypoint.sh
environment:
SZTPD_INIT_PORT: 6080
SZTPD_NBI_PORT: 7080
SZTPD_SBI_PORT: 9090
SZTPD_INIT_MODE: 1
SZTPD_ACCEPT_CONTRACT: "Yes"
SZTPD_INIT_ADDR: 0.0.0.0
SZTPD_OPI_MODE: "running"
SZTPD_RETRY_ATTEMPTS: 30
ports:
- 7080:7080
- 9090:9090
networks:
- opi
healthcheck:
test: ["CMD-SHELL", "curl --fail -H Accept:application/yang-data+json http://127.0.0.1:$$SZTPD_NBI_PORT/.well-known/host-meta || exit 1"]
redirecter:
image: docker.io/opiproject/sztpd:0.0.15
depends_on:
setup-cert:
condition: service_completed_successfully
volumes:
- server-certs:/certs
- ./config/sztpd.redirect.json.template:/mnt/sztpd.redirect.json.template
- ./scripts/docker-entrypoint.sh:/usr/local/bin/docker-entrypoint.sh
entrypoint: /usr/local/bin/docker-entrypoint.sh
environment:
SZTPD_INIT_PORT: 6080
SZTPD_NBI_PORT: 7070
SZTPD_SBI_PORT: 8080
SZTPD_INIT_MODE: 1
SZTPD_ACCEPT_CONTRACT: "Yes"
SZTPD_INIT_ADDR: 0.0.0.0
BOOTSVR_PORT: 9090
BOOTSVR_ADDR: "bootstrap"
SZTPD_OPI_MODE: "redirect"
SZTPD_RETRY_ATTEMPTS: 30
ports:
- 8080:8080
networks:
- opi
healthcheck:
test: ["CMD-SHELL", "curl --fail -H Accept:application/yang-data+json http://127.0.0.1:$$SZTPD_NBI_PORT/.well-known/host-meta || exit 1"]
dhcp:
image: docker.io/networkboot/dhcpd:1.3.0
environment:
NODE_IP_SUBNET: 10.127.127.0
NODE_IP_NETMASK: 255.255.255.0
NODE_IP_RANGE_MIN: 10.127.127.100
NODE_IP_RANGE_MAX: 10.127.127.253
NODE_IP_ADDRESS: 10.127.127.3
volumes:
- ./dhcp:/opt
cap_add:
- CAP_NET_BIND_SERVICE
- CAP_NET_RAW
ports:
- 67:67/udp
networks:
- opi
command: sh -e -u -x -c 'touch /var/lib/dhcp/dhcpd.leases && eval "echo \"$$(cat /opt/dhcpd.conf.template)\"" > /etc/dhcp/dhcpd.conf && dhcpd -d'
setup-cert:
image: docker.io/alpine/openssl:3.3.1
volumes:
- server-certs:/certs/server
- client-certs:/certs/client
user: "0"
entrypoint: /bin/ash
command: >
-c '
set -euxo pipefail
env
apk add --no-cache --no-check-certificate curl make && rm -rf /var/cache/apk/*
rm -rf /tmp/sztpd-simulator
curl -kL https://watsen.net/support/sztpd-simulator-0.0.11.tgz | tar -zxvf - -C /tmp/
cd /tmp/sztpd-simulator/pki
echo === SERVER SBI certificates ===
echo "DNS.2 = bootstrap" >> sztpd1/sbi/end-entity/openssl.cnf
echo "DNS.3 = web" >> sztpd1/sbi/end-entity/openssl.cnf
echo "DNS.4 = redirecter" >> sztpd1/sbi/end-entity/openssl.cnf
make -C sztpd1/sbi pki SHELL=/bin/ash
cat sztpd1/sbi/end-entity/my_cert.pem sztpd1/sbi/intermediate2/my_cert.pem > /tmp/cert_chain.pem
openssl crl2pkcs7 -nocrl -certfile /tmp/cert_chain.pem -outform DER -out /tmp/cert_chain.cms
echo === CLIENT cert DevID trust anchor ===
make -C client pki SHELL=/bin/ash
cat client/root-ca/my_cert.pem client/intermediate1/my_cert.pem client/intermediate2/my_cert.pem > /tmp/ta_cert_chain.pem
openssl crl2pkcs7 -nocrl -certfile /tmp/ta_cert_chain.pem -outform DER -out /tmp/ta_cert_chain.cms
echo === COPY TO FINAL DESTINATION ===
cat sztpd1/sbi/root-ca/my_cert.pem sztpd1/sbi/intermediate1/my_cert.pem > /certs/client/opi.pem
cp sztpd1/sbi/end-entity/private_key.der \
sztpd1/sbi/end-entity/private_key.pem \
sztpd1/sbi/end-entity/public_key.der \
sztpd1/sbi/end-entity/my_cert.pem \
/tmp/cert_chain.cms \
/tmp/cert_chain.pem \
/tmp/ta_cert_chain.cms \
/tmp/ta_cert_chain.pem \
/certs/server/
echo === Generate Clients Endponts ===
for vendor in first second third; do
sed -i "s/my-serial-number/$${vendor}-serial-number/g" client/end-entity/openssl.cnf
make -C client/end-entity cert_request OPENSSL=openssl SHELL=/bin/ash
make -C client/intermediate2 sign_cert_request OPENSSL=openssl SHELL=/bin/ash REQDIR="../end-entity"
cp client/end-entity/private_key.pem /certs/client/$${vendor}_private_key.pem
cp client/end-entity/my_cert.pem /certs/client/$${vendor}_my_cert.pem
sed -i "s/$${vendor}-serial-number/my-serial-number/g" client/end-entity/openssl.cnf
done
'
web:
image: docker.io/library/httpd:2.4.57-alpine3.17
depends_on:
setup-cert:
condition: service_completed_successfully
volumes:
- server-certs:/certs
- ./images:/usr/local/apache2/htdocs
ports:
- 443:443
networks:
- opi
entrypoint: /bin/ash
command: |
-x -e -c '
sed -i \
-e "s/^#\(Include .*httpd-ssl.conf\)/\1/" \
-e "s/^#\(LoadModule .*mod_ssl.so\)/\1/" \
-e "s/^#\(LoadModule .*mod_socache_shmcb.so\)/\1/" \
conf/httpd.conf
sed -i \
-e "s/^#\(SSLVerifyClient .*require\)/\1/" \
-e "s/^#\(SSLVerifyDepth .*\)/\1/" \
-e "s/^#\(SSLCACertificateFile .*\)/\1/" \
conf/extra/httpd-ssl.conf
cp /certs/my_cert.pem conf/server.crt
cp /certs/private_key.pem conf/server.key
mkdir -p /usr/local/apache2/conf/ssl.crt/
cp /certs/ta_cert_chain.pem /usr/local/apache2/conf/ssl.crt/ca-bundle.crt
httpd-foreground
'
avahi:
image: docker.io/flungo/avahi:latest
environment:
SERVER_HOST_NAME: "opi"
networks:
- opi
swtpm:
build:
context: tpm
volumes:
- tpm-data:/swtpm
networks:
- opi
command: ['socket', '--tpm2',
'--server', 'type=unixio,path=/swtpm/swtpm.sock',
'--ctrl', 'type=unixio,path=/swtpm/swtpm.sock.ctrl',
'--tpmstate', 'dir=/swtpm',
'--log', 'file=swtpm.log',
'--log', 'level=20',
'--flags', 'not-need-init,startup-clear']
swtpm-test:
image: docker.io/strongx509/tpm:5.9.13
depends_on:
- swtpm
volumes:
- tpm-data:/swtpm
networks:
- opi
environment:
TPM2TOOLS_TCTI: swtpm:path=/swtpm/swtpm.sock
command: ['tpm2', 'clear']
volumes:
tpm-data:
server-certs:
client-certs:
networks:
opi:
ipam:
config:
- subnet: "10.127.127.0/24"
gateway: "10.127.127.1"