Skip to content

Commit

Permalink
chore: updated readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
CJ-Jackson committed Dec 29, 2024
1 parent e5237e6 commit 33c831e
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 188 deletions.
90 changes: 69 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,38 +16,80 @@ the following sane open-source solution.

## How it works

### For local machine
First you need a build script for image building, for now we create a dummy.

File: `build.py`
```python
#!/usr/bin/env python3
import os
import shutil
import sys

project_path = ""
try:
project_path = os.environ["RUN_DEPLOY_PROJECT_PATH"]
except KeyError:
print("RUN_DEPLOY_PROJECT_PATH is missing", file=sys.stderr)
exit(1)
```
Give it execute right `chmod 755 build.py`

```shell
#!/bin/sh
Now we need to create the following
File: `create_image.toml`
```toml
#!/usr/bin/env run-deploy-image-toml

# Create the image
image_location=$(./create_image.py)
# Image name
name = "example"
# The location is relative to toml file
build_script = "./build.py"

# Deploy the image
run-deploy $image_location
# It will move the image to `/opt/run-deploy/image/{image_dir}`
# The hostname has to match the hostname of where it getting deployed
[manifest.hostname]
# Name of incus container
incus_name = "example"
```
Give it execute right `chmod 755 create_image.toml`
You can also test the image building by running `./create_image.toml`

### For remote machine
Now we the toml file for deploy, this is for the local machine

```shell
#!/bin/sh
File: `deploy_local.toml`
```toml
#!/usr/bin/env run-deploy-local-toml

# Image creation script to execute
create_image_script = "./create_image.toml"

# Create the image (on Local Machine)
image_location=$(./create_image.py)
incus = "example"
image = "example"
```
Give it execute right `chmod 755 deploy_local.toml`
Let deploy to local machine by running `./deploy_local.toml`

# Sign the image (on Local Machine)
minisign -Sm $image_location
For remote deploy we need to create the following TOML.

# Upload the image and signature
scp $image_location ${image_location}.minisig "[email protected]:/tmp/run-deploy"
File: `deploy_remote.toml`
```toml
#!/usr/bin/env run-deploy-remote-toml

# Deploy the image,
ssh [email protected] -- doas /opt/run-deploy/bin/run-deploy "/tmp/run-deploy/$(basename $image_location)" "$(whoami)@$(hostname)"
# Image creation script to execute
create_image_script = "./create_image.toml"

# "$(whoami)@$(hostname)" is used as public key and permission references.
# Image name (Mandatory)
image = "example"

# SSH Config, at least one is required
[ssh.'username@deploy.example-1.com']
# Mandatory for remote-incus
incus = "example"
```
Give it execute right `chmod 755 deploy_remote.toml`
Let deploy to remote machine by running `./deploy_remote.toml`

That is the jist of it. Really clean and elegant isn't it? =D

[Click here for more detail on toml-util](toml-util/README.md)

## Image Manifest

Expand Down Expand Up @@ -108,6 +150,10 @@ Run `client/install.py` as root

Run `local-incus/install.py` as root

### toml-util

Run `toml-util/install.py` as root

### For servers

Run `create_server_installer.py`, first it will open a toml file in the default text editor, edit it, add the ssh
Expand Down Expand Up @@ -287,4 +333,6 @@ In quirk mode, the squashfs exec will also need to do a symlink swap. You will n
cd /opt/run-deploy/image/example
ln -sf example-2024-12-12.squashfs example.squashfs
/opt/run-deploy/script/deploy/example
```
```

Strict mode will write it own script and is the default, Quirk mode will let you write you own script that is stored in the image, not recommended as it will run the script in root.
63 changes: 0 additions & 63 deletions test-template/create_image.py

This file was deleted.

26 changes: 0 additions & 26 deletions test-template/deploy_local.py

This file was deleted.

78 changes: 0 additions & 78 deletions test-template/deploy_remote.py

This file was deleted.

0 comments on commit 33c831e

Please sign in to comment.