Remove unused

This commit is contained in:
f-trycua
2025-10-11 22:14:00 -07:00
parent 7b286f77c6
commit 1a83931587
5 changed files with 0 additions and 571 deletions

View File

@@ -1,21 +0,0 @@
MIT License
Copyright (c) 2025 CUA
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -1,127 +0,0 @@
.PHONY: build run stop push clean test logs shell
IMAGE_NAME := trycua/cua-docker-xfce
TAG := latest
CONTAINER_NAME := cua-docker-xfce-test
# Build the Docker image
build:
docker build -t $(IMAGE_NAME):$(TAG) .
# Run the container
run:
docker run -d \
--name $(CONTAINER_NAME) \
--shm-size=512m \
-p 5901:5901 \
-p 6901:6901 \
-p 8000:8000 \
$(IMAGE_NAME):$(TAG)
@echo "Container started!"
@echo "noVNC: http://localhost:6901"
@echo "VNC: localhost:5901 (password: password)"
@echo "API: http://localhost:8000"
# Run with custom resolution
run-hd:
docker run -d \
--name $(CONTAINER_NAME) \
--shm-size=512m \
-p 5901:5901 \
-p 6901:6901 \
-p 8000:8000 \
-e VNC_RESOLUTION=1280x720 \
$(IMAGE_NAME):$(TAG)
# Run with persistent storage
run-persist:
mkdir -p ./storage ./shared
docker run -d \
--name $(CONTAINER_NAME) \
--shm-size=512m \
-p 5901:5901 \
-p 6901:6901 \
-p 8000:8000 \
-v $(PWD)/storage:/home/cua/storage \
-v $(PWD)/shared:/home/cua/shared \
$(IMAGE_NAME):$(TAG)
# Stop and remove the container
stop:
docker stop $(CONTAINER_NAME) || true
docker rm $(CONTAINER_NAME) || true
# Push to Docker Hub
push:
docker push $(IMAGE_NAME):$(TAG)
# Clean up everything
clean: stop
docker rmi $(IMAGE_NAME):$(TAG) || true
rm -rf ./storage ./shared
# Run tests
test: build run
@echo "Waiting for services to start..."
@sleep 10
@echo "Testing noVNC..."
@curl -f http://localhost:6901 > /dev/null && echo "✓ noVNC is running" || echo "✗ noVNC failed"
@echo "Testing API..."
@curl -f http://localhost:8000 > /dev/null && echo "✓ API is running" || echo "✗ API failed"
@$(MAKE) stop
# View logs
logs:
docker logs -f $(CONTAINER_NAME)
# View supervisor logs
logs-supervisor:
docker exec $(CONTAINER_NAME) tail -f /var/log/supervisor/supervisord.log
# View individual service logs
logs-vnc:
docker exec $(CONTAINER_NAME) tail -f /var/log/supervisor/vncserver.log
logs-novnc:
docker exec $(CONTAINER_NAME) tail -f /var/log/supervisor/novnc.log
logs-api:
docker exec $(CONTAINER_NAME) tail -f /var/log/supervisor/computer-server.log
# Open a shell in the container
shell:
docker exec -it $(CONTAINER_NAME) /bin/bash
# Check supervisor status
status:
docker exec $(CONTAINER_NAME) supervisorctl status
# Restart services
restart-services:
docker exec $(CONTAINER_NAME) supervisorctl restart all
# Create a snapshot
snapshot:
docker commit $(CONTAINER_NAME) $(IMAGE_NAME):snapshot
@echo "Snapshot created: $(IMAGE_NAME):snapshot"
# Build and run
dev: build run logs
# Help
help:
@echo "Available targets:"
@echo " build - Build the Docker image"
@echo " run - Run the container"
@echo " run-hd - Run with 720p resolution"
@echo " run-persist - Run with persistent storage"
@echo " stop - Stop and remove container"
@echo " push - Push to Docker Hub"
@echo " clean - Remove image and container"
@echo " test - Build, run tests, and stop"
@echo " logs - View container logs"
@echo " logs-* - View specific service logs"
@echo " shell - Open shell in container"
@echo " status - Check supervisor status"
@echo " snapshot - Create container snapshot"
@echo " dev - Build, run, and follow logs"

View File

@@ -1,166 +0,0 @@
# Quick Start Guide
Get up and running with CUA Docker XFCE in 5 minutes.
## Prerequisites
- Docker installed and running
- Python 3.11+ (for using with CUA library)
- `cua-computer` package installed: `pip install cua-computer`
## Quick Start
### Option 1: Using Makefile (Recommended)
```bash
# Build and run
make build
make run
# Check if it's running
make status
# View logs
make logs
```
Access:
- 🌐 **Web VNC**: http://localhost:6901
- 🖥️ **VNC Client**: localhost:5901 (password: `password`)
- 🔌 **API**: http://localhost:8000
### Option 2: Using Docker Compose
```bash
# Start the container
docker-compose up -d
# View logs
docker-compose logs -f
# Stop the container
docker-compose down
```
### Option 3: Docker Command
```bash
docker run -d \
--name cua-desktop \
--shm-size=512m \
-p 5901:5901 \
-p 6901:6901 \
-p 8000:8000 \
trycua/cua-docker-xfce:latest
```
## Using with Python
```python
import asyncio
from computer import Computer
async def main():
computer = Computer(
os_type="linux",
provider_type="docker",
image="trycua/cua-docker-xfce:latest"
)
async with computer:
# Take a screenshot
screenshot = await computer.interface.screenshot()
# Open terminal
await computer.interface.hotkey("ctrl", "alt", "t")
await asyncio.sleep(1)
# Type and execute command
await computer.interface.type_text("echo 'Hello!'")
await computer.interface.press_key("Return")
asyncio.run(main())
```
## Common Tasks
### Run with custom resolution
```bash
make run-hd # 1280x720
# or
docker run -e VNC_RESOLUTION=1280x720 ...
```
### Run with persistent storage
```bash
make run-persist
# or
docker run -v $(pwd)/storage:/home/cua/storage ...
```
### View specific logs
```bash
make logs-vnc # VNC server logs
make logs-novnc # noVNC proxy logs
make logs-api # Computer-server logs
```
### Open shell in container
```bash
make shell
# or
docker exec -it cua-desktop /bin/bash
```
### Create a snapshot
```bash
make snapshot
```
## Troubleshooting
### Container won't start
```bash
# Check if ports are already in use
lsof -i :6901
lsof -i :8000
# View container logs
docker logs cua-desktop
```
### Black screen in noVNC
```bash
# Restart VNC server
docker exec cua-desktop supervisorctl restart vncserver
```
### API not responding
```bash
# Check if computer-server is running
docker exec cua-desktop supervisorctl status computer-server
# Restart computer-server
docker exec cua-desktop supervisorctl restart computer-server
```
## Next Steps
- Read the [full README](README.md) for detailed documentation
- Check out [example.py](example.py) for more usage examples
- Customize the [Dockerfile](Dockerfile) for your needs
## Clean Up
```bash
# Using Makefile
make clean
# Using docker-compose
docker-compose down -v
# Manual
docker stop cua-desktop
docker rm cua-desktop
docker rmi trycua/cua-docker-xfce:latest
```

View File

@@ -1,44 +0,0 @@
version: '3.8'
services:
cua-desktop:
build: .
image: trycua/cua-docker-xfce:latest
container_name: cua-docker-xfce
shm_size: '512m'
ports:
- "5901:5901" # VNC
- "6901:6901" # noVNC
- "8000:8000" # Computer API
environment:
- VNC_RESOLUTION=1920x1080
- VNC_COL_DEPTH=24
- VNC_PORT=5901
- NOVNC_PORT=6901
- API_PORT=8000
volumes:
- ./storage:/home/cua/storage
- ./shared:/home/cua/shared
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
# Optional: Multiple instances for parallel testing
cua-desktop-2:
build: .
image: trycua/cua-docker-xfce:latest
container_name: cua-docker-xfce-2
shm_size: '512m'
ports:
- "5902:5901"
- "6902:6901"
- "8001:8000"
environment:
- VNC_RESOLUTION=1280x720
restart: unless-stopped
profiles:
- multi

View File

@@ -1,213 +0,0 @@
#!/usr/bin/env python3
"""
Example script demonstrating how to use the CUA Docker XFCE container
with the Computer library.
"""
import asyncio
from computer import Computer
async def basic_example():
"""Basic example: Take a screenshot and click around"""
print("=== Basic Example ===")
computer = Computer(
os_type="linux",
provider_type="docker",
image="trycua/cua-docker-xfce:latest",
display="1920x1080",
memory="4GB",
cpu="2",
port=8000,
noVNC_port=6901
)
async with computer:
print("Computer is ready!")
print(f"noVNC available at: http://localhost:6901")
# Get screen info
screen = await computer.interface.get_screen_size()
print(f"Screen size: {screen['width']}x{screen['height']}")
# Take a screenshot
screenshot = await computer.interface.screenshot()
with open("screenshot.png", "wb") as f:
f.write(screenshot)
print("Screenshot saved to screenshot.png")
# Click and type
await computer.interface.left_click(100, 100)
await computer.interface.type_text("Hello from CUA!")
print("Done!")
async def file_operations_example():
"""Example: File system operations"""
print("\n=== File Operations Example ===")
computer = Computer(
os_type="linux",
provider_type="docker",
image="trycua/cua-docker-xfce:latest"
)
async with computer:
# Create a file
await computer.interface.write_text(
"/home/cua/test.txt",
"Hello from CUA!"
)
print("Created test.txt")
# Read it back
content = await computer.interface.read_text("/home/cua/test.txt")
print(f"File content: {content}")
# List directory
files = await computer.interface.list_dir("/home/cua")
print(f"Files in home directory: {files}")
async def command_execution_example():
"""Example: Running shell commands"""
print("\n=== Command Execution Example ===")
computer = Computer(
os_type="linux",
provider_type="docker",
image="trycua/cua-docker-xfce:latest"
)
async with computer:
# Run a command
result = await computer.interface.run_command("uname -a")
print(f"System info:\n{result.stdout}")
# Check Firefox is installed
result = await computer.interface.run_command("which firefox")
print(f"Firefox location: {result.stdout.strip()}")
# Get Python version
result = await computer.interface.run_command("python3 --version")
print(f"Python version: {result.stdout.strip()}")
async def browser_automation_example():
"""Example: Opening Firefox and navigating"""
print("\n=== Browser Automation Example ===")
computer = Computer(
os_type="linux",
provider_type="docker",
image="trycua/cua-docker-xfce:latest"
)
async with computer:
# Open Firefox
await computer.interface.run_command("firefox https://example.com &")
print("Firefox opened")
# Wait for it to load
await asyncio.sleep(5)
# Take a screenshot
screenshot = await computer.interface.screenshot()
with open("browser_screenshot.png", "wb") as f:
f.write(screenshot)
print("Browser screenshot saved")
async def persistent_storage_example():
"""Example: Using persistent storage"""
print("\n=== Persistent Storage Example ===")
computer = Computer(
os_type="linux",
provider_type="docker",
image="trycua/cua-docker-xfce:latest",
shared_directories=["./storage"]
)
async with computer:
# Write to persistent storage
await computer.interface.write_text(
"/home/cua/storage/persistent.txt",
"This file persists across container restarts!"
)
print("Written to persistent storage")
# Read it back
content = await computer.interface.read_text(
"/home/cua/storage/persistent.txt"
)
print(f"Content: {content}")
async def multi_action_example():
"""Example: Complex interaction sequence"""
print("\n=== Multi-Action Example ===")
computer = Computer(
os_type="linux",
provider_type="docker",
image="trycua/cua-docker-xfce:latest"
)
async with computer:
# Open terminal
await computer.interface.hotkey("ctrl", "alt", "t")
await asyncio.sleep(2)
# Type a command
await computer.interface.type_text("echo 'Hello from CUA!'")
await computer.interface.press_key("Return")
await asyncio.sleep(1)
# Take screenshot
screenshot = await computer.interface.screenshot()
with open("terminal_screenshot.png", "wb") as f:
f.write(screenshot)
print("Terminal screenshot saved")
async def main():
"""Run all examples"""
examples = [
("Basic", basic_example),
("File Operations", file_operations_example),
("Command Execution", command_execution_example),
("Browser Automation", browser_automation_example),
("Persistent Storage", persistent_storage_example),
("Multi-Action", multi_action_example),
]
print("Available examples:")
for i, (name, _) in enumerate(examples, 1):
print(f"{i}. {name}")
print(f"{len(examples) + 1}. Run all")
choice = input("\nSelect an example (1-7): ").strip()
try:
if choice == str(len(examples) + 1):
# Run all examples
for name, func in examples:
try:
await func()
except Exception as e:
print(f"Error in {name}: {e}")
else:
idx = int(choice) - 1
if 0 <= idx < len(examples):
await examples[idx][1]()
else:
print("Invalid choice")
except ValueError:
print("Invalid input")
if __name__ == "__main__":
asyncio.run(main())