|
1 |
| -# s6-cli: A cli for s6-overlay |
2 |
| -This cli tool can be used to help you setup your projects s6-overlay files and directories |
| 1 | +# s6-cli: CLI for s6-overlay |
| 2 | +This cli tool can be used to help you setup your projects s6-overlay files and directories. It can also be used to create, remove and lint services. |
| 3 | + |
| 4 | +## s6-overlay |
| 5 | +> s6-overlay is an easy-to-install (just extract a tarball or two!) set of scripts and utilities allowing you to use existing Docker images while using s6 as a pid 1 for your container and process supervisor for your services. |
| 6 | +To know more about s6-overlay visit [github.com/just-containers/s6-overlay](https://github.com/just-containers/s6-overlay). |
| 7 | + |
| 8 | + |
| 9 | +## Setup |
| 10 | + |
| 11 | +```bash |
| 12 | +git clone [email protected]:dazz/s6-cli.git |
| 13 | +cd s6-cli |
| 14 | +make help |
| 15 | +``` |
| 16 | + |
| 17 | +There is a Makefile that you can use to execute helpful commands. Following is a small list for some more important targets. |
| 18 | +Run `make` or `make help` to see all possible targets. |
| 19 | + |
| 20 | +## Build |
| 21 | + There are a few options here how you can install the executable on the target system. |
| 22 | + |
| 23 | +### Go |
| 24 | +Builds the executable and places it in the current directory |
| 25 | +```bash |
| 26 | +make build |
| 27 | +``` |
| 28 | + |
| 29 | +### Nix shell |
| 30 | +If you have nix-shell you can run the following command to get a shell with the cli installed |
| 31 | +```bash |
| 32 | +make nix |
| 33 | +``` |
| 34 | + |
| 35 | +### Docker |
| 36 | +Creates a docker image with the cli installed |
| 37 | +```bash |
| 38 | +make docker |
| 39 | +``` |
| 40 | + |
| 41 | +### In Dockerfile |
| 42 | +If you want to use the cli in a Dockerfile you can copy it from the docker image |
| 43 | +```dockerfile |
| 44 | +COPY --from=hakindazz/s6-cli:latest /app/s6-cli /usr/local/bin/s6-cli |
| 45 | +``` |
| 46 | + |
| 47 | +## Usage |
| 48 | + |
| 49 | +There is a help command that you can use to get more info about the commands in the cli. Run it with |
| 50 | +```bash |
| 51 | +./s6-cli help |
| 52 | +``` |
| 53 | +### The option `--rootPath {path}, -p {path}` |
| 54 | +All commands need the `rootPath` to be specified. It must point to the directory where services will be defined. |
| 55 | +Default is set to `/etc/s6-overlay/s6-rc.d` |
| 56 | + |
| 57 | +### Create |
| 58 | +There are three types of services that can be created: Oneshot, Longrun and Background. |
| 59 | +Read more about them [here](https://skarnet.org/software/s6-rc/s6-rc-compile.html) |
| 60 | + |
| 61 | +```bash |
| 62 | +./s6-cli --rootPath {path} create {o|l|b} {service} |
| 63 | +``` |
| 64 | + |
| 65 | +### Remove |
| 66 | +If the service is not needed anymore it can be removed with the following command. |
| 67 | + |
| 68 | +```bash |
| 69 | +./s6-cli remove {service} |
| 70 | +``` |
| 71 | + |
| 72 | +### Lint |
| 73 | + |
| 74 | +```bash |
| 75 | +./s6-cli lint |
| 76 | +``` |
| 77 | + |
| 78 | + |
| 79 | + |
| 80 | +### Mermaid |
| 81 | +This command will generate a mermaid graph of the services. |
| 82 | + |
| 83 | +```bash |
| 84 | +./s6-cli mermaid > mermaid.md |
| 85 | +``` |
| 86 | + |
| 87 | +Or pipe it directly to a markdown file |
| 88 | +```bash |
| 89 | +./s6-cli mermaid > mermaid.md |
| 90 | +``` |
| 91 | + |
| 92 | +The output will look something like this: |
| 93 | +```bash |
| 94 | +```mermaid |
| 95 | +graph TD; |
| 96 | + user --> prepare-directory |
| 97 | + user --> nginx |
| 98 | + nginx --> php-fpm |
| 99 | + php-fpm --> create-directories |
| 100 | +``` |
| 101 | + |
| 102 | +which will be rendered to this: |
| 103 | + |
| 104 | +```mermaid |
| 105 | +graph TD; |
| 106 | + user --> prepare-directory |
| 107 | + user --> nginx |
| 108 | + nginx --> php-fpm |
| 109 | + php-fpm --> create-directories |
| 110 | +``` |
| 111 | + |
3 | 112 |
|
4 | 113 | ## todo
|
5 |
| -* [ ] write tests with https://github.com/stretchr/testify |
6 |
| -* [ ] find pattern for testcase names |
7 |
| -* [ ] add `s6-cli update` command |
8 |
| -* [ ] add `s6-cli init` command |
9 |
| -* [ ] style output with color https://github.com/charmbracelet/glamour |
| 114 | +* create dependencies between services |
| 115 | +* add `s6-cli update` command |
| 116 | +* add `s6-cli init` command |
| 117 | +* add `s6-cli ci` command |
| 118 | +* style output with color https://github.com/charmbracelet/glamour |
| 119 | +* tui with https://github.com/charmbracelet/bubbletea |
0 commit comments