A hosting service for Jekyll Blogs
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
Manager Bot 5580beb497 Build better maybe. 3 years ago
DB Move hosted servers and domains to internal config. 3 years ago
Web Build better maybe. 3 years ago
devops/ansible Add rsync to build servers. 3 years ago
libs Reload nginx after configs. 3 years ago
README.md Added jekyll bit. 3 years ago

README.md

What is MyJekyllBlog?

MyJekyllBlog is a project to provide a SaaS web interface to Jekyll backed with a CMS and web hosting infrastructure.

What are the systems?

Web Panel

The web panel allows users of the service to create and manage their Jeykll blogs.

The following functionality should exist:

  • Wizard to create a new blog
  • Editor panel that lists articles
  • Editor panel that lists pages
  • Editor panel that allows creating a new article
  • Editor panel that allows creating a new page
  • Editor panel that allows editing an existing article
  • Editor panel that allows editing an existing page
  • Manager panel that shows last deployment
  • Manager panel that allows deploying the blog
  • Manager panel that allows adding a custom domain name to the blog
  • Manager panel that shows list of commits and which one is deployed
  • Manager panel that allows selecting an alternative commit and deploying it

Database Server

The database server holds the database for the Web Panel and for the Build Server.

Gitea Server

The gitea server will have user mapping between the Web Panel and Gitea. Users websites will be held as repos here.

Build Server

The build server will check out the repo, build the static site and deploy it to whichever Web Server it should be deployed to.

SSL Server

The SSL server will run certbot. The /.well-known directory should be proxied to this server so that HTTP challenges can be used.

Web Servers

Web servers will host static content for Jeykll blogs.

How does it work?

Create a new account on MyJekyllBlog

sequenceDiagram
    User ->>+Web Panel: Register with name, email, password
    Web Panel->>+Database: Create user account for panel
    Web Panel->>+Gitea Minion: Create Gitea User
    Web Panel->>-User: Log the user into their account

Deploy a Jekyll blog

sequenceDiagram
    Web Panel->>+Build Server: Build jeykll id X
    Build Server->>+Gitea Server: Checkout Repo
    Gitea Server-->>-Build Server: Get repo
    Build Server-->+Build Server: Build static site from repo
    Build Server-->+Web Server: Deploy website

Create a new post a Jekyll blog

Installation Guide

Step 1: Machine Selection

First, I should layout the servers. At least one panel, build, store and certbot server will be needed to run the platform. One or more webservers will be needed to serve blogs.

These servers should all be Debian 11 machines. I will also need a machine to install from, which should have git, ansible, and SSH access to all of the other machines.

I have choosen to lay out the machines as follows. The private IP addresses will be used to limit database access.

Machine Public IP Private IP Domain
panel 45.79.91.170 192.168.134.89 panel.myjekyllblog.net
build 173.255.209.214 192.168.202.60 build.myjekyllblog.net
store 173.255.209.241 192.168.207.169 store.myjekyllblog.net
certbot 104.200.24.149 192.168.210.55 certbot.myjekyllblog.net
web-west 104.200.24.174 N/A web-west.myjekyllblog.net
web-east 45.79.171.182 N/A web-east.myjekyllblog.net

Each of these machines is now online, brought up on Linode with their default Debian 11 image.

Next I will need to checkout the repository and update the configuration file.

git clone ...
cd devops/ansible/
mkdir -p env/staging
cp config.example.yml env/staging/inventory.yml
vim env/staging/inventory.yml

I named the configuration file env/staging/inventory.yml, since this will be a staging environment. I placed this in its own directory because some environment specific files will be stored in the inventory directory, and keeping seperate directories will prevent file clobbering. One should pay special attention to go through this example config file and update it with details of their network. Once this is complete, the installation should be smooth sailing with ansible. I use the following command to get everything installed.

ansible-playbook -i env/staging/inventory.yml site.yml

This command took about two and a half hours to complete, it should largely setup the whole platform across all of the machines.

Step 2: Manual Steps

Now the ansible playbook has run successfully, and all of the machines are set up.

During the installation process, an SSH keypair was created. The public key must be added to the Gitea user that was setup. This must be done through the Gitea web panel.

  1. Login to Gitea on the store server, using the credentials for gitea user/pass from the inventory file.
  2. Click the user drop down in the upper right
  3. Click Settings from the drop down menu
  4. Click "SSH / GPG Keys"
  5. Click "Add Key" under "Manage SSH Keys"
  6. Type a title
  7. Paste the contents of env/staging/files/ssh/id_rsa.pub
  8. Click to add the key

Once this is done, you'll need to create the mjb organization.

  1. Click the + Plus button drop down
  2. Click "New Organization"
  3. Name the organization "mjb"
  4. Click "Create Organization"

Everything should be setup now.

Step 3: Confirm It All Works!

  1. Create a user account
  2. Create a blog
  3. Delete a post

Development Guide

MJB::Web Panel Development

As root you will need to stop the MJB::Web app from running in production.

systemctl stop mjb-web

As the manager user you can run the application in development mode.

cd mjb/Web
morbo ./script/mjb --listen http://127.0.0.1:8080

Now it will automatically reload when you make changes to the libraries and templates. Additionally, it will show stack traces during crashes and debug information in your terminal.

Jekyll

You can run Jekyll by getting into a build server and running the following:

alias jekyll="podman run -ti --rm -v .:/srv/jekyll -e JEKYLL_ROOTLESS=1 docker.io/jekyll/jekyll jekyll"

Once you've done that, jekyll command will work.

Operations Guide