Skip to content

Commit

Permalink
feat: enhance service configuration with OCI defaults and improve run…
Browse files Browse the repository at this point in the history
…time features (#92)

* Support fallback to OCI image config.json for service defaults
  - Auto-populate workdir from OCI config
  - Use entrypoint/cmd for command and args
  - Inherit environment variables from image

* Add support for multiple port mappings per service
  - Replace single port with ports array
  - Update validation for port conflicts
  - Maintain backward compatibility

* Improve logging system
  - Implement log rotation
  - Add supervisor logs viewing
  - Enhance log formatting and organization

* Refactor path handling
  - Remove static global paths
  - Use dynamic path resolution
  - Better organization of monocore directories

BREAKING CHANGE: Service port configuration now uses 'ports' array instead of single 'port' field
  • Loading branch information
appcypher authored Jan 8, 2025
1 parent 299b108 commit 107e551
Show file tree
Hide file tree
Showing 23 changed files with 1,026 additions and 351 deletions.
9 changes: 9 additions & 0 deletions .todo.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,12 @@
- [ ] Use sqlitedb for maintaining running services state.
- [ ] Fix issue with services running even after the config is deleted.
- [ ] We should be able to guarantee that service is dead when the config is deleted.

- [ ] Treating microvm management like a package manager.
- [ ] Store service rootfs, state, logs locally in a .mc directory kind of like ./node_modules.
- [ ] Store reference rootfses (oci & monofs) in home_dir with a special store that links to them from forked rootfses.

- [ ] Support multiple registries.
- [ ] Use `Reference` type for image_ref where it makes sense: https://docs.rs/oci-spec/0.7.1/oci_spec/distribution/struct.Reference.html
- [ ] Qualify image names fully where needed. <registry>/<repo>:<tag>
- [ ] Instead of sanitizing image refs, we should just hash them instead.
70 changes: 68 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 28 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@

<p>
<a href="https://discord.gg/T95Y3XnEAK">
<img src="https://img.shields.io/static/v1?label=Discord&message=join%20us!&color=mediumslateblue" alt="Discord">
<img src="https://img.shields.io/static/v1?label=Discord&message=join%20us!&color=mediumslateblue&logo=discord&logoColor=white" alt="Discord">
</a>
<a href="https://github.com/appcypher/monocore/actions?query=">
<img src="https://github.com/appcypher/monocore/actions/workflows/tests_and_checks.yml/badge.svg" alt="Build Status">
</a>
<a href="https://crates.io/crates/monocore">
<img src="https://img.shields.io/crates/v/monocore?label=crates" alt="Monocore Crate">
<img src="https://img.shields.io/crates/v/monocore?label=crates&logo=rust" alt="Monocore Crate">
</a>
<a href="https://docs.rs/monocore">
<img src="https://img.shields.io/static/v1?label=Docs&message=docs.rs&color=blue" alt="Monocore Docs">
<img src="https://img.shields.io/static/v1?label=Docs&message=docs.rs&color=blue&logo=docs.rs" alt="Monocore Docs">
</a>
<a href="https://github.com/appcypher/monocore/blob/main/LICENSE">
<img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg" alt="License">
<img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg?logo=apache&logoColor=white" alt="License">
</a>
</p>
</div>
Expand All @@ -31,7 +31,7 @@ Building AI agents that write and execute code? You'll need a secure sandbox.
- Generate visualizations and charts
- Run data analysis scripts
- Execute system commands safely
- Create and test web applications
- Create and host web applications
- Run automated browser tasks
- Perform complex calculations

Expand Down Expand Up @@ -100,29 +100,29 @@ This will install both the `monocore` command and its alias `mc`.
```toml
# monocore.toml
[[service]]
name = "sh-counter"
base = "alpine:latest"
ram = 256
cpus = 1
group = "demo"
command = "/bin/sh"
args = ["-c", "for i in $(seq 1 20); do echo $i; sleep 2; done"]

[[service]]
name = "python-counter"
base = "python:3.11-slim"
ram = 256
cpus = 1
group = "demo"
command = "/usr/local/bin/python3"
args = [
"-c",
"import time; count=0; [print(f'Count: {count+1}') or time.sleep(2) or (count:=count+1) for _ in range(20)]",
]

[[group]]
name = "demo"
local_only = true
name = "sh-counter"
base = "alpine:latest"
ram = 256
cpus = 1
group = "demo"
command = "/bin/sh"
args = ["-c", "for i in $(seq 1 20); do echo $i; sleep 2; done"]

[[service]]
name = "python-counter"
base = "python:3.11-slim"
ram = 256
cpus = 1
group = "demo"
command = "/usr/local/bin/python3"
args = [
"-c",
"import time; count=0; [print(f'Count: {count+1}') or time.sleep(2) or (count:=count+1) for _ in range(20)]",
]

[[group]]
name = "demo"
local_only = true
```

2. **Manage your sandboxes**
Expand Down
4 changes: 2 additions & 2 deletions monocore.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"ram": 256,
"cpus": 1,
"group": "demo",
"command": "/bin/sh",
"command": "sh",
"args": ["-c", "for i in $(seq 1 20); do echo $i; sleep 2; done"]
},
{
Expand All @@ -15,7 +15,7 @@
"ram": 256,
"cpus": 1,
"group": "demo",
"command": "/usr/local/bin/python3",
"command": "python",
"args": [
"-c",
"import time; count=0; [print(f'Count: {count+1}') or time.sleep(2) or (count:=count+1) for _ in range(20)]"
Expand Down
4 changes: 2 additions & 2 deletions monocore.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ base = "alpine:latest"
ram = 256
cpus = 1
group = "demo"
command = "/bin/sh"
command = "sh"
args = ["-c", "for i in $(seq 1 20); do echo $i; sleep 2; done"]

[[service]]
Expand All @@ -13,7 +13,7 @@ base = "python:3.11-slim"
ram = 256
cpus = 1
group = "demo"
command = "/usr/local/bin/python3"
command = "python"
args = [
"-c",
"import time; count=0; [print(f'Count: {count+1}') or time.sleep(2) or (count:=count+1) for _ in range(20)]",
Expand Down
2 changes: 2 additions & 0 deletions monocore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ pretty-error-debug.workspace = true
serde_yaml = "0.9.34"
async-stream.workspace = true
pin-project = "1.1.7"
tracing-appender = "0.2.3"
pin-project-lite = "0.2.15"

[dev-dependencies]
test-log.workspace = true
Expand Down
8 changes: 4 additions & 4 deletions monocore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@

<p>
<a href="https://discord.gg/T95Y3XnEAK">
<img src="https://img.shields.io/static/v1?label=Discord&message=join%20us!&color=mediumslateblue" alt="Discord">
<img src="https://img.shields.io/static/v1?label=Discord&message=join%20us!&color=mediumslateblue&logo=discord&logoColor=white" alt="Discord">
</a>
<a href="https://github.com/appcypher/monocore/actions?query=">
<img src="https://github.com/appcypher/monocore/actions/workflows/tests_and_checks.yml/badge.svg" alt="Build Status">
</a>
<a href="https://crates.io/crates/monocore">
<img src="https://img.shields.io/crates/v/monocore?label=crates" alt="Monocore Crate">
<img src="https://img.shields.io/crates/v/monocore?label=crates&logo=rust" alt="Monocore Crate">
</a>
<a href="https://docs.rs/monocore">
<img src="https://img.shields.io/static/v1?label=Docs&message=docs.rs&color=blue" alt="Monocore Docs">
<img src="https://img.shields.io/static/v1?label=Docs&message=docs.rs&color=blue&logo=docs.rs" alt="Monocore Docs">
</a>
<a href="https://github.com/appcypher/monocore/blob/main/LICENSE">
<img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg" alt="License">
<img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg?logo=apache&logoColor=white" alt="License">
</a>
</p>
</div>
Expand Down
Loading

0 comments on commit 107e551

Please sign in to comment.