Set up and use configuration projects
Last updated
Was this helpful?
Last updated
Was this helpful?
Aidbox Configuration project requires a few things:
, which wraps all the necessary files required for a project package to function.
, which lists project’s dependencies.
, which points to settings and services for an instance under configuration.
Configuration projects, which are also zen projects, work as git repositories under the hood. This means that you need to have a directory initialized as a git repo. You can either create it from scratch or clone an existing one.
You can also bootstrap a project with the help of tool:
Then you need to set BOX_PROJECT_GIT_URL
environment variable to the location of this repository so that Aidbox knows where to find it. Note that the location can be either a local path or a remote URL, for which you can optionally specify a commit and/or branch.
See an example of an .
Aidbox can load project from an URL or read directly from its file system.
BOX_PROJECT_GIT_URL
— where to clone your project from. Aidbox substitutes it to git clone <url>
command.
BOX_PROJECT_GIT_PROTOCOL
— either https
or ssh
. Assumes local dir if omitted.
BOX_PROJEC_GIT_TARGET__PATH
— where to clone your project to and where to read it from. Default value is a directory in /tmp
If a repository you want to use as a project is under restricted access, you can provide the necessary SSH or HTTPS credentials via the following environment variables:
BOX_PROJECT_GIT_ACCESS__TOKEN
— access token for HTTPS
BOX_PROJECT_GIT_PUBLIC__KEY
— SSH public key
BOX_PROJECT_GIT_PRIVATE__KEY
— SSH private key
Project’s package file, zen-package.edn
, should be located at the root of a configuration project. It is used to specify what dependencies, which are other zen projects, you wish to use.
If you don’t have any dependencies, the file should look like this:
Aidbox starts reading configuration project from a zen entrypoint. It is a namespaced symbol which is tagged with aidbox/system
tag. It is used to bootstrap the whole system.
You can specify an entrypoint symbol via AIDBOX_ZEN_ENTRYPOINT
environment variable.
The entrypoint file should import all the packages and other namespaces you wish to use.
Its ns
value should correspond to its filename (with -
replaced by _
).
You need to specify AIDBOX_ZEN_ENTRYPOINT
environment variable. This variable is formatted as <entrypoint namespace>/<entrypoint symbol name>
. Given entry file such as above, you get the following:
Aidbox Configuration project is a git repository. You need to commit all the changes you’ve made otherwise Aidbox won’t see them.
Suppose that you’ve configured your Aidbox instance with some heavy dependencies. During the development phase, you may wish to reuse these dependencies downloaded data. BOX_PROJECT_GIT_TARGET__PATH
environment variable allows you to specify a path where your project with downloaded dependencies are going to be cached. By mounting this path to a persistent file system you'll provide downloaded data to Aidbox after a restart, thus making Aidbox reusing data (Aidbox also checks for dependencies updates in this case).
If you want to cache dependencies for Aidbox Docker container, you need to mount a cache directory as a volume.
By default, Aidbox requires a restart after making changes to a configuration project. If you wish to enable a hot reload, set the following environment variable:
You can also use Aidbox UI to reload namespaces: proceed to Profiles
page on the left sidebar and click the reload button in the upper left corner.
This tip is the same as for development.
Execute the following command inside the project directory to create a zip file with your project:
It will be available inside the target
directory in the root of the project.
Now all you need is to set AIDBOX_ZEN_PATHS
environment variable. There are two ways to do it:
It is also possible to provide an unpacked zip of your project:
Since configuration projects are just git repositories you can publish them in any git registry and other people will be able to use them for their own configurations: either as a standalone project or as a dependency.
If you specify only the target path then Aidbox expects you to clone a project into this location before it starts. This allows mounting persistent file system cache and using local file system for development. See and .
See also an .
You can .
As an example, consider the following config file for a system which happens to import :
It's more preferable to set up Aidbox with . You may provide it with aidbox/system
See an .
Additionally, there’s RPC method that does the same thing.
If you are using VS Code, we have plugin which should help you write configs with less errors.
In production you may not always have an access to a git repository with your project. It can also be convenient to bundle the project together with all its dependencies. You can use our tool to address both of these concerns.
If your repository is available only under a restricted access, others will need to .