compose/pkg/e2e/testdata/TestPreStartHookEnvFile/compose.yaml
Nicolas De Loof eef29d10c3 test(e2e): pre_start hooks must receive the service's env_file and environment
Reproduces docker/compose#14287: a hook inheriting the service's
env_file (or declaring its own) runs without those variables.

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2026-10-12 18:15:14 +02:00

18 lines
722 B
YAML

services:
app:
image: alpine
init: true
command: sleep infinity
env_file:
- service.env
environment:
FROM_SERVICE_ENV: service
pre_start:
# declares nothing: inherits the service's env_file and environment
- command: sh -c 'test "$$FROM_SERVICE_FILE" = service && test "$$FROM_SERVICE_ENV" = service'
# completes the inherited environment with its own, which wins on conflicts
- command: sh -c 'test "$$FROM_SERVICE_FILE" = service && test "$$FROM_SERVICE_ENV" = service && test "$$FROM_HOOK_FILE" = hook && test "$$FROM_HOOK_ENV" = hook && test "$$SHARED" = hook_file'
env_file:
- hook.env
environment:
FROM_HOOK_ENV: hook