Repository Templates

Repository Templates can be used to automatically create files, run scripts and setup environment variables when creating a repository in Komander.

Folder structure

Here's an example:

.
└── repository-templates/
    ├── angular/
    │   ├── templates/
    │   │   ├── .gitignore.txt.hbs
    │   │   ├── .gitlab-ci.yml.hbs
    │   │   ├── Dockerfile.txt.hbs
    │   │   └── README.md.hbs
    │   └── spec.json
    └── rust-app/
        ├── templates/
        │   ├── .dockerignore.txt.hbs
        │   ├── .gitignore.txt.hbs
        │   ├── .gitlab-ci.yml.hbs
        │   ├── .Dockerfile.txt.hbs
        │   └── README.md.hbs
        └── spec.json

What's important is that each Repository Template:

  • Is in its own sub-folder
  • Has a spec.json file in it (see the specification)
  • Has its template files under a templates folder and has Handlebars template files

Specification

The spec.json file follows this schema:

{
  "name": "Name as seen by the user",
  "init_commands": [],
  "template_files": [
    {
      "name": ".dockerignore",
      "extension": ""
    },
    {
      "name": "README",
      "extension": "md"
    }
  ],
  "app_ports": [
    80
  ],
  "app_volumes": [
    "/code"
  ],
  "app_scripts": [
    {
      "name": "start",
      "commands": [
        "ng serve --port 80 --host 0.0.0.0"
      ]
    }
  ]
}
  • name:
  • init_commands: A list of commands that will be run sequentially, only when creating a repository
  • template_files: A list of template file names and their extension. Should match what is found under the templates/ folder
  • app_ports: A list of port numbers that the app needs to be exposed
  • app_volumes: A list of volumes that should be exposed.
  • app_scripts: A list of named scripts that can be run using Komander CLI (with komander run ...). Commands run in parallel.

Template files

A few variables are automatically passed to the template engine:

  • context.repository_name: The full name of the repository in Komander
  • context.repository_identifier: The sanitized name of the repository