repos

blog.bythewood.me-wagtail

mirror archived upstream

Self-hostable blog for developers built on Wagtail and Django, with webpack, Bootstrap, and CodeMirror.

blogbootstrapdjangodockerhandcodedpythonself-hostedwagtailwebpack

6.1 KB · 163 lines · markdown Raw History
  1> **Archived.** This project is no longer in use and no longer maintained. Last updated April 2026.
  2
  3# Blog
  4
  5A self-hostable blog built on Wagtail for developers.
  6
  7
  8## Motivation
  9
 10I was bored and felt like writing my own blog over the weekend.
 11
 12
 13## Features
 14
 15- Top notch SEO using industry best practices and multiple scanners to detect
 16  issues on a regular basis.
 17- Built on Wagtail and Django, powering some of the largest websites in the
 18  world. Wagtail is used by Google, NASA, MIT, Mozilla, and many others.
 19- Customized for developers, makes use of CodeMirror for syntax highlighting and
 20  on the admin panel for a clean code editing experience.
 21- Easily adjusted to fit your needs with the use of well documented projects
 22  like the above mentioned Wagtail and Django plus Bootstrap for the design and
 23  easy to adjust hosting options using Docker.
 24- Minimal network payloads, out of the box 100% scores on all lighthouse metrics
 25  and most pages, even with a few images, are less than 300kB in size.
 26
 27
 28## Requirements
 29
 30You need docker + docker-compose installed for a quick production start or you
 31can figure out how we install and run things via the `Dockerfile` and set it up
 32yourself.
 33
 34If you want to install things without docker then you'll need the following
 35dependencies:
 36
 37- python
 38- pipenv
 39- node
 40- yarn
 41- chromium
 42
 43You can also check the `Dockerfile` for an exact list of dependencies and adjust
 44package names for your desired platform.
 45
 46This is a standard Django project. If you know how to run Django, or want to
 47look up any Django tutorial on how to run Django, you shouldn't have a problem
 48getting this project running on almost anything.
 49
 50
 51## Running locally
 52
 53If you have all of the above dependencies installed you can use my Makefile to
 54run and install python and node dependencies locally. Running `make` will check
 55that you have the proper dependencies installed and if not it will try and
 56install them for you. It will then create you a fresh database and run
 57everything.
 58
 59
 60## Checking outdated dependencies
 61
 62This can be done in both yarn and pipenv with the following two commands:
 63
 64    pipenv update --outdated
 65    yarn outdated
 66
 67You can then upgrade the outdated dependencies with the following two commands:
 68
 69    pipenv update
 70    yarn upgrade
 71
 72I recommend testing everything after this to make sure it's all working.
 73
 74
 75## Optimizing images with webp
 76
 77My development system runs Ubuntu so I installed the official webp utils from
 78Google with `apt install webp`.
 79
 80    cwebp -q 90 -m 6 -o output.webp input.png
 81
 82
 83## Using docker-compose
 84
 85The easiest way to run this project is to run it using
 86`docker-compose up --build -d` if you have `docker-compose` and `docker`
 87installed. This will start the server and have you running at port 8000. The
 88first time you do this make sure you run migrations with
 89`docker-compose run web python manage.py migrate`. Make sure you setup the
 90`.env` file before running, you can copy the sample from
 91`samplefiles/env.sample` into the root of the project as `.env` and change the
 92variables.
 93
 94
 95## Default user
 96
 97The default user is `admin` with the password `admin`.
 98
 99
100## Backups
101
102All data is stored in `/srv/data/blog/` and your repo is stored in
103`/srv/git/blog.git/`. You can backup both of these folders and you'll have
104a 100% backup of everything except changes you may have made to the `Caddyfile`
105and the `.env` file which should be easy enough to recreate but you can back
106those up too!
107
108
109## Support
110
111I won't be providing any user support for this project. I'm more than happy to
112accept good pull requests and fix bugs but I don't have the time to help people
113run or use this project. I appologize in advance for this. Maintaining
114mutliple OSS projects has taught me that I need to step back from trying to
115provide support to avoid burnout.
116
117
118## Server guide
119
120This quickstart requires that you have an Alpine Linux server running with a
121domain name pointed to it. I'm currently using Linode as my host since they
122support Alpine Linux nicely. If you don't want to use Linode or Alpine Linux
123you can use these instructions and just change the apk commands at the start to
124whatever Linux distro you're using.
125
126**IMPORTANT NOTE**: Change `blog.bythewood.me` to your domain name where
127relevant in these instructions.
128
129**TIP**: During the ufw portion to enable the firewall I recommend only allowing
130your IP address or your ISP's IP address range which you can find on whois
131lookups at the top. For example, replace `192.230.176.0/20` with your IP or your
132ISP's IP range.
133
134    ufw allow from 192.230.176.0/20 proto tcp to any port 22
135
136I allow my local ISP's range because I have a DHCP lease from them and I get
137tired of logging into my server from my hosting provider's UI to update it. It's
138good enough security and much better than nothing!
139
140Server:
141
142    apk update && apk upgrade && apk add docker docker-compose caddy git iptables ip6tables ufw
143    ufw allow 22/tcp && ufw allow 80/tcp && ufw allow 443/tcp && ufw --force enable
144    echo -e "#!/bin/sh\napk upgrade --update | sed \"s/^/[\`date\`] /\" >> /var/log/apk-autoupgrade.log" > /etc/periodic/daily/apk-autoupgrade && chmod 700 /etc/periodic/daily/apk-autoupgrade
145    rc-update add docker boot && service docker start
146    mkdir -p /srv/git/blog.git && cd /srv/git/blog.git && git init --bare
147
148Local:
149
150    git clone [email protected]:overshard/blog.git && cd blog
151    git remote remove origin && git remote add origin [email protected]:/srv/git/blog.git
152    git push --set-upstream origin master
153
154Server:
155
156    mkdir -p /srv/docker && cd /srv/docker && git clone /srv/git/blog.git blog && cd /srv/docker/blog
157    cp samplefiles/Caddyfile.sample /etc/caddy/Caddyfile && sed -i 's/blog.example.com/blog.bythewood.me/g' /etc/caddy/Caddyfile
158    cp samplefiles/env.sample .env && sed -i 's/blog.example.com/blog.bythewood.me/g' .env
159    cp samplefiles/post-receive.sample /srv/git/blog.git/hooks/post-receive
160    mkdir -p /srv/data/blog/db && chown -R 1000:1000 /srv/data/blog
161    docker-compose up --build --detach && docker-compose run web python3 manage.py migrate --noinput && docker-compose run web sqlite3 db.sqlite3 "PRAGMA journal_mode=WAL;" ".exit"
162    rc-update add caddy boot && service caddy start