From 92a48b1628344a4d52969df7cf37222cfb662429 Mon Sep 17 00:00:00 2001 From: Jason Swank Date: Tue, 20 Jan 2026 15:28:00 +0000 Subject: [PATCH] add direnv --- Dockerfile | 2 +- ctx/home/.config/direnv/direnvrc | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 ctx/home/.config/direnv/direnvrc diff --git a/Dockerfile b/Dockerfile index 44430df..4ec3a87 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ RUN apk -U --no-cache add \ doas doas-sudo-shim \ bash less openvi \ coreutils grep gawk perl \ - curl bind-tools + curl direnv bind-tools RUN adduser -h /home/cli -s /bin/bash -D cli cli && \ addgroup cli wheel && \ diff --git a/ctx/home/.config/direnv/direnvrc b/ctx/home/.config/direnv/direnvrc new file mode 100644 index 0000000..df319ab --- /dev/null +++ b/ctx/home/.config/direnv/direnvrc @@ -0,0 +1,15 @@ +export_secret() { + local name="$1" + local file="/run/secrets/${name}" + + if [[ ! -f "$file" ]]; then + printf "secret file not found: %s\n" $file >&2 + return 1 + fi + + # Read first line, remove trailing spaces/tabs, convert nulls to newlines + local value + value=$(head -n1 "$file" | sed 's/[ \t]*$//' | tr '\0' '\n') + + export "${name}=${value}" +}