build: resolve --remote as SSH config alias when it has no @

scripts/build-and-push.sh now parses ~/.ssh/config (or --ssh-config)
when --remote is a bare alias like 'prod'. It extracts HostName,
User, Port and IdentityFile from the matching Host block, falls back
to the current user / port 22, and uses the config IdentityFile when
--ssh-key is not given. --ssh-key always wins. The resolved target
is shown in the logs before any docker/pussh call, and is the form
passed to docker pussh and the verification ssh.

Wildcards, Include and Match directives are intentionally not handled:
ssh itself resolves them when the alias is passed through, but the
script logs the expanded target first for visibility.
This commit is contained in:
2026-09-08 18:35:23 -03:00
parent 3b0e6b4a3f
commit 38b22648f1
2 changed files with 105 additions and 10 deletions
+23
View File
@@ -22,6 +22,29 @@ It can be invoked from any directory: by default it resolves the project root
from the script's own location. Override with `--project-dir PATH` or the
`PROJECT_DIR` environment variable when needed.
### SSH config aliases
`--remote` accepts either an explicit `user@host[:port]` or a bare alias that
is resolved from `~/.ssh/config`. The matching `Host` block supplies
`HostName`, `User`, `Port` and `IdentityFile` automatically:
```text
# ~/.ssh/config
Host prod
HostName prod.example.com
User deploy
Port 22
IdentityFile ~/.ssh/deploy_ed25519
```
```shell script
./scripts/build-and-push.sh --remote prod
# Resolves to deploy@prod.example.com:22 using ~/.ssh/deploy_ed25519
```
`--ssh-key` always overrides the config `IdentityFile`. Use `--ssh-config PATH`
to point at a non-default config file.
## Running the application in dev mode
You can run your application in dev mode that enables live coding using: