Skip to content

fix(docker): actually install certificates from CUSTOM_CERT_DIR - #623

Open
lbarrosby wants to merge 1 commit into
AsyncFuncAI:mainfrom
lbarrosby:fix/docker-custom-certs
Open

lbarrosby wants to merge 1 commit into
AsyncFuncAI:mainfrom
lbarrosby:fix/docker-custom-certs

Conversation

@lbarrosby

Copy link
Copy Markdown
Contributor

The custom CA support from #206 (documented in the translated READMEs: drop .crt/.pem files in certs/, or docker build --build-arg CUSTOM_CERT_DIR=...) never takes effect:

  • ARG CUSTOM_CERT_DIR="certs" is declared before the first FROM and not redeclared in the final stage, so ${CUSTOM_CERT_DIR} is empty there and the whole if is skipped.
  • Even with the ARG in scope, nothing copies the directory into the image, so [ -d certs ] in /app would still be false.
  • update-ca-certificates only reads *.crt, so .pem files would be ignored.

This redeclares the ARG in the final stage, reads the directory through a RUN --mount=type=bind of the build context (nothing extra ends up in the image, and a missing directory is just skipped), and installs .crt and .pem files as .crt.

Tested with a small harness that takes the top-level ARG plus the cert block from each Dockerfile onto debian:stable-slim with a self-signed CA in the context:

case main this PR
default, certs/test-ca.pem not installed (148 certs) installed (149)
--build-arg CUSTOM_CERT_DIR=my-certs, other.crt not installed installed
--build-arg CUSTOM_CERT_DIR=nope silent no-op "No custom certificates found in 'nope', skipping."

The ARG was declared before the first FROM and never redeclared in the
final stage, so it was empty there, and the cert directory was never
copied into the image. The block was a no-op for every build.

Redeclare the ARG, read the directory through a bind mount of the build
context, and install .crt and .pem files (update-ca-certificates only
picks up .crt).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant