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.
Govinor listens to Github webhooks of a repo of your choice and creates and manages Docker containers with preview links.
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.
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, ssh into the server and run the following commands:
cd ~/govinor;
git pull;
npm ci;
npm run deploy;
First, create an AWS account and create an IAM user with these permissions:
AmazonEC2FullAccess
AmazonRDSFullAccess
AmazonS3FullAccess
- 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.
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
Follow the instructions "Install on Linux" to install Docker Compose.
Follow the instructions for "Ubuntu" to install Caddy.
To make it easier to manage and upgrade Node versions, Govinor uses Node Version Manager.
To install Node.js, run the following command:
nvm install 20
Let's also set the default Node version to the one we just installed:
nvm alias default 20
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".
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
Initialize the Caddy config:
./scripts/init-caddy.sh
As a final step, you need to configure the Github as a known host for the EC2 instance. To do so, ssh into the EC2 instance and run the following command:
ssh-keyscan github.com >> ~/.ssh/known_hosts
If Govinor runs out of memory, to scale it up follow the following steps:
- Stop the running EC2 instance and wait for it to stop (it can take a few minutes)
- Change the instance type appropriately
- Start the instance again and wait for it to start (it can take a few minutes)
- ssh into the ec2 instance (using the new machine IP)
- Initialize the Caddy config:
cd ~/govinor ./scripts/init-caddy.sh
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
# View what routes are exposed by govinor - shows the Caddy config
curl -X GET http://localhost:2019/config/ | jq