Skip to content

Commit

Permalink
apacheGH-41007: [CI][Archery] Correctly interpolate environment varia…
Browse files Browse the repository at this point in the history
…bles from docker compose when using docker cli on archery docker (apache#41026)

### Rationale for this change

Currently our verification jobs are failing due to environment variables not being correctly interpolated. docker compose expects a double `$$` sign on the command as explained here:
https://docs.docker.com/compose/compose-file/12-interpolation/
When we use `ARCHERY_USE_DOCKER_CLI=1` we are using `docker run` instead of `docker compose run`. The behaviour of the command changes and we have to update change the environment variable.

### What changes are included in this PR?

Use correct docker compose binary when using `docker cli` and remove double $$.

### Are these changes tested?

Via archery

### Are there any user-facing changes?

No
* GitHub Issue: apache#41007

Authored-by: Raúl Cumplido <raulcumplido@gmail.com>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
  • Loading branch information
raulcd authored Apr 5, 2024
1 parent 7da285e commit 17e51cc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion dev/archery/archery/docker/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ def docker(ctx, src, dry_run, using_docker_cli, using_docker_buildx):
compose = DockerCompose(config_path, params=os.environ,
using_docker=using_docker_cli,
using_buildx=using_docker_buildx,
debug=ctx.obj.get('debug', False))
debug=ctx.obj.get('debug', False),
compose_bin=("docker compose" if using_docker_cli
else "docker-compose"))
if dry_run:
_mock_compose_calls(compose)
ctx.obj['compose'] = compose
Expand Down
4 changes: 4 additions & 0 deletions dev/archery/archery/docker/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,10 @@ def run(self, service_name, command=None, *, env=None, volumes=None,
# on the docker-compose yaml file.
if isinstance(cmd, list):
cmd = shlex.join(cmd)
# Match behaviour from docker compose
# to interpolate environment variables
# https://docs.docker.com/compose/compose-file/12-interpolation/
cmd = cmd.replace("$$", "$")
args.extend(shlex.split(cmd))

# execute as a plain docker cli command
Expand Down

0 comments on commit 17e51cc

Please sign in to comment.