Skip to content

Commit 6440583

Browse files
committed
Docker builds are now templated
Instead of a huge Dockerfile we now use arguments supplied by the Makefile, making everything a lot simpler to work with.
1 parent bc7c2cc commit 6440583

File tree

3 files changed

+49
-170
lines changed

3 files changed

+49
-170
lines changed

CONTRIBUTING.md

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -129,39 +129,20 @@ The `src` directory contains the source Markdown documentation that will be comp
129129

130130
The build process is quite complex with several required dependencies, particularly for the manuals that require Doxygen. Therefore a Docker based build has been created which will do all the hard work automatically without you having to install any dependencies (apart from Docker itself).
131131

132-
For every manual an entry needs to be added into the `Dockerfile` and `Makefile` at the root of this directory tree.
133-
134-
#### Dockerfile
135-
136-
A new entry needs to be added as below (modified for the project name / directories / files):
137-
138-
```
139-
# Build wolfBoot PDF
140-
FROM builder AS wolfboot-stage1
141-
WORKDIR /src/wolfssl/wolfBoot
142-
RUN make pdf
143-
144-
# Build wolfBoot HTML
145-
FROM builder AS wolfboot-stage2
146-
WORKDIR /src/wolfssl/wolfBoot
147-
RUN make html
148-
149-
# Build wolfBoot HTML and PDF
150-
FROM scratch AS wolfboot
151-
COPY --from=wolfboot-stage1 /src/wolfssl/wolfBoot/wolfBoot-Manual.pdf wolfboot.pdf
152-
COPY --from=wolfboot-stage2 /src/wolfssl/wolfBoot/html wolfboot-html
153-
```
154-
155-
The final `wolfboot.pdf` and `wolfboot-html` will be what is created in the `build` directory in the root of this directory tree at the end of the build.
132+
For every manual an entry needs to be added into the `Makefile` at the root of this directory tree.
156133

157134
#### Makefile
158135

159-
An entry also needs to be added to the `Makefile` at the root of this directory tree with the following contents (adjusted for the target at the third step of your Dockerfile entry):
136+
An entry needs to be added to the `Makefile` at the root of this directory tree with the following contents (adjusted for the target at the third step of your Dockerfile entry):
160137

161138
```
162139
.PHONY: wolfboot
140+
wolfboot: MANPATH=wolfBoot
141+
wolfboot: PDFFILE=wolfBoot-Manual.pdf
163142
wolfboot: build
164-
@$(DOCKER_CMD) --target=wolfboot
143+
@$(DOCKER_CMD)
165144
```
166145

146+
The `MANPATH` should be set to the subdirectory name the manual is in. `PDFFILE` should be set to the PDF filename generated by the manual's Makefile.
147+
167148
You will also need to add an entry to the `all` line for your project.

Dockerfile

Lines changed: 13 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -20,143 +20,23 @@ RUN cd doxybook2 && cmake . && make install
2020
WORKDIR /src/wolfssl
2121
COPY . .
2222

23-
# Get the wolfSSL Doxygen
24-
FROM builder as wolfssl-stage1
25-
WORKDIR /src/wolfssl/wolfSSL
26-
# Cache getting wolfSSL source for Doxygen docs
27-
RUN git clone --depth 1 https://github.com/wolfSSL/wolfssl
28-
2923
# Build wolfSSL PDF
30-
FROM wolfssl-stage1 AS wolfssl-stage2
31-
WORKDIR /src/wolfssl/wolfSSL
24+
FROM builder AS wolfssl-stage1
25+
ARG MANPATH
26+
ARG PDFFILE
27+
WORKDIR /src/wolfssl/${MANPATH}
3228
RUN make pdf
3329

3430
# Build wolfSSL HTML
35-
FROM wolfssl-stage1 AS wolfssl-stage3
36-
WORKDIR /src/wolfssl/wolfSSL
31+
FROM wolfssl-stage1 AS wolfssl-stage2
32+
ARG MANPATH
33+
ARG PDFFILE
34+
WORKDIR /src/wolfssl/${MANPATH}
3735
RUN make html
3836

3937
# Build both wolfSSL HTML and PDF
40-
FROM scratch AS wolfssl
41-
COPY --from=wolfssl-stage2 /src/wolfssl/wolfSSL/wolfssl.pdf wolfssl.pdf
42-
COPY --from=wolfssl-stage3 /src/wolfssl/wolfSSL/html wolfssl-html
43-
44-
# Build wolfSSH PDF
45-
FROM builder AS wolfssh-stage1
46-
WORKDIR /src/wolfssl/wolfSSH
47-
RUN make pdf
48-
49-
# Build wolfSSH HTML
50-
FROM builder AS wolfssh-stage2
51-
WORKDIR /src/wolfssl/wolfSSH
52-
RUN make html
53-
54-
# Build wolfSSH HTML and PDF
55-
FROM scratch AS wolfssh
56-
COPY --from=wolfssh-stage1 /src/wolfssl/wolfSSH/wolfSSH-Manual.pdf wolfssh.pdf
57-
COPY --from=wolfssh-stage2 /src/wolfssl/wolfSSH/html wolfssh-html
58-
59-
# Build wolfBoot PDF
60-
FROM builder AS wolfboot-stage1
61-
WORKDIR /src/wolfssl/wolfBoot
62-
RUN make pdf
63-
64-
# Build wolfBoot HTML
65-
FROM builder AS wolfboot-stage2
66-
WORKDIR /src/wolfssl/wolfBoot
67-
RUN make html
68-
69-
# Build wolfBoot HTML and PDF
70-
FROM scratch AS wolfboot
71-
COPY --from=wolfboot-stage1 /src/wolfssl/wolfBoot/wolfBoot-Manual.pdf wolfboot.pdf
72-
COPY --from=wolfboot-stage2 /src/wolfssl/wolfBoot/html wolfboot-html
73-
74-
# Build wolfCLU PDF
75-
FROM builder AS wolfclu-stage1
76-
WORKDIR /src/wolfssl/wolfCLU
77-
RUN make pdf
78-
79-
# Build wolfCLU HTML
80-
FROM builder AS wolfclu-stage2
81-
WORKDIR /src/wolfssl/wolfCLU
82-
RUN make html
83-
84-
# Build wolfCLU HTML and PDF
85-
FROM scratch AS wolfclu
86-
COPY --from=wolfclu-stage1 /src/wolfssl/wolfCLU/wolfCLU_Manual.pdf wolfclu.pdf
87-
COPY --from=wolfclu-stage2 /src/wolfssl/wolfCLU/html wolfboot-html
88-
89-
# Build wolfCrypt JNI PDF
90-
FROM builder AS wolfcrypt-jni-stage1
91-
WORKDIR /src/wolfssl/wolfCrypt-JNI
92-
RUN make pdf
93-
94-
# Build wolfCrypt JNI HTML
95-
FROM builder AS wolfcrypt-jni-stage2
96-
WORKDIR /src/wolfssl/wolfCrypt-JNI
97-
RUN make html
98-
99-
# Build wolfCrypt JNI HTML and PDF
100-
FROM scratch AS wolfcrypt-jni
101-
COPY --from=wolfcrypt-jni-stage1 /src/wolfssl/wolfCrypt-JNI/wolfCrypt-JNI-JCE-Manual.pdf wolfcryp-jni.pdf
102-
COPY --from=wolfcrypt-jni-stage2 /src/wolfssl/wolfCrypt-JNI/html wolfcrypt-jni-html
103-
104-
# Build wolfMQTT PDF
105-
FROM builder AS wolfmqtt-stage1
106-
WORKDIR /src/wolfssl/wolfMQTT
107-
RUN make pdf
108-
109-
# Build wolfMQTT HTML
110-
FROM builder AS wolfmqtt-stage2
111-
WORKDIR /src/wolfssl/wolfMQTT
112-
RUN make html
113-
114-
# Build wolfMQTT HTML and PDF
115-
FROM scratch AS wolfmqtt
116-
COPY --from=wolfmqtt-stage1 /src/wolfssl/wolfMQTT/wolfMQTT-Manual.pdf wolfmqtt.pdf
117-
COPY --from=wolfmqtt-stage2 /src/wolfssl/wolfMQTT/html wolfmqtt-html
118-
119-
# Build wolfSentry PDF
120-
FROM builder AS wolfsentry-stage1
121-
WORKDIR /src/wolfssl/wolfSentry
122-
RUN make pdf
123-
124-
# Build wolfSentry HTML
125-
FROM builder AS wolfsentry-stage2
126-
WORKDIR /src/wolfssl/wolfSentry
127-
RUN make html
128-
129-
# Build wolfSentry HTML and PDF
130-
FROM scratch AS wolfsentry
131-
COPY --from=wolfsentry-stage1 /src/wolfssl/wolfSentry/wolfsentry.pdf wolfsentry.pdf
132-
COPY --from=wolfsentry-stage2 /src/wolfssl/wolfSentry/html wolfsentry-html
133-
134-
# Build wolfSSL-JNI PDF
135-
FROM builder AS wolfssl-jni-stage1
136-
WORKDIR /src/wolfssl/wolfSSL-JNI
137-
RUN make pdf
138-
139-
# Build wolfSSL-JNI HTML
140-
FROM builder AS wolfssl-jni-stage2
141-
WORKDIR /src/wolfssl/wolfSSL-JNI
142-
RUN make html
143-
144-
# Build wolfSentry HTML and PDF
145-
FROM scratch AS wolfssl-jni
146-
COPY --from=wolfssl-jni-stage1 /src/wolfssl/wolfSSL-JNI/wolfSSL-JNI-JSSE-Manual.pdf wolfssl-jni.pdf
147-
COPY --from=wolfssl-jni-stage2 /src/wolfssl/wolfSSL-JNI/html wolfssl-jni-html
148-
149-
# Build wolfTPM PDF
150-
FROM builder AS wolftpm-stage1
151-
WORKDIR /src/wolfssl/wolfTPM
152-
RUN make pdf
153-
154-
# Build wolfTPM HTML
155-
FROM builder AS wolftpm-stage2
156-
WORKDIR /src/wolfssl/wolfTPM
157-
RUN make html
158-
159-
# Build wolfTPM HTML and PDF
160-
FROM scratch AS wolftpm
161-
COPY --from=wolftpm-stage1 /src/wolfssl/wolfTPM/wolfTPM-Manual.pdf wolftpm.pdf
162-
COPY --from=wolftpm-stage2 /src/wolfssl/wolfTPM/html wolftpm-html
38+
FROM scratch AS manual
39+
ARG MANPATH
40+
ARG PDFFILE
41+
COPY --from=wolfssl-stage1 /src/wolfssl/${MANPATH}/${PDFFILE} ${PDFFILE}
42+
COPY --from=wolfssl-stage2 /src/wolfssl/${MANPATH}/html ${MANPATH}-html

Makefile

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,63 @@
1-
DOCKER_CMD=DOCKER_BUILDKIT=1 docker build -t doc_build --output=build -f Dockerfile .
1+
DOCKER_CMD=DOCKER_BUILDKIT=1 docker build -t doc_build --build-arg MANPATH=$(MANPATH) --build-arg PDFFILE=$(PDFFILE) --target=manual --output=build -f Dockerfile .
22

33
all: wolfssl wolfssh wolfboot wolfclu wolfcrypt-jni wolfmqtt wolfsentry wolfssl-jni wolftpm
44

55
build:
66
@mkdir -p build
77

88
.PHONY: wolfssl
9+
wolfssl: MANPATH=wolfSSL
10+
wolfssl: PDFFILE=wolfssl.pdf
911
wolfssl: build
10-
@$(DOCKER_CMD) --target=wolfssl
12+
@$(DOCKER_CMD)
1113

1214
.PHONY: wolfssh
15+
wolfssh: MANPATH=wolfSSH
16+
wolfssh: PDFFILE=wolfSSH-Manual.pdf
1317
wolfssh: build
14-
@$(DOCKER_CMD) --target=wolfssh
18+
@$(DOCKER_CMD)
1519

1620
.PHONY: wolfboot
21+
wolfboot: MANPATH=wolfBoot
22+
wolfboot: PDFFILE=wolfBoot-Manual.pdf
1723
wolfboot: build
18-
@$(DOCKER_CMD) --target=wolfboot
24+
@$(DOCKER_CMD)
1925

2026
.PHONY: wolfclu
27+
wolfclu: MANPATH=wolfCLU
28+
wolfclu: PDFFILE=wolfCLU_Manual.pdf
2129
wolfclu: build
22-
@$(DOCKER_CMD) --target=wolfclu
30+
@$(DOCKER_CMD)
2331

2432
.PHONY: wolfcrypt-jni
33+
wolfcrypt-jni: MANPATH=wolfCrypt-JNI
34+
wolfcrypt-jni: PDFFILE=wolfCrypt-JNI-JCE-Manual.pdf
2535
wolfcrypt-jni: build
26-
@$(DOCKER_CMD) --target=wolfcrypt-jni
36+
@$(DOCKER_CMD)
2737

2838
.PHONY: wolfmqtt
39+
wolfmqtt: MANPATH=wolfMQTT
40+
wolfmqtt: PDFFILE=/wolfMQTT-Manual.pdf
2941
wolfmqtt: build
30-
@$(DOCKER_CMD) --target=wolfmqtt
42+
@$(DOCKER_CMD)
3143

3244
.PHONY: wolfsentry
45+
wolfsentry: MANPATH=wolfSentry
46+
wolfsentry: PDFFILE=wolfsentry.pdf
3347
wolfsentry: build
34-
@$(DOCKER_CMD) --target=wolfsentry
48+
@$(DOCKER_CMD)
3549

3650
.PHONY: wolfssl-jni
37-
wolfssl: build
38-
@$(DOCKER_CMD) --target=wolfssl-jni
51+
wolfssl-jni: MANPATH=wolfSSL-JNI
52+
wolfssl-jni: PDFFILE=wolfSSL-JNI-JSSE-Manual.pdf
53+
wolfssl-jni: build
54+
@$(DOCKER_CMD)
3955

4056
.PHONY: wolftpm
57+
wolftpm: MANPATH=wolfTPM
58+
wolftpm: PDFFILE=wolfTPM-Manual.pdf
4159
wolftpm: build
42-
@$(DOCKER_CMD) --target=wolftpm
60+
@$(DOCKER_CMD)
4361

4462
clean:
4563
rm -rf build

0 commit comments

Comments
 (0)