Skip to content

Commit 4660f5f

Browse files
aledbfclaude
andcommitted
fix(cli): keep the config's ENV order in the single Dockerfile build
The one-build path for Dockerfile configurations (#70) built its Features stage without the config's containerEnv order, so those ENV lines came out sorted there while image configurations kept the declared order. A Dockerfile variant of the declaration-order parity case compares the built image with the reference. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 9ef9782 commit 4660f5f

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

‎docs/parity/parity-matrix.yaml‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,6 +1093,20 @@ initial_cases:
10931093
current_status: match
10941094
notes: "TS writes a Feature's containerEnv as ENV lines in devcontainer-feature.json's order and the config's containerEnv in devcontainer.json's (generateContainerEnvs, Object.keys), and devcontainer-features.env lists the options the Feature declares, then the user's other options in the user's order (getFeatureValueObject). The Feature's PATH line uses SDKMAN_DIR, which the line before it sets, so the image's PATH starts with /usr/local/sdkman/bin. Go sorted the keys: PATH came first and expanded an unset SDKMAN_DIR to /bin, ALPHA preceded ZED, and AA preceded ZZ."
10951095

1096+
- id: build.dockerfile-features-env-declaration-order-success
1097+
lane: runtime
1098+
command: build
1099+
priority: p1
1100+
docker_required: true
1101+
setup_cmd: "WORKSPACE=/tmp/parity-${PARITY_CASE_ID}-${PARITY_SIDE}; rm -rf $WORKSPACE; mkdir -p $WORKSPACE/.devcontainer/sdk; printf '%s' '{\"id\":\"sdk\",\"version\":\"1.0.0\",\"name\":\"Sdk\",\"options\":{\"version\":{\"type\":\"string\",\"default\":\"latest\"}},\"containerEnv\":{\"SDKMAN_DIR\":\"/usr/local/sdkman\",\"PATH\":\"${SDKMAN_DIR}/bin:${PATH}\"}}' > $WORKSPACE/.devcontainer/sdk/devcontainer-feature.json; printf '%s\\n' '#!/bin/sh' 'set -e' 'cp devcontainer-features.env /features-env.txt' > $WORKSPACE/.devcontainer/sdk/install.sh; chmod +x $WORKSPACE/.devcontainer/sdk/install.sh; printf 'FROM alpine:3\\n' > $WORKSPACE/.devcontainer/Dockerfile; printf '%s' '{\"build\":{\"dockerfile\":\"Dockerfile\"},\"containerEnv\":{\"ZED\":\"1\",\"ALPHA\":\"2\"},\"features\":{\"./sdk\":{\"zz\":\"1\",\"version\":\"2\",\"aa\":\"3\"}}}' > $WORKSPACE/.devcontainer/devcontainer.json; echo WORKSPACE=$WORKSPACE"
1102+
ts_cmd: "build --workspace-folder ${WORKSPACE} --image-name parity-${PARITY_CASE_ID}-${PARITY_SIDE}"
1103+
verify_cmd: "docker run --rm ${IMAGE_NAME} cat /features-env.txt; echo; docker image inspect -f '{{json .Config.Env}}' ${IMAGE_NAME}"
1104+
cleanup_cmd: "docker rmi -f parity-${PARITY_CASE_ID}-${PARITY_SIDE} >/dev/null 2>&1; rm -rf /tmp/parity-${PARITY_CASE_ID}-${PARITY_SIDE}; true"
1105+
asserts: [exit_code, stdout_normalized]
1106+
class: build-runtime
1107+
current_status: match
1108+
notes: "The same declaration order as build.features-env-declaration-order-success, through a Dockerfile configuration, which builds the user's Dockerfile and the Features in one combined Dockerfile-with-features."
1109+
10961110
- id: up.compose-features-staging-layout-success
10971111
lane: runtime
10981112
command: up

‎internal/cli/dockerfile_build.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ func buildDockerfileImage(ctx context.Context, logger log.Logger, dockerClient *
113113
UseBuildKitContexts: useBuildx,
114114
Syntax: featuresSyntaxDirective(ctx, engine, fb.OmitSyntaxDirective, useBuildx, parsed),
115115
ConfigContainerEnv: fb.ContainerEnv,
116+
ConfigEnvOrder: fb.ContainerEnvOrder,
116117
SecretIDs: secretIDs,
117118
CABundle: caSecrets != nil,
118119
})

0 commit comments

Comments
 (0)