Automate your remote development workflow with this powerful CLI tool! π»β¨
- Devcontainer Automation: Effortlessly create, build, and start devcontainers on remote hosts. π¦
- Interactive Shell: Access your devcontainer with an interactive shell for seamless command execution. π
- Automatic File Synchronization: Keep your local and remote directories in sync with real-time file monitoring. π
- SSH Key Management: Securely manage SSH keys for authentication. π
- Docker Integration: Validate and install Docker and Docker Compose on remote servers. π³
- Configuration Management: Easily configure your remote development environment with a JSON configuration file. βοΈ
- Caching: Reuses SSH connections and container names for faster subsequent runs. β‘
- Logging: Detailed logging for debugging and monitoring. π
-
Python >=3.11
-
uv python package manager
-
A remote host with SSH access
-
Docker and Docker Compose installed on the remote host
Note: The CLI can install them for you!
-
Clone the repository:
git clone github.com/mohamedashraf-eng/remote-developer cd remote-developer -
Install the required Python packages:
uv venv uv sync && uv sync --upgrade
-
Create a
config.jsonfile (or copy and modifyremote-developer-config.example.json):{ "remote_host": "user@remote-host.example.com", "docker_image": "example-image:latest", "remote_dir": "/home/user/example-project", "port_mappings": [ "1234:1234", "5678:5678" ], "devcontainer_template": "./templates/devcontainer-template.txt.example", "dockerfile_template": "./templates/dockerfile-template.txt.example", "docker_compose_template": "./templates/docker-compose-template.txt.example", "dockerignore_template": "./templates/dockerignore-template.txt.example" }remote_host: SSH user and host (e.g.,user@192.168.1.100).docker_image: Docker image to use for the devcontainer.remote_dir: Remote directory where the project will be stored.port_mappings: List of port mappings (e.g.,["8080:8080", "3000:3000"]).devcontainer_template,dockerfile_template,docker_compose_template,dockerignore_template: Paths to template files.
-
Customize the template files in the
templates/directory as needed. Example templates are provided with the.exampleextension.
Tip: The base templates function correctly as is.
uv run remote_developer.py --config config.json --path /path/to/your/project <command>--config: Path to theconfig.jsonfile.--path: Path to your local project directory.
Starts the devcontainer.
python remote_developer.py --config config.json --path /path/to/your/project startOptions:
--auto-sync: Automatically syncs the local and remote directories.--keep-alive: Keeps the SSH connection alive and opens an interactive shell after starting the devcontainer.
Example:
python remote_developer.py --config config.json --path /path/to/your/project start --auto-sync --keep-aliveSyncs files from the local directory to the remote directory.
python remote_developer.py --config config.json --path /path/to/your/project syncOptions:
--auto-sync: Starts auto-sync in the background, monitoring for file changes.
Example:
python remote_developer.py --config config.json --path /path/to/your/project sync --auto-syncRuns a command on the remote host inside the devcontainer.
python remote_developer.py --config config.json --path /path/to/your/project run <command>Example:
python remote_developer.py --config config.json --path /path/to/your/project run ls -l /home/user/example-project/workspace-
Start the devcontainer and keep the shell open:
python remote_developer.py --config config.json --path /path/to/your/project start --keep-alive
This will start the devcontainer and open an interactive shell. You can then execute commands directly in the devcontainer. Type
exitto close the shell. -
Start the devcontainer with automatic file synchronization:
python remote_developer.py --config config.json --path /path/to/your/project start --auto-sync
This will start the devcontainer and automatically sync files between your local and remote directories.
-
Run a specific command in the devcontainer:
python remote_developer.py --config config.json --path /path/to/your/project run python --version
This will execute the
python --versioncommand inside the devcontainer and print the output.
- SSH keys are used for authentication. The CLI will guide you through generating and setting up SSH keys if needed.
- The CLI uses
rsyncover SSH for file synchronization, ensuring secure data transfer. - The
CLICommandExecutorclass includes security measures to prevent command injection vulnerabilities.
Detailed logs are generated to help you troubleshoot any issues. The log level can be configured using the LOG_LEVEL environment variable (e.g., DEBUG, INFO, WARNING, ERROR, CRITICAL).
Example:
LOG_LEVEL=DEBUG python remote_developer.py --config config.json --path /path/to/your/project startCACHE_LOCATION: Specifies the location of the cache file. Defaults to platform-specific locations (Windows Registry, macOS plist, Linux JSON file).LOG_LEVEL: Specifies the log level. Defaults toINFO.
The CLI uses template files for generating the devcontainer.json, Dockerfile, and docker-compose.yml files. You can customize these templates to suit your specific needs.
Contributions are welcome! Please submit a pull request with your changes.
This project is licensed under the MIT License. See the LICENSE file for details.
Copyright (c) 2025 MoWx