Skip to content

Commit d76e4b9

Browse files
committed
chore(ci): move certificates logic into containers
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 f361fa2 commit d76e4b9

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

Taskfile.yml

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ tasks:
134134
run: once
135135
cmds:
136136
- >
137-
mkdir -p certs &&
138-
pushd certs &&
137+
docker volume create certs &&
138+
docker run -v certs:/certs -w /certs --rm --entrypoint=/bin/bash ubuntu -c 'apt update && apt install openssl -y &&
139139
openssl genrsa -out ca-key.pem 4096 &&
140140
openssl req -new -x509 -days 365 -key ca-key.pem -sha256 -out ca.pem \
141141
-subj "/O=CloudNativePG/OU=Barman Cloud Plugin Testing" &&
@@ -144,14 +144,7 @@ tasks:
144144
echo subjectAltName = DNS:{{ .REGISTRY_NAME }},IP:127.0.0.1 >> extfile.cnf &&
145145
echo extendedKeyUsage = serverAuth >> extfile.cnf &&
146146
openssl x509 -req -days 365 -sha256 -in server.csr -CA ca.pem -CAkey ca-key.pem \
147-
-CAcreateserial -out server-cert.pem -extfile extfile.cnf &&
148-
popd
149-
status:
150-
- test -f certs/ca-key.pem
151-
- test -f certs/ca.pem
152-
- test -f certs/server-key.pem
153-
- test -f certs/server.csr
154-
- test -f certs/server-cert.pem
147+
-CAcreateserial -out server-cert.pem -extfile extfile.cnf'
155148
156149
start-build-network:
157150
desc: Create a docker network for image building used by the dagger engine and the registry
@@ -175,7 +168,7 @@ tasks:
175168
docker run -d --name {{ .REGISTRY_NAME }}
176169
-p {{ .REGISTRY_PORT }}:5000
177170
--network {{ .REGISTRY_NETWORK }}
178-
-v $(pwd)/certs:/certs
171+
-v certs:/certs
179172
-e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/server-cert.pem -e REGISTRY_HTTP_TLS_KEY=/certs/server-key.pem
180173
registry:${REGISTRY_VERSION}
181174
status:
@@ -197,7 +190,7 @@ tasks:
197190
- >
198191
docker run -d -v /var/lib/dagger --name "{{ .DAGGER_ENGINE_CONTAINER_NAME }}"
199192
--network={{ .REGISTRY_NETWORK }}
200-
-v $(pwd)/certs/ca.pem:/usr/local/share/ca-certificates/ca.crt
193+
-v certs:/usr/local/share/ca-certificates/
201194
--privileged {{ .DAGGER_ENGINE_IMAGE }}
202195
status:
203196
- \[ "$(docker inspect -f {{`'{{.State.Running}}'`}} "{{ .DAGGER_ENGINE_CONTAINER_NAME }}" 2> /dev/null )" == 'true' \]
@@ -313,10 +306,12 @@ tasks:
313306
env:
314307
_EXPERIMENTAL_DAGGER_RUNNER_HOST: docker-container://{{ .DAGGER_ENGINE_CONTAINER_NAME }}
315308
cmds:
309+
- docker create --name certs -v certs:/certs busybox
310+
- docker cp certs:/certs/ca.pem ca.pem
316311
- >
317312
GITHUB_REF= dagger call -m dagger/e2e/ run-ephemeral
318313
--source .
319-
--ca certs/ca.pem
314+
--ca ca.pem
320315
--registry {{.REGISTRY_NAME}}:{{.REGISTRY_PORT}}
321316
--go-version {{ .GOLANG_IMAGE_VERSION }}
322317

0 commit comments

Comments
 (0)