diff --git a/container/README.md b/container/README.md index d0f5ae97..08b90955 100644 --- a/container/README.md +++ b/container/README.md @@ -105,7 +105,7 @@ docker build -f container/Dockerfile --build-arg COPILOT_VERSION=1.0.105 -t copi python3 container/smoke_test.py copilot-cli:local --version 1.0.105 ``` -The smoke test needs only Python 3 and Docker. It checks the container's configuration and a real client handshake with the running server. Add `--platform linux/arm64` or `--platform linux/amd64` to test a build for another architecture. +The smoke test needs only Python 3 and Docker. It checks the container's configuration, Git access to a bind-mounted repository owned by the host user, and a real client handshake with the running server. Add `--platform linux/arm64` or `--platform linux/amd64` to test a build for another architecture. ## Publishing diff --git a/container/smoke_test.py b/container/smoke_test.py index 4b1cda87..373932bf 100755 --- a/container/smoke_test.py +++ b/container/smoke_test.py @@ -161,14 +161,21 @@ def check_runtime_environment(target): def check_git_workspace(target): with tempfile.TemporaryDirectory(prefix="copilot-git-safe-") as workspace: + # The runtime UID needs access, while the host must own the files for cleanup. + os.chmod(workspace, 0o755) volume = "%s:/home/copilot/workspace" % workspace initialized = run_to_completion( target, - ["--user", "0:0", "--volume", volume, "--entrypoint", "git"], - ["init", "--quiet", "/home/copilot/workspace"], + [ + "--user", "%d:%d" % (os.getuid(), os.getgid()), + "--volume", "%s:/tmp/workspace" % workspace, + "--workdir", "/tmp/workspace", + "--entrypoint", "git", + ], + ["init", "--quiet"], ) if initialized.returncode != 0: - raise Failure("could not initialize a root-owned workspace repository: %s" % initialized.stderr.strip()) + raise Failure("could not initialize a host-owned workspace repository: %s" % initialized.stderr.strip()) result = run_to_completion( target,