Metadata-Version: 2.4
Name: minicloud
Version: 1.0.1
Summary: Docker container management library for Python
Home-page: https://github.com/ImMrShervin/minicloud
Author: Shervin Mirzaei
Author-email: Shervin Mirzaei <shervinmr84@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/ImMrShervin/minicloud
Project-URL: Repository, https://github.com/ImMrShervin/minicloud
Keywords: docker,container,vps,management,ssh
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: System :: Systems Administration
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: docker>=7.0.0
Requires-Dist: psutil>=5.9.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0; extra == "dev"
Requires-Dist: ruff>=0.1.0; extra == "dev"
Dynamic: author
Dynamic: home-page
Dynamic: license-file
Dynamic: requires-python

# minicloud

Docker container management library for Python. Create and manage VPS containers with SSH access.

## Installation

```bash
pip install minicloud
```

## Quick Start

```python
from minicloud import CloudManager

cm = CloudManager()

# Create a container
container = cm.create_container(
    name="my-app",
    ram=512,
    cpu=100,
    disk=10,
    port=3000,
    ssh_password="mypassword"
)

print(f"Container ID: {container['container_id']}")
```

## Usage

### Create Container

```python
from minicloud import CloudManager

cm = CloudManager()

container = cm.create_container(
    name="my-app",
    ram=512,      # 512 MB RAM
    cpu=100,       # 1 CPU core (100 = 1 core)
    disk=10,       # 10 GB disk
    port=3000,     # SSH port
    image="ubuntu:22.04",
    ssh_password="secure-password"
)
```

### List Containers

```python
containers = cm.list_containers()

for c in containers:
    print(f"{c['name']}: {c['status']}")
```

### Get Container Info

```python
info = cm.get_container_info("my-app")
print(f"Status: {info['status']}")
print(f"Port: {info['port']}")
```

### Get Container Stats

```python
stats = cm.get_container_stats("my-app")
print(f"CPU: {stats['cpu_percent']}%")
print(f"Memory: {stats['memory_used']}/{stats['memory_limit']} MB")
```

### Start/Stop/Restart

```python
cm.start_container("my-app")
cm.stop_container("my-app")
cm.restart_container("my-app")
```

### Delete Container

```python
cm.delete_container("my-app")
```

### Server Info

```python
server = cm.get_server_info()
print(f"Hostname: {server['hostname']}")
print(f"Available RAM: {server['available_ram']} MB")
print(f"Containers: {server['containers_count']}")
```

## Custom Configuration

### Custom Prefix

```python
cm = CloudManager(prefix="vps")
# Containers will be named: vps_my-app
```

### Custom Allowed Images

```python
cm = CloudManager(allowed_images=[
    "ubuntu:22.04",
    "debian:12",
    "nginx:latest",
])
```

## Error Handling

```python
from minicloud import CloudManager, ContainerAlreadyExistsError, ImageNotAllowedError

try:
    cm.create_container(
        name="my-app",
        ram=512,
        cpu=100,
        disk=10,
        port=3000
    )
except ContainerAlreadyExistsError:
    print("Container already exists")
except ImageNotAllowedError as e:
    print(f"Image not allowed: {e}")
```

## Available Images

Default allowed images:
- `ubuntu:22.04`
- `ubuntu:20.04`
- `debian:12`
- `debian:11`
- `alpine:latest`
- `centos:7`

## License

MIT
