Files
devbox-images/devbox/base-config/dokku-cli.sh
T

26 lines
1.3 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
# Minimal Dokku remote-CLI wrapper for this Coder devbox environment — see
# base-config/Dockerfile's own comment for why this replaced the official
# dokku/dokku contrib/dokku_client.sh: that script always shells out to a
# literal `ssh` binary, which has nothing to authenticate with here (no
# live ssh-agent socket, no on-disk identity file — confirmed live: both
# `ssh-add -l` and a bare `ssh -T git@github.com` fail in a real
# workspace). Every outbound SSH connection that actually works here (git
# clones, the dokku-demo git remote push) goes through Coder's own
# GIT_SSH_COMMAND proxy instead (`<coder-agent-binary> gitssh --`), which
# Coder injects as an agent-wide env var and which fetches the real
# per-user key from the Coder control plane on demand.
set -euo pipefail
if [[ -z "${GIT_SSH_COMMAND:-}" ]]; then
echo "dokku: \$GIT_SSH_COMMAND is not set -- this only works inside a Coder-managed workspace" >&2
exit 1
fi
# GIT_SSH_COMMAND is Coder's own "<agent-binary-path> gitssh --" string;
# only the binary path is reused here, since the argv below is built from
# scratch rather than reusing the whole templated command line.
CODER_BIN="${GIT_SSH_COMMAND%% *}"
exec "$CODER_BIN" gitssh -- -p "${DOKKU_PORT:-22}" -t "dokku@${DOKKU_HOST:-dokku}" "$@"