### Start Local Development Server Source: https://github.com/moghtech/komodo/blob/main/docsite/README.md Starts a local development server. Changes are reflected live without restarting. ```bash $ yarn start ``` -------------------------------- ### Install Dependencies Source: https://github.com/moghtech/komodo/blob/main/docsite/README.md Run this command to install project dependencies using Yarn. ```bash $ yarn ``` -------------------------------- ### Setup Development Environment Source: https://github.com/moghtech/komodo/blob/main/ui/README.md Builds the local client dependency and links it to the UI project. ```sh cd ../client/core/ts && yarn && yarn build && yarn link && \ cd ../../../ui && yarn link komodo_client && yarn ``` -------------------------------- ### View setup-periphery help options Source: https://github.com/moghtech/komodo/blob/main/scripts/readme.md Displays the command-line interface help menu for the setup script. ```text usage: setup-periphery [-h] [--version VERSION] [--user] [--root-directory ROOT_DIRECTORY] [--core-address CORE_ADDRESS] [--connect-as CONNECT_AS] [--onboarding-key ONBOARDING_KEY] [--force-service-file FORCE_SERVICE_FILE] [--config-url CONFIG_URL] [--binary-url BINARY_URL] Install systemd-managed Komodo Periphery options: -h, --help show this help message and exit --version, -v VERSION Install a specific Komodo version, like 'v2.0.0' (default: latest) --user, -u Install systemd '--user' service (default: False) --root-directory, -r ROOT_DIRECTORY Specify a specific Periphery root directory. (default: /etc/komodo) --core-address, -c CORE_ADDRESS Specify the Komodo Core address for outbound connection. Leave blank to enable inbound connection server. (default: None) --connect-as, -n CONNECT_AS Specify the Server name to connect as. Defaults to hostname. (default: hostname) --onboarding-key, -k ONBOARDING_KEY Give an onboarding key for automatic Server onboarding into Komodo Core. (default: None) --force-service-file FORCE_SERVICE_FILE Recreate the systemd service file even if it already exists. (default: None) --config-url CONFIG_URL Use a custom config url. (default: https://raw.githubusercontent.com/moghtech/komodo/refs/heads/main/config/periphery.config.toml) --binary-url BINARY_URL Use alternate binary source (default: https://github.com/moghtech/komodo/releases/download) ``` -------------------------------- ### Install Development Tools Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/ecosystem/development.md Updates the Rust toolchain and installs necessary CLI tools for Komodo development. Run this after setting up Rust. ```sh rustup update cargo install typeshare-cli runnables-cli run link-client ``` -------------------------------- ### Start Development Server Source: https://github.com/moghtech/komodo/blob/main/ui/README.md Launches the Vite development server for the UI. ```sh yarn dev ``` -------------------------------- ### Install Komodo CLI Source: https://github.com/moghtech/komodo/blob/main/bin/cli/README.md Install the CLI tool using cargo. Ubuntu users must also install build-essential, pkg-config, and libssl-dev. ```sh cargo install komodo_cli ``` -------------------------------- ### Deploy MongoDB Container Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/setup/mongo.mdx Starts the MongoDB service using the downloaded configuration and environment files. ```bash docker compose -p komodo -f komodo/mongo.compose.yaml --env-file komodo/compose.env up -d ``` -------------------------------- ### Setting Up a Webhook Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/automate/webhooks.md Step-by-step guide on how to configure a webhook in your git provider to send events to Komodo. ```APIDOC ## Setting Up a Webhook 1. **Copy Webhook URL**: Retrieve the specific webhook URL from the resource's Config page in Komodo. 2. **Create Webhook in Git Provider**: Navigate to your git repository's **Settings > Webhooks** and create a new webhook. 3. **Set Payload URL**: Paste the copied Komodo webhook URL into the **Payload URL** field. 4. **Set Content-type**: Configure the **Content-type** to `application/json`. 5. **Set Secret**: Provide your `KOMODO_WEBHOOK_SECRET` in the **Secret** field. 6. **Select Trigger Events**: Choose **Push events** as the trigger for the webhook. ``` -------------------------------- ### Start MongoDB Instance Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/ecosystem/development.md Starts a MongoDB instance in Docker. This command names the container 'komodo-mongo' and maps the default MongoDB port. ```sh docker run -d --name komodo-mongo \ -p 27017:27017 \ -v komodo-mongo-data:/data/db \ -v komodo-mongo-config:/data/configdb \ -e MONGO_INITDB_ROOT_USERNAME=komodo \ -e MONGO_INITDB_ROOT_PASSWORD=komodo \ mongo ``` -------------------------------- ### Start Docusaurus Docs Site Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/ecosystem/development.md Starts the Docusaurus documentation site in development mode. Changes in the `./docsite` directory will trigger automatic reloads. ```sh run dev-docsite ``` -------------------------------- ### Install Komodo CLI on MacOS with Homebrew Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/ecosystem/cli.mdx Installs the Komodo CLI on MacOS by first tapping the Komodo repository and then installing the `km` package. ```bash brew tap moghtech/komodo && \ brew install km ``` -------------------------------- ### Install Komodo Client with npm Source: https://github.com/moghtech/komodo/blob/main/client/core/ts/README.md Install the Komodo client package using npm. This is the first step to using Komodo for software deployment. ```sh npm install komodo_client ``` -------------------------------- ### Create Local Config Directories Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/ecosystem/development.md Creates necessary directories for local configuration files. Ensure these directories exist before proceeding with local setup. ```sh mkdir -p .dev/keys .dev/periphery ``` -------------------------------- ### Install Komodo Periphery Source: https://github.com/moghtech/komodo/blob/main/scripts/readme.md Commands to install the periphery service in system or user mode. ```sh curl -sSL https://raw.githubusercontent.com/moghtech/komodo/main/scripts/setup-periphery.py \ | python3 - --core-address \ --onboarding-key ``` ```sh curl -sSL https://raw.githubusercontent.com/moghtech/komodo/main/scripts/setup-periphery.py \ | python3 - --user --core-address \ --onboarding-key ``` -------------------------------- ### Install Komodo Client with Yarn Source: https://github.com/moghtech/komodo/blob/main/client/core/ts/README.md Install the Komodo client package using Yarn. Choose this method if you prefer Yarn for package management. ```sh yarn add komodo_client ``` -------------------------------- ### Install Komodo CLI on Linux Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/ecosystem/cli.mdx Installs the Komodo CLI system-wide or for the current user using a Python script. Ensure Python 3 is installed. ```bash curl -sSL https://raw.githubusercontent.com/moghtech/komodo/main/scripts/install-cli.py | python3 ``` ```bash curl -sSL https://raw.githubusercontent.com/moghtech/komodo/main/scripts/install-cli.py | python3 - --user ``` -------------------------------- ### Build Configuration with Files on Host Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/build.md Example of configuring a build to use files already present on the builder machine. Set `files_on_host = true` and specify `build_path` and `dockerfile_path`. ```toml [[build]] name = "my-app-from-host" [build.config] builder = "builder-01" files_on_host = true build_path = "/path/to/build/context" dockerfile_path = "Dockerfile.prod" image_registry = [ { domain = "docker.io", account = "my-dockerhub-user" } ] ``` -------------------------------- ### Start Periphery Binary Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/setup/connect-servers.mdx Command to start the Periphery binary directly, specifying the configuration file path. This is useful when not using systemd or Docker. ```sh periphery --config-path /path/to/periphery.config.toml ``` -------------------------------- ### Run Komodo Core Service Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/ecosystem/development.md Starts the Komodo Core service in development mode. This command assumes `runnables-cli` is installed and configured. ```sh run dev-core ``` -------------------------------- ### Install Periphery Agent (User Systemd) Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/setup/connect-servers.mdx Installs the Periphery agent as a systemd user service. Use this for non-root installations. Requires curl and python3. Replace placeholders for core-address, hostname, and onboarding-key. ```bash curl -sSL https://raw.githubusercontent.com/moghtech/komodo/main/scripts/setup-periphery.py \ | python3 - --user \ --core-address="https://" \ --connect-as="$(hostname)" \ --onboarding-key="O-..." ``` -------------------------------- ### Start Komodo with Docker Compose Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/ecosystem/development.md Starts a Komodo container with the UI accessible at localhost:9120. This command should be run after rebuilding with `dev-compose-build`. ```sh run dev-compose-exposed ``` -------------------------------- ### Install Docker on EC2 Instance Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/build.md Commands to update package lists, upgrade existing packages, and install Docker on an Ubuntu-based EC2 instance. Also enables Docker and containerd services. ```sh apt update && apt upgrade -y curl -fsSL https://get.docker.com | sh systemctl enable docker.service containerd.service ``` -------------------------------- ### Configure Docker Container Deployment Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/deploy/containers.md Example TOML configuration for deploying a Docker container with specified image, network, restart policy, environment variables, and volumes. ```toml [[deployment]] name = "my-app" [deployment.config] server = "server-prod" image.type = "Image" image.params.image = "ghcr.io/myorg/my-app:latest" network = "host" restart = "on-failure" environment = """ DB_HOST = db.example.com LOG_LEVEL = info """ volumes = """ /data/my-app/data:/app/data /data/my-app/config:/app/config """ ``` -------------------------------- ### Container Deployment Configuration Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/deploy/containers.md Example TOML configuration for deploying a Docker container using Komodo's Deployment resource. ```APIDOC ## POST /api/deployments ### Description Deploys a Docker container based on the provided configuration. ### Method POST ### Endpoint /api/deployments ### Parameters #### Request Body - **name** (string) - Required - The name of the deployment. - **server** (string) - Required - The server to deploy on. - **image** (object) - Required - Docker image configuration. - **type** (string) - Required - Type of image source ('Image' for custom, 'Build' for Komodo Build). - **params** (object) - Optional - Parameters for the image. - **image** (string) - Required if type is 'Image' - The Docker image string (e.g., 'ghcr.io/myorg/my-app:latest'). - **network** (string) - Optional - Docker network to connect to. Defaults to 'host'. - **restart** (string) - Optional - Restart policy (e.g., 'no', 'on-failure', 'always', 'unless-stopped'). Defaults to 'unless-stopped'. - **environment** (string) - Optional - Environment variables in 'KEY=value' format. - **volumes** (string) - Optional - Bind mounts in 'host_path:container_path' format. - **ports** (array) - Optional - Port mappings (e.g., '27018:27017'). Defaults to []. - **labels** (string) - Optional - Docker labels in 'key=value' format. - **command** (string) - Optional - Override the default image command. - **extra_args** (string) - Optional - Additional flags passed directly to 'docker run'. - **send_alerts** (boolean) - Optional - Send alerts on container state changes. Defaults to true. - **auto_update** (boolean) - Optional - Automatically redeploy when a newer image digest is available. Defaults to false. - **poll_for_updates** (boolean) - Optional - Check for newer images and show an update indicator. Defaults to false. - **links** (array) - Optional - Quick links displayed in the resource header. Defaults to []. ### Request Example ```json { "deployment": [ { "name": "my-app", "config": { "server": "server-prod", "image": { "type": "Image", "params": { "image": "ghcr.io/myorg/my-app:latest" } }, "network": "host", "restart": "on-failure", "environment": "DB_HOST = db.example.com\nLOG_LEVEL = info", "volumes": "/data/my-app/data:/app/data\n/data/my-app/config:/app/config" } } ] } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the deployment status. - **message** (string) - A confirmation message. #### Response Example ```json { "status": "success", "message": "Deployment initiated successfully." } ``` ``` -------------------------------- ### Komodo Core Configuration (TOML) Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/setup/advanced.mdx Example TOML configuration file for Komodo Core. This file can be mounted to `/config/config.toml` in the container. Environment variables take precedence over settings in this file. ```toml # This is a TOML configuration file for Komodo Core. # It can be mounted to /config/config.toml in the Komodo core container. # Environment variables will take precedence over settings in this file. # Example configuration settings: # [server] # port = 9120 # host = "0.0.0.0" # [database] # type = "postgres" # url = "postgres://user:password@host:port/database" # [oidc] # enabled = true # provider = "https://your.oidc.provider/realms/your-realm" # client_id = "your-client-id" # client_secret = "your-client-secret" ``` -------------------------------- ### Install Periphery Agent (Root Systemd) Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/setup/connect-servers.mdx Installs the Periphery agent as a systemd service for root users. Requires curl and python3. Ensure you replace placeholders for core-address, hostname, and onboarding-key. ```bash curl -sSL https://raw.githubusercontent.com/moghtech/komodo/main/scripts/setup-periphery.py \ | python3 - \ --core-address="https://" \ --connect-as="$(hostname)" \ --onboarding-key="O-..." ``` -------------------------------- ### Download FerretDB Configuration Files Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/setup/ferretdb.mdx Use wget to download the FerretDB compose file and environment file to your host machine. Ensure you have wget installed. ```bash wget -P komodo https://raw.githubusercontent.com/moghtech/komodo/main/compose/ferretdb.compose.yaml && \ wget -P komodo https://raw.githubusercontent.com/moghtech/komodo/main/compose/compose.env ``` -------------------------------- ### Configure a Docker Compose Stack Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/deploy/compose.md Example TOML configuration for defining a Docker Compose stack in Komodo, including repository details and environment variables. ```toml [[stack]] name = "my-stack" [stack.config] server = "server-prod" run_directory = "/opt/stacks/my-stack" file_paths = ["compose.yaml"] git_account = "my-user" repo = "myorg/stacks" environment = """ DB_HOST = db.example.com LOG_LEVEL = info """ ``` -------------------------------- ### Clone Git Repository via CLI Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/configuration/providers.md Examples of git clone commands using username/token or token-only authentication. ```shell git clone https://:@// ``` ```shell git clone https://@// ``` -------------------------------- ### Enable Periphery Systemd Service Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/setup/connect-servers.mdx Enables the Periphery systemd service to start automatically on system reboot. This command requires sudo privileges. ```bash sudo systemctl enable periphery ``` -------------------------------- ### Execute a Build using Komodo Client Source: https://github.com/moghtech/komodo/blob/main/client/core/rs/README.md Executes a specific build job on the Komodo Core API. This example demonstrates how to trigger a build named 'test-build'. ```rust let update = client.execute(RunBuild { build: "test-build".to_string() }).await?: ``` -------------------------------- ### Periphery Docker Compose Configuration Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/setup/connect-servers.mdx Example Docker Compose file for deploying the Periphery agent. This file defines the service, image, and necessary configurations for running Periphery in a containerized environment. ```yaml services: periphery: image: ghcr.io/moghtech/komodo-periphery:latest container_name: periphery restart: unless-stopped volumes: - ./periphery.config.yaml:/etc/komodo/periphery.config.yaml ports: - "8120:8120" environment: - KOMODO_CORE_ADDRESS=https:// - KOMODO_CONNECT_AS=$(hostname) - KOMODO_ONBOARDING_KEY=O-... ``` -------------------------------- ### Run Komodo Periphery Service Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/ecosystem/development.md Starts the Komodo Periphery service in development mode. This command assumes `runnables-cli` is installed and configured. ```sh run dev-periphery ``` -------------------------------- ### Run Komodo UI Service Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/ecosystem/development.md Starts the Komodo UI service in development (watch) mode. This command assumes `runnables-cli` is installed and configured. ```sh run dev-ui # Start in dev (watch) mode ``` -------------------------------- ### Initialize and use the TypeScript client Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/ecosystem/api.md Configure the client with API key authentication and execute stack commands. ```ts import { KomodoClient, Types } from "komodo_client"; const komodo = KomodoClient("https://demo.komo.do", { type: "api-key", params: { key: "your_key", secret: "your secret", }, }); // Inferred as Types.StackListItem[] const stacks = await komodo.read("ListStacks", {}); // Inferred as Types.Update const update = await komodo.execute("DeployStack", { stack: stacks[0].name, }); ``` -------------------------------- ### Run Komodo CLI Help Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/ecosystem/cli.mdx Displays help information for the Komodo CLI. ```bash km --help ``` -------------------------------- ### Initialize Komodo Client from Environment Source: https://github.com/moghtech/komodo/blob/main/client/core/rs/README.md Loads environment variables for Komodo API address and credentials, then initializes the Komodo client. Ensure KOMODO_ADDRESS, KOMODO_API_KEY, and KOMODO_API_SECRET are set in your .env file or environment. ```rust dotenvy::dotenv().ok(); let client = KomodoClient::new_from_env()?; ``` -------------------------------- ### Initialize and use the Rust client Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/ecosystem/api.md Connect to the Komodo API using credentials and perform stack operations. ```rust let komodo = KomodoClient::new("https://demo.komo.do", "your_key", "your_secret") .with_healthcheck() .await?; let stacks = komodo.read(ListStacks::default()).await?; let update = komodo .execute(DeployStack { stack: stacks[0].name.clone(), stop_time: None }) .await?; ``` -------------------------------- ### Set up Docker Buildx for Multi-platform Builds Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/build.md Create and configure a Docker Buildx builder for multi-platform image compilation. This command sets up a builder named 'builder' and makes it the default for 'docker build'. ```sh docker buildx create --name builder --use --bootstrap docker buildx install # makes buildx the default for `docker build` ``` -------------------------------- ### Initialize Docker Swarm Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/swarm.md Run this command on a server to initialize a new Docker Swarm cluster. ```bash docker swarm init --advertise-addr ``` -------------------------------- ### Download MongoDB Configuration Files Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/setup/mongo.mdx Fetches the required Docker Compose and environment variable files from the official repository. ```bash wget -P komodo https://raw.githubusercontent.com/moghtech/komodo/main/compose/mongo.compose.yaml && \ wget -P komodo https://raw.githubusercontent.com/moghtech/komodo/main/compose/compose.env ``` -------------------------------- ### Build Static Website Source: https://github.com/moghtech/komodo/blob/main/docsite/README.md Generates static website content into the 'build' directory for hosting. ```bash $ yarn build ``` -------------------------------- ### Configure a Repository Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/automate/sync-resources.md Defines a repository with server, Git provider, account, and repository details. It also includes an 'on_pull' command to execute after the repository is pulled. ```toml [[repo]] name = "komodo-periphery" description = "Builds new versions of the periphery binary. Requires Rust installed on the host." tags = ["komodo"] [repo.config] server = "server-01" git_provider = "git.mogh.tech" # use an alternate git provider (default is github.com) git_account = "mbecker20" repo = "moghtech/komodo" # Run an action after the repo is pulled on_pull.path = "." on_pull.command = """ # Supports comments /root/.cargo/bin/cargo build -p komodo_periphery --release # Multiple lines will be combined together using '&&' cp ./target/release/periphery /root/periphery""" ``` -------------------------------- ### Basic Build Configuration Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/build.md This TOML configuration defines a build named 'my-app' using a specific builder, repository, branch, and Git account. It also specifies the image registry for pushing the built image. ```toml [[build]] name = "my-app" [build.config] builder = "builder-01" repo = "myorg/my-app" branch = "main" git_account = "my-user" image_registry = [ { domain = "ghcr.io", account = "my-user", organization = "my-org" } ] ``` -------------------------------- ### Cron Schedule Examples Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/automate/schedules.md Use cron expressions for precise scheduling when `schedule_format` is set to 'Cron'. Note that seconds are required in the 6-field cron expression. ```text second minute hour day month day-of-week ``` ```text 0 0 3 * * ? ``` ```text 0 */5 * * * ? ``` ```text 0 0 0 1,15 * ? ``` ```text 0 0 9 ? * MON ``` -------------------------------- ### Download Periphery Configuration Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/setup/connect-servers.mdx Use wget to quickly download the default periphery configuration file to your local komodo directory. ```bash wget -P komodo https://raw.githubusercontent.com/moghtech/komodo/main/config/periphery.config.toml ``` -------------------------------- ### Periphery Docker Command Argument Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/setup/connect-servers.mdx Example of how to pass arguments to the Periphery binary when running it within a Docker container using the 'command' directive in Docker Compose. ```yaml command: periphery --config-path /in/container/to/periphery.config.base.toml ``` -------------------------------- ### Download Komodo Configuration File Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/ecosystem/cli.mdx Downloads the default Komodo CLI configuration file to the local directory. ```bash wget -P komodo https://raw.githubusercontent.com/moghtech/komodo/main/config/komodo.cli.toml ``` -------------------------------- ### Build Configuration with Extra Arguments and Buildx Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/build.md Pass additional flags to `docker build` using `extra_args`. Enable `use_buildx = true` to utilize `docker buildx build` for enhanced build capabilities. ```toml [[build]] name = "my-app-buildx" [build.config] builder = "builder-01" repo = "myorg/my-app" branch = "main" use_buildx = true extra_args = ["--platform", "linux/amd64", "--platform", "linux/arm64"] image_registry = [ { domain = "ghcr.io", account = "my-user", organization = "my-org" } ] ``` -------------------------------- ### Declare Builder and Build Resources Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/automate/sync-resources.md Configures a cloud-based builder and a specific build process linked to a repository. ```toml [[builder]] # Declare a builder name = "builder-01" tags = [] config.type = "Aws" [builder.config.params] region = "us-east-2" ami_id = "ami-0e9bd154667944680" # These things come from your specific setup subnet_id = "subnet-xxxxxxxxxxxxxxxxxx" key_pair_name = "xxxxxxxx" assign_public_ip = true use_public_ip = true security_group_ids = [ "sg-xxxxxxxxxxxxxxxxxx", "sg-xxxxxxxxxxxxxxxxxx" ] ## [[build]] name = "test_logger" description = "Logs randomly at INFO, WARN, ERROR levels to test logging setups" tags = ["test"] [build.config] builder = "builder-01" repo = "mbecker20/test_logger" branch = "master" git_account = "mbecker20" image_registry.type = "Standard" image_registry.params.domain = "github.com" # or your custom domain image_registry.params.account = "your_username" image_registry.params.organization = "your_organization" # optional # Set docker labels labels = """ org.opencontainers.image.source = https://github.com/mbecker20/test_logger org.opencontainers.image.description = Logs randomly at INFO, WARN, ERROR levels to test logging setups org.opencontainers.image.licenses = GPL-3.0 """ ``` -------------------------------- ### Enable Systemd User Linger Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/setup/connect-servers.mdx Ensures the Periphery user service stays running after the user logs out. This command is for systemd user installs and requires sudo privileges. ```bash sudo loginctl enable-linger $USER ``` -------------------------------- ### Initialize Komodo Action Variables and Update Build Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/automate/procedures.md Sets up version and branch variables, defines application and architecture lists, and then iterates to update build configurations for each app and architecture combination. ```typescript const VERSION = "1.16.5"; const BRANCH = "dev/" + VERSION; const APPS = ["core", "periphery"]; const ARCHS = ["x86", "aarch64"]; await komodo.write("UpdateVariableValue", { name: "KOMODO_DEV_VERSION", value: VERSION, }); for (const app of APPS) { for (const arch of ARCHS) { const name = `komodo-${app}-${arch}-dev`; await komodo.write("UpdateBuild", { id: name, config: { version: VERSION as any, branch: BRANCH }, }); console.log(`Updated Build ${name}`); } } ``` -------------------------------- ### Configure Database Copy Utility Source: https://github.com/moghtech/komodo/blob/main/bin/cli/docs/copy-database.md Use this configuration in your Docker Compose file to set up the `copy_database` service. It specifies the source and target database URIs and names. Ensure environment variables for credentials and database names are set. ```yaml services: copy_database: image: ghcr.io/moghtech/komodo-cli command: km database copy -y environment: KOMODO_DATABASE_URI: mongodb://${KOMODO_DB_USERNAME}:${KOMODO_DB_PASSWORD}@source:27017 KOMODO_DATABASE_DB_NAME: ${KOMODO_DATABASE_DB_NAME:-komodo} KOMODO_CLI_DATABASE_TARGET_URI: mongodb://${KOMODO_DB_USERNAME}:${KOMODO_DB_PASSWORD}@target:27017 KOMODO_CLI_DATABASE_TARGET_DB_NAME: ${KOMODO_DATABASE_DB_NAME:-komodo} ``` -------------------------------- ### Configure AWS EC2 Builder Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/build.md Define an AWS EC2 instance as a Komodo builder. This configuration specifies region, instance type, AMI, subnet, SSH key, and networking settings. The user_data script installs the Periphery agent. ```toml [[builder]] name = "builder-01" [builder.config] type = "Aws" params.region = "us-east-2" params.instance_type = "c5.2xlarge" params.ami_id = "ami-xxxxxxxxxxxxxxxxxx" params.subnet_id = "subnet-xxxxxxxxxxxxxxxxxx" params.key_pair_name = "ssh-key" params.assign_public_ip = true ## Required for outbound internet access unless you have network gateway. params.use_public_ip = true ## Setting 'false' uses the private IP (when Komodo Core is in same subnet). params.security_group_ids = ["sg-xxxxxxxxxxxxxxxxxx"] params.user_data = """#!/bin/bash curl -sSL \ https://raw.githubusercontent.com/moghtech/komodo/main/scripts/setup-periphery.py | \ HOME=/root python3 - --version=v2.X.X """ ``` -------------------------------- ### Configure a Deployment Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/automate/sync-resources.md Defines a deployment with server, image, and volume configurations. It also includes environment variables and Docker labels. ```toml after = ["test-logger-01"] [deployment.config] server = "server-01" image.type = "Build" image.params.build = "test_logger" volumes = """ /data/logs = /etc/logs /data/config = /etc/config""" environment = """ VARIABLE_1 = value_1 VARIABLE_2 = value_2""" # Set Docker labels labels = "deployment.type = logger" ``` -------------------------------- ### Initialize Komodo Client and Read Data Source: https://github.com/moghtech/komodo/blob/main/client/core/ts/README.md Initialize the Komodo client with your API key and secret, then use it to list all stacks and retrieve details for a specific stack. Ensure you have your API credentials ready. ```typescript import { KomodoClient, Types } from "komodo_client"; const komodo = KomodoClient("https://demo.komo.do", { type: "api-key", params: { key: "your_key", secret: "your secret", }, }); // Inferred as Types.StackListItem[] const stacks = await komodo.read("ListStacks", {}); // Inferred as Types.Stack const stack = await komodo.read("GetStack", { stack: stacks[0].name, }); ``` -------------------------------- ### Force service file recreation Source: https://github.com/moghtech/komodo/blob/main/scripts/readme.md Reinstalls the systemd service file using the default configuration. ```sh curl -sSL https://raw.githubusercontent.com/moghtech/komodo/main/scripts/setup-periphery.py \ | python3 - --core-address \ --onboarding-key \ --force-service-file ``` -------------------------------- ### Declare Deployment Resources Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/automate/sync-resources.md Defines deployment configurations including variables, volume mounts, environment variables, and dependencies. ```toml # Declare variables [[variable]] name = "OTLP_ENDPOINT" value = "http://localhost:4317" ## [[deployment]] # Declare a deployment name = "test-logger-01" description = "test logger deployment 1" tags = ["test"] # sync will deploy the container: # - if it is not running. # - has relevant config updates. # - the attached build has new version. deploy = true [deployment.config] server = "server-01" image.type = "Build" image.params.build = "test_logger" # set the volumes / bind mounts volumes = """ # Supports comments /data/logs = /etc/logs # And other formats (eg yaml list) - "/data/config:/etc/config" """ # Set the environment variables environment = """ # Comments supported OTLP_ENDPOINT = [[OTLP_ENDPOINT]] # interpolate variables into the envs. VARIABLE_1 = value_1 VARIABLE_2 = value_2 """ # Set Docker labels labels = "deployment.type = logger" ## [[deployment]] name = "test-logger-02" description = "test logger deployment 2" tags = ["test"] deploy = true # Create a dependency on test-logger-01. This deployment will only be deployed after test-logger-01 is deployed. ``` -------------------------------- ### Download Komodo Core Configuration File Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/setup/advanced.mdx Download the default Komodo Core configuration file (`core.config.toml`) using `wget`. This file can then be modified and mounted into the Komodo core container. ```bash wget -P komodo https://raw.githubusercontent.com/moghtech/komodo/main/config/core.config.toml ``` -------------------------------- ### Configure Environment Variables Source: https://github.com/moghtech/komodo/blob/main/ui/README.md Defines the Komodo host URL in a local .env.development file. ```text VITE_KOMODO_HOST=https://demo.komo.do ``` -------------------------------- ### Deploy Website (No SSH) Source: https://github.com/moghtech/komodo/blob/main/docsite/README.md Deploys the website without using SSH. Replace '' with your actual username. ```bash $ GIT_USER= yarn deploy ``` -------------------------------- ### Configure Credentials Source: https://github.com/moghtech/komodo/blob/main/bin/cli/README.md Define connection details in a TOML file located at ~/.config/komodo/creds.toml. ```toml url = "https://your.komodo.address" key = "YOUR-API-KEY" secret = "YOUR-API-SECRET" ``` -------------------------------- ### UI Development Environment Variables Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/ecosystem/development.md Sets the Komodo host for the UI in development. This file should be placed in the `ui/` directory. ```env VITE_KOMODO_HOST=http://localhost:9120 ``` -------------------------------- ### Configure a Stack Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/automate/sync-resources.md Defines a stack with deployment details, including server, file paths, Git provider, account, and repository. It can also specify dependencies on other deployments. ```toml [[stack]] name = "test-stack" description = "stack test" deploy = true after = ["test-logger-01"] # Stacks can depend on deployments, and vice versa. tags = ["test"] [stack.config] server = "server-prod" file_paths = ["mongo.yaml", "redis.yaml"] git_provider = "git.mogh.tech" git_account = "mbecker20" # clone private repo by specifying account repo = "mbecker20/stack_test" ``` -------------------------------- ### Dockerfile Sources Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/build.md Details the different methods for providing Dockerfile and build context to Komodo. ```APIDOC ## Dockerfile Sources Komodo supports three ways of providing the Dockerfile and build context: 1. **Write in the UI** — define the Dockerfile contents directly in Komodo. Supports variable and secret interpolation. 2. **Files on host** — point to an existing Dockerfile and build context already present on the builder machine. Set `files_on_host = true` and use `build_path` / `dockerfile_path` to specify the paths. 3. **Git repo** — clone a repository containing the Dockerfile. This is the default mode. Configure `repo`, `branch`, and optionally `git_account` for private repos. ``` -------------------------------- ### Deploy Komodo Stack Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/ecosystem/cli.mdx Deploys a Komodo stack. ```bash km deploy stack my-stack ``` -------------------------------- ### Build Configuration with UI Dockerfile Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/build.md This configuration demonstrates providing Dockerfile contents directly within Komodo using the `dockerfile` field. Supports variable and secret interpolation. ```toml [[build]] name = "my-ui-app" [build.config] builder = "builder-01" dockerfile = "FROM alpine\nRUN echo 'Hello, Komodo!'" image_registry = [ { domain = "ghcr.io", account = "my-user", organization = "my-org" } ] ``` -------------------------------- ### Komodo CLI - Main Commands Source: https://github.com/moghtech/komodo/blob/main/bin/cli/README.md This section details the main commands and global options available for the Komodo CLI. ```APIDOC ## Komodo CLI - Main Commands ### Description Command line tool to execute Komodo actions. ### Usage `komodo [OPTIONS] ` ### Commands - `execute`: Runs an execution. - `help`: Print this message or the help of the given subcommand(s). ### Options - `--creds `: The path to a creds file. (default: `/Users/max/.config/komodo/creds.toml`) - `--url `: Pass url in args instead of creds file. - `--key `: Pass api key in args instead of creds file. - `--secret `: Pass api secret in args instead of creds file. - `-y, --yes`: Always continue on user confirmation prompts. - `-h, --help`: Print help (see more with '--help'). - `-V, --version`: Print version. ``` -------------------------------- ### Deploy Website (SSH) Source: https://github.com/moghtech/komodo/blob/main/docsite/README.md Deploys the website using SSH. This command builds the site and pushes to the 'gh-pages' branch. ```bash $ USE_SSH=true yarn deploy ``` -------------------------------- ### Configure Git Providers in TOML Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/configuration/providers.md Define git provider domains and associated user accounts in core or periphery configuration files. ```toml # in core.config.toml or periphery.config.toml [[git_provider]] domain = "github.com" accounts = [ { username = "my-user", token = "ghp_xxxxxxxxxxxx" }, ] [[git_provider]] domain = "git.example.com" # self-hosted Gitea, GitLab, etc. accounts = [ { username = "my-user", token = "access_token" }, ] [[git_provider]] domain = "localhost:3000" https = false # clone over http:// accounts = [ { username = "my-user", token = "access_token" }, ] ``` -------------------------------- ### Declare a Server Resource Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/automate/sync-resources.md Defines a server configuration including address, region, and enabled status. ```toml [[server]] # Declare a new server name = "server-prod" description = "the prod server" tags = ["prod"] [server.config] address = "http://localhost:8120" region = "AshburnDc1" enabled = true # default: false ``` -------------------------------- ### Configure a Procedure Stage with Deployments Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/automate/sync-resources.md Defines a stage within a procedure for deploying services. It allows specifying deployments and optionally disabling them. ```toml [[procedure.config.stage]] name = "Deploy test logger 1" executions = [ { execution.type = "Deploy", execution.params.deployment = "test-logger-01" }, { execution.type = "Deploy", execution.params.deployment = "test-logger-03", enabled = false }, ] ``` ```toml [[procedure.config.stage]] name = "Deploy test logger 2" enabled = false executions = [ { execution.type = "Deploy", execution.params.deployment = "test-logger-02" } ] ``` -------------------------------- ### Read Deployments using Komodo Client Source: https://github.com/moghtech/komodo/blob/main/client/core/rs/README.md Fetches all deployments from the Komodo Core API using the initialized client. This operation requires the client to be successfully created. ```rust // Get all the deployments let deployments = client.read(ListDeployments::default()).await?; println!("{deployments:#?}"); ``` -------------------------------- ### Komodo CLI Configuration File Detection Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/ecosystem/cli.mdx Demonstrates how the Komodo CLI detects and merges configuration files from the current directory and the user's home directory. Configuration files matching `*komodo.cli*.*` are parsed and merged, with later files overriding earlier ones. ```bash km -c /path/to/1/base.config.yaml -c ./overrides ... ``` -------------------------------- ### Run Executions Source: https://github.com/moghtech/komodo/blob/main/bin/cli/README.md Trigger a specific build process using the execute command. ```sh # Triggers an example build komodo execute run-build test_build ``` -------------------------------- ### SSH / Connect Command Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/ecosystem/cli.mdx Opens an interactive shell on a server managed by Komodo Periphery. ```APIDOC ## km ssh / km connect ### Description Opens an interactive shell on a server managed by Komodo Periphery. Analogous to ssh. ### Parameters #### Path Parameters - **server** (string) - Required - Server name - **command** (string) - Optional - Shell command to start (defaults to Periphery default) #### Options - **-n, --name** (string) - Optional - Terminal session name (default: ssh) - **-r, --recreate** (boolean) - Optional - Force a fresh terminal, replacing any existing session with the same name ``` -------------------------------- ### Attach Command Source: https://github.com/moghtech/komodo/blob/main/docsite/docs/ecosystem/cli.mdx Attaches to a running container's main process stdio. ```APIDOC ## km attach ### Description Attaches to a running container's main process stdio. Analogous to docker attach. ### Parameters #### Path Parameters - **container** (string) - Required - Container name #### Options - **-s, --server** (string) - Optional - Server name (required if multiple servers have a container with the same name) - **-r, --recreate** (boolean) - Optional - Force a fresh terminal, replacing any existing session ```