Repository navigation
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·54 lines (48 loc) · 1.66 KB
/
Copy pathrun.sh
File metadata and controls
executable file
·54 lines (48 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env bash
set -euo pipefail
IMAGES="claude-php claude-ext claude-go codex-php codex-ext codex-go"
image=${1:-}
case " ${IMAGES} " in
*" ${image} "*) shift ;;
*)
echo "usage: $0 <image> [command…]" >&2
echo "images: ${IMAGES}" >&2
exit 2
;;
esac
WORKSPACE=${WORKSPACE:-$PWD}
docker_args=(--rm -it -v "${WORKSPACE}:/workspace")
case "${image}" in
claude-*)
if [ -n "${CLAUDE_CODE_OAUTH_TOKEN-}" ]; then
docker_args+=(-e "CLAUDE_CODE_OAUTH_TOKEN=${CLAUDE_CODE_OAUTH_TOKEN}")
fi
;;
codex-*)
auth_file=${CODEX_AUTH_FILE:-$HOME/.codex/auth.json}
if [ -n "${CODEX_ACCESS_TOKEN-}" ]; then
docker_args+=(-e "CODEX_ACCESS_TOKEN=${CODEX_ACCESS_TOKEN}")
elif [ -f "${auth_file}" ]; then
command -v jq > /dev/null || {
echo "jq is required to prepare Codex credentials." >&2
exit 1
}
auth_json=$(jq -ce '
if (.tokens.access_token? | type) == "string" then
.tokens.refresh_token = ""
else
error("auth file has no ChatGPT access token")
end
' "${auth_file}") || {
echo "Could not read ChatGPT credentials from ${auth_file}. Run codex login on the host." >&2
exit 1
}
docker_args+=(-e "CODEX_AUTH_JSON=${auth_json}")
fi
;;
esac
if [ -n "${GH_TOKEN-}" ]; then
docker_args+=(-e "GH_TOKEN=${GH_TOKEN}")
fi
printf 'Starting %s with %s mounted at /workspace\n' "$image" "$WORKSPACE"
exec docker run "${docker_args[@]}" "${image}" "$@"