Govinor
A platform for creating and managing Docker containers that integrates with Github to offer branch preview links.
Note: This is a work in progress. The current focus is to deploy Strapi containers.
How does it work?
Govinor listens to Github webhooks of a repo of your choice and creates and manages Docker containers with preview links.
Development
From your terminal:
npm run dev
This starts your app in development mode, rebuilding assets on file changes.
⚠️ Note: Govinor carries out a lot of work using shell commands that won't probably work on your local machine. The target OS is Ubuntu 20.04. These functionalities needs to be mocked in order to be tested locally, so for now dev mode is only meant for testing UI changes to the Govinor dashboard.
Deployment
If you need to setup a new server read the instructions below on "Setup AWS resources" and "Install Govinor on the server".
When you need to deploy a new version of govinor, run the following commands:
cd ~/govinor;
git pull;
npm install;
npm run build;
npm run deploy;
Setup AWS resources
First, create an AWS account and create an IAM user with these permissions:
AmazonEC2FullAccess
AmazonRDSFullAccess
AmazonS3FullAccess
Launch an EC2 instance
- Choose AMI:
Ubuntu Server 20.04 LTS (x86)
- Choose instance type:
t3.medium
- Configure instance: -
- Add Storage: Select 50GB
- Add tags: -
- Configure security groups: Create a new group named
govinor
with descriptiongovinor instance security settings
and add the following rules:
- Type:
SSH
, Protocol:TCP
, Port:22
, Source:0.0.0.0/0
- Type:
SSH
, Protocol:TCP
, Port:22
, Source:::/0
- Type:
HTTP
, Protocol:TCP
, Port:80
, Source:0.0.0.0/0, ::/0
- Type:
HTTPS
, Protocol:TCP
, Port:443
, Source:0.0.0.0/0, ::/0
Finally hit "Launch" and create a new key pair (e.g. govinor-key-pair
) and save it to your computer.
Install Docker
Follow the instructions on How To Install and Use Docker on Ubuntu 20.04 to install Docker for Ubuntu 20.04.
⚠️ Important: Make sure to follow Step 2 to enable docker execution without the sudo command
Install Docker Compose
Follow the instructions "Install on Linux" to install Docker Compose.
Install Caddy Server
Follow the instructions for "Ubuntu" to install Caddy.
Install Node.js
To make it easier to manage and upgrade Node versions, we recommend using Node Version Manager.
To install Node.js, run the following command:
nvm install 14
Install govinor on the server
Prerequisites
You need to have a Github webhook configured for the repo you want to deploy. Head to your repo settings and add a webhook that points to the following settings:
- Payload URL: https://govinor.com/github/webhook
- Content type:
application/json
Select also "Send me everything".
Install
To install govinor, you need to SSH into your EC2 instance and run the following commands:
- Create deployment folder:
mkdir -p ~/deployments
- Clone this repo
- cd into the repo:
cd govinor
- Add .env file
cp .env.example .env
and - Edit .env: change
ADMIN_USERNAME
,ADMIN_PASSWORD
and setGITHUB_WEBHOOK_SECRET
- Install dependencies:
npm install
- Build app:
npm run build
- Create systemd service:
sudo cp -i ~/govinor/service/govinor.service /etc/systemd/system
- Enable govinor systemd service:
sudo systemctl enable govinor.service
- Start govinor systemd service:
sudo systemctl start govinor
Check that govinor service is running by running the following command:
sudo systemctl status govinor
Finally as the last step initialize the Caddy config:
./scripts/init-caddy.sh
Debug
For convenience here a few useful commands for diagnosing problems:
# Check govinor service status
systemctl status govinor
# Look up service logs
journalctl -u govinor -b -r
# Restart govinor service (you may need to run this with sudo)
systemctl restart govinor
# Reload Systemd when you change service configuration
sudo systemctl daemon-reload
# View the process running govinor
lsof -i tcp:3000