Repository navigation
feat(docker): support ssh-based commands in the docker image - #2183
Merged
Merged
Conversation
Install openssh-client and rsync, bind port forwardings to the container interface and document how to pass the ssh key. Closes #2182
Allocate a TTY only when interactive, fail on missing keys instead of creating a directory, make the key configurable, warn about host networking and document root-owned downloads. CI now checks that ssh, scp, ssh-keygen, rsync and GatewayPorts are in the image.
This was referenced Nov 1, 2026
martin-helmich
approved these changes
Nov 2, 2026
martin-helmich
pushed a commit
that referenced
this pull request
Nov 2, 2026
Closes #2184 - both stages on `ubuntu:26.04` - the builder picks the tarball via `TARGETARCH` instead of `uname -p`. On 26.04 `uname -p` returns `unknown`, so arm64 would have gotten the x64 tarball - the builder runs on `$BUILDPLATFORM`, so the tarball is extracted natively, not under QEMU. The final stage is still built per target platform - dropped the `ARCH` build arg. Neither workflow sets it, and with `TARGETARCH` picking the tarball it could combine an arm64 base with x64 binaries. `--platform` is now the only way to pick the architecture Tested with the v1.28.1 release tarballs: arm64 and amd64 images both start with the right arch (`mw --version` shows `linux-arm64` / `linux-x64`), and `mw project list` against the API works on both. The CI path (only the linux-x64 tarball, `PKG_SOURCE=dist`) builds and runs too. This touches the same lines of the Dockerfile as #2183, whichever goes in second needs a small rebase. `openssh-client` and `rsync` install fine on 26.04 (OpenSSH 10.2, rsync 3.4.1). The builder now fails with `unsupported architecture: <arch>` for anything but amd64/arm64 instead of silently packing the x64 binary (e.g. `--platform linux/s390x` used to build an image that crashed on start).
martin-helmich
pushed a commit
that referenced
this pull request
Nov 2, 2026
Closes #2186 `container cp` had `--ssh-identity-file` in its flags but never handed it to scp. The scp args are now built in `buildScpArgs` (`src/lib/resources/ssh/scp.ts`), which adds `-i <file>` when set, same as `buildSSHClientFlags` does for ssh. Without the flag the args are exactly as before. Unit tests cover `-i` placement, paths with spaces, the unset case and `-p`/`-r`. This also matters for the Docker image (#2183): there the key gets mounted at an arbitrary path and passed via `MITTWALD_SSH_IDENTITY_FILE`, which so far only worked for everything except `container cp`. `ScpArgsOptions` requires the `ssh-identity-file` key (`Pick<SSHConnectionFlags, ...>`), so a caller dropping it fails to compile instead of silently losing the key again.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2182
The Docker image had no
sshand norsync, so every SSH-based command (container exec|cp|port-forward,app ssh,app download|upload, ...) failed in the container.openssh-clientandrsyncin the runtime imageGatewayPorts yesin/etc/ssh/ssh_config.d/, soport-forwardbinds to the container interface and the port can be published withdocker run -p. This only affects the container's own network namespace. With--network hostthe forwarding would listen on all host interfaces though, so the README example uses-p 127.0.0.1:...MITTWALD_SSH_IDENTITY_FILE~/.bashrc/~/.zshrcto use the image like a localmw. It only adds-twhen stdin and stdout are terminals, so pipes work, and the key is configurable viaMW_SSH_KEY(only that one key gets mounted). Keys are mounted with--mount ...,readonly, so a missing key fails instead of docker creating a directory. Plus notes on root-owned downloads on Linux, paths outside the working dir, and not combining port forwarding with--network hostssh,scp,ssh-keygen,rsyncandGatewayPorts yesare in the imageTested with an image built from this Dockerfile and the v1.28.1 linux-arm64 release tarball:
container exec,app download --dry-runandcontainer port-forward(HTTP 301 from the container through-p 127.0.0.1:18080:18080) worked against a real project.container cponly honorsMITTWALD_SSH_IDENTITY_FILEwith #2187, until then it only finds keys at the default~/.ssh/id_*paths.Follow-ups after testing: the
mw()function only mounts the key if it exists (token-only commands work without a key), the port-forward example passes--project-id(no persisted context in a fresh container), and the ownership note now also covers rsync keeping the remote numeric owner.