https://github.com/hadialqattan/go-compose
A lightweight services composer written in Golang for managing services (processes) in a development environment.
https://github.com/hadialqattan/go-compose
cli compose docker-compose go golang goroutines process-management
Last synced: about 2 months ago
JSON representation
A lightweight services composer written in Golang for managing services (processes) in a development environment.
- Host: GitHub
- URL: https://github.com/hadialqattan/go-compose
- Owner: hadialqattan
- License: mit
- Created: 2020-10-16T15:09:48.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2020-10-28T16:18:18.000Z (over 5 years ago)
- Last Synced: 2025-08-25T08:13:53.989Z (9 months ago)
- Topics: cli, compose, docker-compose, go, golang, goroutines, process-management
- Language: Go
- Homepage:
- Size: 141 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Go Compose
A lightweight services composer written in Golang for managing services (processes) in a development environment.
***
## Installation
```bash
$ go get github.com/hadialqattan/go-compose
```
## Usage
```bash
$ go-compose start # --config path/to/go-compose.yaml [default=./go-compose.yaml].
```
## `go-compose.yaml`
```yaml
services:
service_name:
ignore_failures: false
sub_service: false
auto_restart: true
hooks:
wait:
- another_service_name
stop:
- another_service_name
start:
- another_service_name
cwd: .
command: echo "shell script"
environs:
ENVIRONMENT_VARIABLE: true
```
* `services`: a set of services to run.
* `ignore_failures`: don't stop other services when this failed.
* `sub_service`: don't start this service. this may be started by another service using the `start hook`.
* `auto_restart`: automatically restart this service if it crashed.
* `hooks`:
+ `wait`: wait for other services to stop before starting (setup).
+ `stop`: stop other services on exit (teardown).
+ `start`: start other services/sub-services on exit (teardown).
* `cwd`: where the command will be executed (Command Work Directory).
* `command`: a unix shell command.
* `environs`: environment variables.
A real world example
```yaml
services:
webapp:
ignore_failures: true
auto_restart: true
hooks:
start:
- cleanup
cwd: .
command: |
docker build .
docker run --rm \
--name webapp \
--link db \
-v ${PWD}:/webapp -w /webapp webapp
environs:
- POSTGRES_USER=webapp_admin
- POSTGRES_PASSWORD=db0123
- POSTGRES_DB=db
postgres_db:
ignore_failures: true
auto_restart: true
cwd: .
command: |
sleep 3
docker run --rm \
--name db postgres:12.0-alpine
environs:
- POSTGRES_USER=webapp_admin
- POSTGRES_PASSWORD=db0123
- POSTGRES_DB=db
cleanup:
sub_service: true
cwd: .
command: python3 teardown.py
```
***
## Copyright ©
👤 **Hadi Alqattan**
* Github: [@hadialqattan](https://github.com/hadialqattan)
* Email: [alqattanhadizaki@gmail.com]()
📝 **License**
Copyright © 2020 [Hadi Alqattan](https://github.com/hadialqattan).
This project is [MIT](https://github.com/hadialqattan/go-compose/blob/master/LICENSE) licensed.
***
Give a ⭐️ if this project helped you!