|
| 1 | +# Plugins guide |
| 2 | + |
| 3 | +Exoframe allows extending the core functionality of Exoframe-Server using third party plugins. |
| 4 | +This guide aims to explain basics you need to know to create your own plugins. |
| 5 | +If you are looking for plugins usage - please see [Advanced](Advanced.md) part of the docs. |
| 6 | + |
| 7 | +## Basics |
| 8 | + |
| 9 | +Exoframe uses [yarn](https://yarnpkg.com/) to install and remove third-party plugins. |
| 10 | +The plugins then are added to Exoframe-Server using Node.js `require()` method. |
| 11 | +So, make sure that your plugin's `package.json` has correct `main` attribute. |
| 12 | + |
| 13 | +Your plugins main script needs to export the following variables and methods: |
| 14 | + |
| 15 | +```js |
| 16 | +module.exports = { |
| 17 | + // plugin default config |
| 18 | + config: { |
| 19 | + // plugin name |
| 20 | + name: 'exoframe-plugin-swarm', |
| 21 | + // whether plugin requires exclusive hooks to exoframe methods |
| 22 | + // exclusive hooks are the only ones being executed |
| 23 | + // make sure you only run ONE exclusive plugin at a time |
| 24 | + exclusive: true, |
| 25 | + }, |
| 26 | + |
| 27 | + /* plugin functions that hook into Exoframe-Server methods */ |
| 28 | + // server init function hook |
| 29 | + // should initialize traefik, setup networks, etc |
| 30 | + init, |
| 31 | + // exoframe start function hook |
| 32 | + // should start a deployment from files |
| 33 | + start, |
| 34 | + // exoframe startFromParams function hook |
| 35 | + // should start a deployment from given set of params |
| 36 | + startFromParams, |
| 37 | + // exoframe list function hook |
| 38 | + // should list currently active deployments |
| 39 | + list, |
| 40 | + // exoframe logs function hook |
| 41 | + // should get logs for a given deployment |
| 42 | + logs, |
| 43 | + // exoframe remove function hook |
| 44 | + // should remove a given deployment |
| 45 | + remove, |
| 46 | + // exoframe compose template extension |
| 47 | + // can affect how docker-compose template is executed |
| 48 | + compose, |
| 49 | +}; |
| 50 | +``` |
| 51 | + |
| 52 | +## Examples |
| 53 | + |
| 54 | +- [Swarm plugin](https://github.com/exoframejs/exoframe-plugin-swarm) |
0 commit comments