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
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,20 @@ minikube start --driver=docker --download-only

### Initialization

Initializes a new environment named <environment_name>. Creates a directory structure and a default configuration file.
Initializes a new environment named <environment_name>. Creates a directory structure, a default configuration file, and a "sample-app" service to get you started quickly.

```bash
sailr init <environment_name>
```

### Add Service

Adds a new service to your project. This creates boilerplate Kubernetes templates (`deployment.yaml`, `service.yaml`, `configmap.yaml`) in `k8s/templates/<service_name>/` and adds the service to the `develop` environment's configuration.

```bash
sailr add service <service_name> --type <app_type>
```

### Completions

Generates shell completion scripts for bash or zsh to enhance the Sailr CLI experience.
Expand Down Expand Up @@ -89,16 +97,18 @@ sailr build <environment_name> [--ignore <service1,service2,...>]
Combines generation and deployment in a single command for the <environment_name> environment.

```bash
sailr go <environment_name>:
sailr go <environment_name>
```

### Additional Notes

- Use the --force flag with build to rebuild all service images regardless of the cache.
- For a full list of commands and their detailed options, please see the [CLI Command Reference](docs/docs/cli-usage.md).

### Getting Help

- Consult the Sailr project documentation [here](docs/docs/intro.md).
- Consult the main Sailr project documentation [here](docs/docs/intro.md).
- For detailed CLI command information, refer to the [CLI Command Reference](docs/docs/cli-usage.md).

## Sailr Configuration File

Expand Down
44 changes: 44 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
schema_version = "0.2.0"
name = "dev"
log_level = "INFO"
domain = "example.com"
default_replicas = 1
registry = "docker.io"

[[service_whitelist]]
version = "latest"
path = ""
name = "default/test"

[[service_whitelist]]
path = "core/test2"
build = "./test"
name = "test-namespace/test2"
version = "1.2.0"

[[service_whitelist]]
name = "default/test-portal2"
path = "test-portal2"
version = "latest"

[build]
beforeAll = "echo 'do something before'"

[build.rooms.test]
path = "./test"
include = "./**/*.*"
after = "docker push test:latest"

[build.rooms.test2]
path = "./test2"
include = "./**/*.*"
before = "docker build -t docker.io/test2:latest ."
after = "docker push docker.io/test2:latest"

[[environment_variables]]
name = "REDIS_HOST"
value = "redis"

[[environment_variables]]
name = "REDIS_PORT"
value = "6379"
24 changes: 24 additions & 0 deletions docs/docs/cli-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,30 @@ Initializes a new Sailr environment, creating its directory structure (e.g., `./
# Initialize with a custom registry and AWS provider settings
sailr init --name staging --registry quay.io/my-company --provider Aws --region us-east-1
```
* **Note on Default Service:** The `sailr init` command also creates a default "sample-app" service. This includes generating basic Kubernetes manifest templates (Deployment, Service, ConfigMap) in `k8s/templates/sample-app/` and adding a corresponding service entry to the new environment's `config.toml`. This makes the newly initialized environment immediately runnable and provides a quick way to demonstrate Sailr's capabilities.

---

### `sailr add service`

Adds a new service to your Sailr project. This involves generating boilerplate Kubernetes manifest templates and updating the environment configuration.

* **Usage:** `sailr add service <SERVICE_NAME> --type <APP_TYPE>`
* **Arguments & Options:**
* `<SERVICE_NAME>`: (Required) The name for the new service (e.g., `my-api`, `frontend-app`). This name will be used for the template directory and in the service configuration.
* `-t, --type <APP_TYPE>`: (Required) Specifies the type of application (e.g., `web-app`, `worker`, `database`). This can influence the structure and content of the generated templates.
* **Actions Performed:**
* Creates a new directory `k8s/templates/<SERVICE_NAME>/`.
* Generates the following Kubernetes manifest template files within this directory:
* `deployment.yaml`
* `service.yaml`
* `configmap.yaml`
* Adds a new service entry to the `k8s/environments/develop/config.toml` file (assuming "develop" is the current or default environment for this operation). This entry allows Sailr to manage and deploy the new service.
* **Example:**
```bash
# Add a new web application service named "user-api"
sailr add service user-api --type web-app
```

---

Expand Down
32 changes: 32 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ pub enum Commands {
Go(GoArgs),
/// Kubernetes resources commands
K8s(K8sArgs),
/// Add a new service to the project
AddService(AddServiceArgs),
}

#[derive(Debug, Args)]
Expand Down Expand Up @@ -373,3 +375,33 @@ pub struct GetArgs {
)]
pub context: String,
}

#[derive(Debug, Args)]
pub struct AddServiceArgs {
#[arg(help = "Name of the service")]
pub service_name: String,

#[arg(
short = 't',
long = "type",
help = "Type of the application (e.g., web-app, worker)"
)]
pub app_type: String,

#[arg(
short = 'p',
long = "port",
help = "Port for the service (default is 80)"
)]
pub port: Option<u16>,

#[arg(
short = 'i',
long = "image",
help = "Docker image for the service (default is 'nginx:latest')"
)]
pub image: Option<String>,

#[arg(short = 'n', long = "name", help = "Environment to add the service to")]
pub env_name: String,
}
Loading
Loading