fix(compose): root로 도는 CI에서도 Keycloak이 smoke lane secret을 읽는다

문제: compose smoke는 실행마다 Keycloak client secret을 0600 파일로 만든다.
Compose는 파일을 소유자·권한 그대로 붙이고 Keycloak은 이미지 사용자 uid
1000으로 읽는다. runner job은 root라 파일이 root 소유가 되고, Keycloak
entrypoint가 읽지 못해 exit 78로 끝난다. auth profile을 쓰는 8 lane이
run 52·63에서 모두 이것으로 실패했다. desktop은 만든 사람이 uid 1000이라
통과했다.

고른 방법: root면 파일을 uid 1000에게 넘기고 0600을 지킨다. uid 1000도
root도 아니면 같은 스크립트의 Mailpit 키처럼 0644로 둔다(값은 실행마다
새로 만들고, Git이 무시하는 폴더에 있고, 끝나면 지운다).

위험·한계: Keycloak 이미지의 사용자가 1000이 아니게 바뀌면 상수를 고쳐야
한다. 이미지 태그(26.0)를 올릴 때 확인할 것으로 주석에 적었다.

검증: runner main 수동 실행의 compose-smoke(이 PR 본문에 적는다).
This commit is contained in:
DongHyeonka
2026-11-12 01:16:57 +09:00
parent ecc1400486
commit 6325b5183f
+11
View File
@@ -83,6 +83,8 @@ done
# The lane-only TLS overlay's keypair directory (src/bootstrap/app/compose-lanes/tls.yaml).
LANE_POSTGRES_TLS="${REPO_ROOT}/src/bootstrap/app/compose-lanes/postgres/tls"
# The user quay.io/keycloak/keycloak runs as (the image's USER), which reads the realm's client secret.
KEYCLOAK_IMAGE_UID=1000
# ---- per-lane state, cleaned up by the trap ---------------------------------
PROJECT=""
@@ -178,6 +180,15 @@ run_lane() {
local client_secret; client_secret="$(random_secret)"
GENERATED_SECRETS+=("${client_secret}")
(umask 077 && printf '%s' "${client_secret}" >"${secret_file}")
# Compose mounts the file with its owner and mode, and Keycloak reads it as its image user, uid
# 1000. A developer with that uid owns the file already. A CI job runs as root, so the file is
# handed to uid 1000 and stays 0600. Anyone else gets 0644, as the Mailpit key below does: the
# value is random, lives for one run and sits in a Git-ignored directory removed on teardown.
if [[ "$(id -u)" == 0 ]]; then
chown "${KEYCLOAK_IMAGE_UID}:0" "${secret_file}"
elif [[ "$(id -u)" != "${KEYCLOAK_IMAGE_UID}" ]]; then
chmod 0644 "${secret_file}"
fi
# A CA and a server certificate for the host name `db`, when the lane brings the TLS overlay.
#