Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,28 @@ arm-cli --help
```
You can also use:


```bash
python -m arm_cli --help
```

### Container Management
The CLI includes tools for managing Docker containers:

```bash
# List running containers
arm-cli container list

# Attach to a container interactively (sources ROS and interactive entrypoints)
arm-cli container attach

# Restart a container
arm-cli container restart

# Stop a container
arm-cli container stop
```

For more details on container compliance, see [arm_cli/container/readme.md](arm_cli/container/readme.md).
## Development

To contribute to this tool, first checkout the code. Then create a new virtual environment. From the root of the repo:
Expand Down
14 changes: 13 additions & 1 deletion arm_cli/container/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,20 @@ def attach_container(ctx):

print(f"Attaching to {selected_container_name}...")

cmd = """
if [ -f /ros_entrypoint.sh ]; then
source /ros_entrypoint.sh
fi
if [ -f /interactive_entrypoint.sh ]; then
source /interactive_entrypoint.sh
fi
exec bash
"""

try:
subprocess.run(["docker", "exec", "-it", selected_container_name, "/bin/bash"], check=True)
subprocess.run(
["docker", "exec", "-it", selected_container_name, "bash", "-c", cmd], check=True
)
except subprocess.CalledProcessError as e:
print(f"Error attaching to container: {e}")
except KeyboardInterrupt:
Expand Down
40 changes: 40 additions & 0 deletions arm_cli/container/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Container Compliance for arm-cli

While not strictly necessary, to work with arm-cli's interactive attach:

## Entrypoint Scripts

arm-cli attach will automatically source the following scripts if they exist:

1. `/ros_entrypoint.sh` - Standard ROS entrypoint script
2. `/interactive_entrypoint.sh` - Custom interactive entrypoint script

### ROS Entrypoint Script

Most ROS containers already include `/ros_entrypoint.sh`. This script typically:
- Sets up ROS environment variables
- Sources ROS setup files
- Configures the ROS workspace

### Interactive Entrypoint Script

Add /interactive_entrypoint.sh in your image:

```
#!/bin/bash
[ -f /opt/ros/$ROS_DISTRO/setup.bash ] && source /opt/ros/$ROS_DISTRO/setup.bash
[ -f /ros2_ws/install/setup.bash ] && source /ros2_ws/install/setup.bash
exec "$@"
```

Dockerfile:
```
COPY interactive_entrypoint.sh /interactive_entrypoint.sh
ENTRYPOINT ["/interactive_entrypoint.sh"]
```

Behavior:
arm-cli attach <container> sources both scripts in order if present:
1. First sources `/ros_entrypoint.sh` (if it exists)
2. Then sources `/interactive_entrypoint.sh` (if it exists)
3. Falls back to plain bash if neither exists