Skip to content

Commit c24d7ae

Browse files
authored
chore(ci): move certificates logic into containers (#309)
We create the certificates and all the required files inside a container mounting these files in a volume that later can be used everywhere to get the certification files. Closes #308 Signed-off-by: Jonathan Gonzalez V. <[email protected]>
1 parent f198b44 commit c24d7ae

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

Taskfile.yml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ tasks:
146146
cmds:
147147
- >
148148
mkdir -p certs &&
149-
pushd certs &&
149+
docker volume create certs &&
150+
docker run -v certs:/certs -w /certs --name certs --entrypoint=/bin/bash ubuntu -c 'apt update && apt install openssl -y &&
150151
openssl genrsa -out ca-key.pem 4096 &&
151152
openssl req -new -x509 -days 365 -key ca-key.pem -sha256 -out ca.pem \
152153
-subj "/O=CloudNativePG/OU=Barman Cloud Plugin Testing" &&
@@ -155,14 +156,12 @@ tasks:
155156
echo subjectAltName = DNS:{{ .REGISTRY_NAME }},IP:127.0.0.1 >> extfile.cnf &&
156157
echo extendedKeyUsage = serverAuth >> extfile.cnf &&
157158
openssl x509 -req -days 365 -sha256 -in server.csr -CA ca.pem -CAkey ca-key.pem \
158-
-CAcreateserial -out server-cert.pem -extfile extfile.cnf &&
159-
popd
159+
-CAcreateserial -out server-cert.pem -extfile extfile.cnf'
160+
docker cp certs:/certs/ca.pem certs/ca.pem &&
161+
docker rm certs
160162
status:
161-
- test -f certs/ca-key.pem
162-
- test -f certs/ca.pem
163-
- test -f certs/server-key.pem
164-
- test -f certs/server.csr
165-
- test -f certs/server-cert.pem
163+
- docker volume inspect certs
164+
- test -f certs/ca.pem
166165

167166
start-build-network:
168167
desc: Create a docker network for image building used by the dagger engine and the registry
@@ -186,7 +185,7 @@ tasks:
186185
docker run -d --name {{ .REGISTRY_NAME }}
187186
-p {{ .REGISTRY_PORT }}:5000
188187
--network {{ .REGISTRY_NETWORK }}
189-
-v $(pwd)/certs:/certs
188+
-v certs:/certs
190189
-e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/server-cert.pem -e REGISTRY_HTTP_TLS_KEY=/certs/server-key.pem
191190
registry:${REGISTRY_VERSION}
192191
status:
@@ -208,7 +207,7 @@ tasks:
208207
- >
209208
docker run -d -v /var/lib/dagger --name "{{ .DAGGER_ENGINE_CONTAINER_NAME }}"
210209
--network={{ .REGISTRY_NETWORK }}
211-
-v $(pwd)/certs/ca.pem:/usr/local/share/ca-certificates/ca.crt
210+
-v certs:/usr/local/share/ca-certificates/
212211
--privileged {{ .DAGGER_ENGINE_IMAGE }}
213212
status:
214213
- \[ "$(docker inspect -f {{`'{{.State.Running}}'`}} "{{ .DAGGER_ENGINE_CONTAINER_NAME }}" 2> /dev/null )" == 'true' \]

0 commit comments

Comments
 (0)