Create a service¶
Register a new service in a product and get its working folders in both repositories. A service (called a neuron in resource names) is one deployable unit of a product: one contract, one or more images, one Terraform module.
Prerequisites¶
- Builder access to the product.
- The product's repositories cloned with
alis clone <org>.<product>. - A package id for the service:
<org>.<product>.<path>.<vN>, for exampleacme.sh.orders.v1. The path may have several segments, such asacme.sh.internal.api.v2.
Steps¶
-
Register the service.
The result names the service and the folders it created:
{ "packageId": "acme.sh.orders.v1", "name": "organisations/acme/products/sh/neurons/orders-v1", "serviceId": "orders-v1", "created": true, "buildFolder": "/Users/you/alis.build/acme/build/sh/orders/v1", "defineFolder": "/Users/you/alis.build/acme/define/acme/sh/orders/v1", "next": ["..."] }Folders are created only in the repositories already on disk:
orders/v1plusorders/v1/infrain the build repo, andacme/sh/orders/v1in the definitions repo. No files are generated. -
Write the contract in the define folder and publish it. See Define your API.
- Write the implementation, a Dockerfile and
infra/in the build folder. See Write a Dockerfile for your service and Write infrastructure with Terraform. - Commit and push, then build and deploy. See Build a version.
- Open the product and go to Services.
- Choose Add neuron and enter the identifier without its version, for example
orders; the console adds the version and shows the neuron it will create,orders-v1. - Run
alis clone acme.shon your machine, then create the folders yourself:orders/v1andorders/v1/infrain the build repo, andacme/sh/orders/v1in the definitions repo.
Naming¶
| Part | Rule | Example |
|---|---|---|
| Build environment id | 3 to 21 lowercase letters or digits, starting with a letter | acme |
| Product id | two lowercase characters | sh |
| Service path | one or more lowercase segments | orders, internal.api |
| Version | v followed by a number |
v1, v2 |
| Service id | the path with / replaced by -, plus the version |
orders-v1, internal-api-v2 |