fix: bind local compose builds to the active Docker context

This commit is contained in:
2026-11-01 19:11:47 +08:00
parent 98ad60c0b8
commit 11efdaa331

View File

@@ -44,9 +44,9 @@ def compose(*args, **kwargs):
env.update(ORBIT_LOCAL_DIRECTORY=str(PRIVATE), env.update(ORBIT_LOCAL_DIRECTORY=str(PRIVATE),
ORBIT_LOCAL_USER=f'{os.getuid()}:{os.getgid()}') ORBIT_LOCAL_USER=f'{os.getuid()}:{os.getgid()}')
# 本地环境使用 Docker 自带构建器,不占用用户选中的跨平台构建器。 # 本地环境使用 Docker 自带构建器,不占用用户选中的跨平台构建器。
env.update(BUILDX_BUILDER=subprocess.check_output( docker_context = subprocess.check_output(['docker', 'context', 'show'], text=True).strip()
['docker', 'context', 'show'], text=True).strip(), COMPOSE_BAKE='false') env.update(BUILDX_BUILDER=docker_context, COMPOSE_BAKE='false')
command = ['docker', 'compose', '--project-name', 'orbit-test', command = ['docker', '--context', docker_context, 'compose', '--project-name', 'orbit-test',
'--env-file', str(ENV_FILE), '-f', str(ROOT / 'deploy/docker-compose.yml'), '--env-file', str(ENV_FILE), '-f', str(ROOT / 'deploy/docker-compose.yml'),
'-f', str(ROOT / 'deploy/local/compose.yml'), *args] '-f', str(ROOT / 'deploy/local/compose.yml'), *args]
return subprocess.run(command, cwd=ROOT, env=env, check=True, **kwargs) return subprocess.run(command, cwd=ROOT, env=env, check=True, **kwargs)