Skip to content

Commit cab7a2f

Browse files
committed
git-launcher: remove child env file support
1 parent c8b49a9 commit cab7a2f

5 files changed

Lines changed: 22 additions & 66 deletions

File tree

git-launcher/README.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ no shell expansion in the parse step.
139139
| --- | --- |
140140
| `REPO_SUBDIR` | Relative directory inside the repo to `cd` into before running the entry point or `RUN_CMD`. Must not be absolute and must not contain `..`. |
141141
| `ENTRYPOINT_SCRIPT` | Relative path (inside `REPO_SUBDIR` or repo root) to the bash entry script for default mode. Defaults to `entrypoint.sh`. Must not be absolute and must not contain `..`. Trust-bearing in default mode — like `REPO_SUBDIR`, it selects which script runs. |
142-
| `CHILD_ENV_FILE` | Path to a separate env file. Each `KEY=VALUE` line is `export`ed into the environment seen by `entrypoint.sh` / `INSTALL_CMD` / `RUN_CMD`. The file is parsed line-by-line just like the main config (not sourced). |
143142
| `RUN_CMD` | **Advanced.** Shell command to exec instead of the default `entrypoint.sh`. Use only when the workload repo cannot host its own entry script. |
144143
| `INSTALL_CMD` | **Advanced.** Shell command to run before `RUN_CMD`. Only valid alongside `RUN_CMD`. |
145144

@@ -155,10 +154,10 @@ In this mode the trust-bearing config in the launcher's config file is
155154
`REPO_URL` + `COMMIT_SHA` (and `REPO_SUBDIR` if used, since it selects
156155
which `entrypoint.sh` runs). `WORK_DIR` is local plumbing — it names
157156
where on the in-TEE filesystem to keep the checkout — and is not
158-
trust-bearing. `CHILD_ENV_FILE` (and any env it provides) can change the
159-
script's runtime behavior but does not change the bytes that run; if the
160-
deployment uses it, audit it the same way you audit any other runtime
161-
configuration the deployment ships with.
157+
trust-bearing. Normal process environment variables are inherited by the
158+
workload. Use Docker Compose `environment:` for non-secret runtime config that
159+
should be visible at launch, and use dstack encrypted secrets / KMS / mounted
160+
secret files for secrets.
162161

163162
Because `entrypoint.sh`'s bytes are pinned by `COMMIT_SHA` and stored in
164163
the workload repo, they are covered by source provenance of the pinned
@@ -234,10 +233,10 @@ the workload container. By default the SDK looks at `/var/run/dstack.sock`.
234233
Mount it in every compose snippet below; the snippets already include the
235234
mount.
236235

237-
If your workload talks to a non-default dstack endpoint, set
238-
`DSTACK_LLM_ROUTER_DSTACK_ENDPOINT` (or whatever endpoint variable your
239-
workload reads) via `CHILD_ENV_FILE` rather than baking it into the
240-
launcher config — it is runtime configuration, not a trust-bearing field.
236+
If your workload talks to a non-default dstack endpoint, set the endpoint
237+
variable your workload reads through Docker Compose `environment:` rather than
238+
baking it into the launcher config. It is runtime configuration, not part of
239+
the Git pin.
241240

242241
### Local development (host bind-mount)
243242

@@ -325,7 +324,7 @@ at specific commits, and asserts:
325324
* Unknown keys are rejected.
326325
* `REPO_SUBDIR` containing `..` is rejected.
327326
* Pre-existing `WORK_DIR` whose `origin` differs from `REPO_URL` is rejected.
328-
* `CHILD_ENV_FILE` values reach the child process.
327+
* Normal process environment variables reach the workload.
329328
* `INSTALL_CMD` runs before `RUN_CMD`.
330329
* `--help` exits zero.
331330
* The release workflow runs launcher tests before building the image and

git-launcher/VERIFY.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,10 @@ Parse the `configs:` content from step 2 and read `REPO_URL` and
235235
`COMMIT_SHA` (plus `REPO_SUBDIR` and `ENTRYPOINT_SCRIPT` if present —
236236
each selects which script in the pinned repo is used). `WORK_DIR` is
237237
local plumbing only and is not part of the trust-bearing config.
238-
`CHILD_ENV_FILE` (and any env it supplies) does not change the bytes that
239-
run; if used, audit it as runtime deployment configuration, not as
240-
source.
238+
Docker Compose `environment:` does not change the bytes that run, but it can
239+
change workload behavior. Audit non-secret environment variables as runtime
240+
deployment configuration, and keep secrets in encrypted secrets / KMS / mounted
241+
secret files rather than inline compose.
241242

242243
In default mode there are no `INSTALL_CMD` / `RUN_CMD` strings to audit —
243244
the entry point is the fixed-path `entrypoint.sh` in the workload repo,

git-launcher/bin/git-launcher

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ Optional keys:
4848
ENTRYPOINT_SCRIPT Relative path inside REPO_SUBDIR (or the repo root) to the
4949
bash entry script for default mode. Defaults to
5050
'entrypoint.sh'. Must not be absolute or contain '..'.
51-
CHILD_ENV_FILE Path to a separate KEY=VALUE env file. Each key listed
52-
there is exported into the environment of the entry point
53-
/ RUN_CMD.
5451
RUN_CMD Advanced: shell command to exec instead of the workload's
5552
default entry point. Use only when the workload repo
5653
cannot host its own entry script.
@@ -108,7 +105,6 @@ parse_config() {
108105
CFG_WORK_DIR=
109106
CFG_REPO_SUBDIR=
110107
CFG_ENTRYPOINT_SCRIPT=
111-
CFG_CHILD_ENV_FILE=
112108
CFG_INSTALL_CMD=
113109
CFG_RUN_CMD=
114110
CFG_INSTALL_CMD_SET=0
@@ -137,7 +133,6 @@ parse_config() {
137133
WORK_DIR) CFG_WORK_DIR=$val ;;
138134
REPO_SUBDIR) CFG_REPO_SUBDIR=$val ;;
139135
ENTRYPOINT_SCRIPT) CFG_ENTRYPOINT_SCRIPT=$val ;;
140-
CHILD_ENV_FILE) CFG_CHILD_ENV_FILE=$val ;;
141136
INSTALL_CMD) CFG_INSTALL_CMD=$val; CFG_INSTALL_CMD_SET=1 ;;
142137
RUN_CMD) CFG_RUN_CMD=$val; CFG_RUN_CMD_SET=1 ;;
143138
*) die "unknown config key '$key' at $config_file:$lineno" ;;
@@ -221,30 +216,6 @@ ensure_repo_at_commit() {
221216
log "HEAD verified: $head"
222217
}
223218

224-
apply_child_env() {
225-
local env_file=$1
226-
[[ -f $env_file ]] || die "CHILD_ENV_FILE not found: $env_file"
227-
local line key val lineno=0 trimmed
228-
while IFS= read -r line || [[ -n $line ]]; do
229-
lineno=$((lineno + 1))
230-
trimmed=${line#"${line%%[![:space:]]*}"}
231-
[[ -z $trimmed ]] && continue
232-
[[ ${trimmed:0:1} == '#' ]] && continue
233-
if [[ ! $trimmed =~ ^([A-Za-z_][A-Za-z0-9_]*)=(.*)$ ]]; then
234-
die "child env parse error at $env_file:$lineno: $trimmed"
235-
fi
236-
key=${BASH_REMATCH[1]}
237-
val=${BASH_REMATCH[2]}
238-
if [[ ${#val} -ge 2 ]]; then
239-
local first=${val:0:1} last=${val: -1}
240-
if [[ ($first == '"' && $last == '"') || ($first == "'" && $last == "'") ]]; then
241-
val=${val:1:${#val}-2}
242-
fi
243-
fi
244-
export "$key=$val"
245-
done < "$env_file"
246-
}
247-
248219
main() {
249220
parse_config "$CONFIG_FILE"
250221
validate_config
@@ -256,9 +227,6 @@ main() {
256227
if [[ -n $CFG_REPO_SUBDIR ]]; then
257228
log "subdir: $CFG_REPO_SUBDIR"
258229
fi
259-
if [[ -n $CFG_CHILD_ENV_FILE ]]; then
260-
log "envfile: $CFG_CHILD_ENV_FILE"
261-
fi
262230
if [[ $CFG_RUN_CMD_SET -eq 1 ]]; then
263231
log "mode: advanced (RUN_CMD)"
264232
[[ -n $CFG_INSTALL_CMD ]] && log "install: $CFG_INSTALL_CMD"
@@ -277,10 +245,6 @@ main() {
277245
fi
278246
cd "$target"
279247

280-
if [[ -n $CFG_CHILD_ENV_FILE ]]; then
281-
apply_child_env "$CFG_CHILD_ENV_FILE"
282-
fi
283-
284248
if [[ $CFG_RUN_CMD_SET -eq 1 ]]; then
285249
if [[ -n $CFG_INSTALL_CMD ]]; then
286250
log "running install in $target"

git-launcher/examples/web-app.conf

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,9 @@ WORK_DIR=/var/lib/git-launcher/example-web-app
3737
# mode (selects which script runs). Absolute paths and '..' are rejected.
3838
# ENTRYPOINT_SCRIPT=scripts/launch.sh
3939

40-
# Optional: a second env file whose KEY=VALUE lines are exported into the
41-
# environment of entrypoint.sh. Use this for runtime configuration (listen
42-
# address, secrets, etc.) — keeping it separate from the pin config means
43-
# config-only edits do not perturb the trust-bearing fields above.
44-
# CHILD_ENV_FILE=/etc/git-launcher/web-app.env
40+
# Runtime configuration is not part of this launcher config. Pass non-secret
41+
# workload env through Docker Compose `environment:` and pass secrets through
42+
# dstack encrypted secrets, KMS, or mounted secret files.
4543

4644
# Advanced mode (use only if the workload repo cannot host its own
4745
# entrypoint.sh — e.g. you are pinning a third-party repo unchanged):

git-launcher/tests/run-tests.sh

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
#
66
# Builds a throwaway local git repo so the tests do not hit the network,
77
# pins the launcher to specific commits in that repo, and asserts that the
8-
# launcher checks out the right commit, refuses bad inputs, and propagates
9-
# the child env file.
8+
# launcher checks out the right commit, refuses bad inputs, and preserves
9+
# the process environment for the workload.
1010
#
1111
# Requires: bash, git, mktemp.
1212

@@ -339,26 +339,20 @@ EOF
339339
return 0
340340
}
341341

342-
test_child_env_file() {
342+
test_environment_passes_through() {
343343
local work=$TMPROOT/work-env
344344
local marker=$TMPROOT/marker-env.txt
345-
local envfile=$TMPROOT/workload.env
346345
local conf=$TMPROOT/conf-env.env
347-
cat > "$envfile" <<EOF
348-
# a comment
349-
CHILD_ENV_EXTRA=passed-through
350-
EOF
351346
cat > "$conf" <<EOF
352347
REPO_URL=$FIXTURE
353348
COMMIT_SHA=$PIN_SHA
354349
WORK_DIR=$work
355350
REPO_SUBDIR=sub
356-
CHILD_ENV_FILE=$envfile
357351
INSTALL_CMD=
358352
RUN_CMD="MARKER_FILE='$marker' ./run.sh"
359353
EOF
360-
"$LAUNCHER" "$conf" || return 1
361-
grep -q "child_env_extra=passed-through" "$marker" || { echo "CHILD_ENV_FILE not applied" >&2; cat "$marker" >&2; return 1; }
354+
CHILD_ENV_EXTRA=passed-through "$LAUNCHER" "$conf" || return 1
355+
grep -q "child_env_extra=passed-through" "$marker" || { echo "process environment not preserved" >&2; cat "$marker" >&2; return 1; }
362356
return 0
363357
}
364358

@@ -533,7 +527,7 @@ run_case "unknown_key_rejected" test_unknown_key_rejected
533527
run_case "repo_subdir_escape_rejected" test_repo_subdir_escape_rejected
534528
run_case "origin_mismatch_rejected" test_origin_mismatch_rejected
535529
run_case "non_git_non_empty_work_dir_rejected" test_non_git_non_empty_work_dir_rejected
536-
run_case "child_env_file_passes_through" test_child_env_file
530+
run_case "environment_passes_through" test_environment_passes_through
537531
run_case "install_runs_before_run" test_install_runs_before_run
538532
run_case "default_mode_happy" test_default_mode_happy
539533
run_case "default_mode_missing_script_fails" test_default_mode_missing_script_fails

0 commit comments

Comments
 (0)