ghostmgr

Ghostmgr is a CLI tool to run and manage Ghost instances, in the production, on the Docker container system. It uses Docker API to create containers, configurations, and networks.
Running Ghost on services like Kubernetes can be overkill for starters. Instead, a cheap virtual machine can be a perfect choice for independent writers who are just starting and want to host the platform by themselves. Drawback for the ghost-cli is that it doesn't work well with Docker containers. Ghostmgr is a solution for container hosted Ghost instances.
Features:
- Host your Ghost instance on a Virtual machine with low resources
- Run and manage Ghost, Nginx, and MySQL database
- Externalized configuration using YAML files
- Upgrade to the newest Ghost docker image with cli
GitHub - qdnqn/ghostmgr: Ghostmgr is a CLI tool for running and managing Ghost instance on the Docker container ecosystem.
Ghostmgr is a CLI tool for running and managing Ghost instance on the Docker container ecosystem. - GitHub - qdnqn/ghostmgr: Ghostmgr is a CLI tool for running and managing Ghost instance on the Do…
How to install?
$ git clone https://github.com/qdnqn/ghostmgr.git
$ cd ghostmgr
$ go build main.go -o ghostmgr
$ EXPORT PATH=$PATH:$(pwd)ghostmgr
$ ghostmgr --help
Usage of ./ghostmgr:
--config string Name of config file without extension in config dir (default "development")
--destroy Destroy project
--down Clear all ghost, mysql and nginx containers
--info Display selected config
--init Init project
--project string Name of the current project (default "ghostmgr")
--scale-ghost Automatic creation of new instances of ghost (1,2,3,...,N)
--scale-mysql Automatic creation of new instances of mysql (1,2,3,...,N)
--scale-nginx Automatic creation of new instances of nginx (1,2,3,...,N)
--up Setup ghost, mysql and nginx
--upgrade Upgrade ghost image - Zero downtime
--watch Watch the running containers
Usage
ghostmgr --init --project test
Mysql password: [Enter password for the database]
$ tree $HOME/ghostmgr/test
$HOME/ghostmgr/test
├── config
│ ├── development.yaml
│ └── production.yaml
├── exports
├── resources
│ ├── ghost
│ ├── mysql
│ └── nginx
└── templates
├── ghost
│ ├── development.conf
│ └── production.conf
├── mysql
└── nginx
├── development.conf
└── production.conf
$ ghostmgr --up --project test --config development
{"level":"info","ts":1684831305.428744,"caller":"container/Image.go:27","msg":"Image mysql:8.0 already present"}
{"level":"info","ts":1684831306.7891543,"caller":"manager/UpDown.go:35","msg":"Waiting mysql to be ready..."}
{"level":"info","ts":1684831311.8251882,"caller":"manager/UpDown.go:35","msg":"Waiting mysql to be ready..."}
{"level":"info","ts":1684831316.8862782,"caller":"manager/UpDown.go:35","msg":"Waiting mysql to be ready..."}
{"level":"info","ts":1684831321.9308426,"caller":"manager/UpDown.go:35","msg":"Waiting mysql to be ready..."}
{"level":"info","ts":1684831326.9802113,"caller":"manager/UpDown.go:35","msg":"Waiting mysql to be ready..."}
{"level":"info","ts":1684831332.027674,"caller":"manager/UpDown.go:35","msg":"Waiting mysql to be ready..."}
{"level":"info","ts":1684831337.0656948,"caller":"manager/UpDown.go:35","msg":"Waiting mysql to be ready..."}
{"level":"info","ts":1684831342.082538,"caller":"manager/UpDown.go:40","msg":"======> Mysql is up."}
{"level":"info","ts":1684831342.1064978,"caller":"manager/UpDown.go:46","msg":"======> Mysql Ghost database created."}
{"level":"info","ts":1684831342.1815698,"caller":"container/Image.go:27","msg":"Image ghost:5.30 already present"}
{"level":"info","ts":1684831342.6321816,"caller":"manager/UpDown.go:81","msg":"Waiting ghost to be ready..."}
{"level":"info","ts":1684831347.6457758,"caller":"manager/Readiness.go:60","msg":"Ghost responded to the request","HTTP":503}
{"level":"info","ts":1684831347.6525822,"caller":"manager/UpDown.go:81","msg":"Waiting ghost to be ready..."}
{"level":"info","ts":1684831352.657843,"caller":"manager/Readiness.go:60","msg":"Ghost responded to the request","HTTP":503}
{"level":"info","ts":1684831352.6684535,"caller":"manager/UpDown.go:81","msg":"Waiting ghost to be ready..."}
{"level":"info","ts":1684831357.6719375,"caller":"manager/Readiness.go:60","msg":"Ghost responded to the request","HTTP":503}
{"level":"info","ts":1684831357.6822052,"caller":"manager/UpDown.go:81","msg":"Waiting ghost to be ready..."}
{"level":"info","ts":1684831362.6856215,"caller":"manager/Readiness.go:60","msg":"Ghost responded to the request","HTTP":503}
{"level":"info","ts":1684831362.6974134,"caller":"manager/UpDown.go:81","msg":"Waiting ghost to be ready..."}
{"level":"info","ts":1684831367.7005959,"caller":"manager/Readiness.go:60","msg":"Ghost responded to the request","HTTP":503}
{"level":"info","ts":1684831367.7123656,"caller":"manager/UpDown.go:81","msg":"Waiting ghost to be ready..."}
{"level":"info","ts":1684831372.9150882,"caller":"manager/Readiness.go:60","msg":"Ghost responded to the request","HTTP":200}
{"level":"info","ts":1684831372.9151156,"caller":"manager/UpDown.go:86","msg":"======> Ghost is up."}
{"level":"info","ts":1684831372.9843576,"caller":"container/Image.go:27","msg":"Image nginx:1.23.1 already present"}
{"level":"info","ts":1684831373.3927085,"caller":"manager/UpDown.go:117","msg":"Waiting nginx to be ready..."}
{"level":"info","ts":1684831378.3994792,"caller":"manager/UpDown.go:122","msg":"======> Nginx is up."}
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4ef11ea143b3 nginx:1.23.1 "/docker-entrypoint.…" About a minute ago Up About a minute 0.0.0.0:8080->80/tcp test-nginx-0
d93b2cea8cfb ghost:5.30 "docker-entrypoint.s…" About a minute ago Up About a minute 2368/tcp test-ghost-0
c2629a38b5f9 mysql:8.0 "docker-entrypoint.s…" 2 minutes ago Up 2 minutes 3306/tcp, 33060/tcp test-mysql-0
Upgrade
$ ghostmgr --upgrade --project test --config development
Please provide ghost docker tag (eg 5.30.1): 5.46.0 [User input required]
{"level":"info","ts":1684831630.0210931,"caller":"manager/Init.go:116","msg":"Creating directory.","Directory":"/home/adnanse/ghostmgr/test/upgrade/ghost/2023-05-23 10:47:07.074100957 +0200 CEST m=+0.000022705"}
{"level":"info","ts":1684831630.0646343,"caller":"manager/Mysql.go:45","msg":"Exporting database","database":"test_ghost_0"}
{"level":"info","ts":1684831630.090786,"caller":"manager/Mysql.go:65","msg":"Database exported","database":"test_ghost_0"}
{"level":"info","ts":1684831630.090895,"caller":"manager/Mysql.go:71","msg":"Importing old database to the new database","database":"test_ghost_1"}
{"level":"info","ts":1684831640.1987963,"caller":"manager/Mysql.go:88","msg":"Importing of the database done!","database":"test_ghost_1"}
{"level":"info","ts":1684831640.240417,"caller":"container/Image.go:27","msg":"Image ghost:5.46.0 already present"}
{"level":"info","ts":1684831640.7154047,"caller":"manager/UpDown.go:81","msg":"Waiting ghost to be ready..."}
{"level":"info","ts":1684831645.7293334,"caller":"manager/Readiness.go:60","msg":"Ghost responded to the request","HTTP":503}
{"level":"info","ts":1684831645.7358408,"caller":"manager/UpDown.go:81","msg":"Waiting ghost to be ready..."}
{"level":"info","ts":1684831650.9120204,"caller":"manager/Readiness.go:60","msg":"Ghost responded to the request","HTTP":200}
{"level":"info","ts":1684831650.9120467,"caller":"manager/UpDown.go:86","msg":"======> Ghost is up."}
{"level":"info","ts":1684831651.376947,"caller":"container/Image.go:27","msg":"Image nginx:1.23.1 already present"}
{"level":"info","ts":1684831651.7955503,"caller":"manager/UpDown.go:117","msg":"Waiting nginx to be ready..."}
{"level":"info","ts":1684831656.8091395,"caller":"manager/UpDown.go:122","msg":"======> Nginx is up."}
See more
GitHub - qdnqn/ghostmgr: Ghostmgr is a CLI tool for running and managing Ghost instance on the Docker container ecosystem.
Ghostmgr is a CLI tool for running and managing Ghost instance on the Docker container ecosystem. - GitHub - qdnqn/ghostmgr: Ghostmgr is a CLI tool for running and managing Ghost instance on the Do…