repos

blog.bythewood.me-flask

mirror archived upstream

Markdown blog on Flask with Vite-built assets and WeasyPrint PDF export, rewritten from the Wagtail build that preceded it.

blogdockerflaskmarkdownpythonself-hostedvite

5.1 KB · 141 lines · markdown Raw History
  1> **Archived.** This project is no longer in use and no longer maintained. Last updated May 2026.
  2
  3# Blog
  4
  5A self-hostable blog built on Flask 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 Flask with markdown files for content, no database required.
 18- Customized for developers, makes use of CodeMirror for syntax highlighting.
 19- Easily adjusted to fit your needs with Bootstrap for the design and easy to
 20  adjust hosting options using Docker.
 21- Minimal network payloads, out of the box 100% scores on all lighthouse metrics
 22  and most pages, even with a few images, are less than 300kB in size.
 23
 24
 25## Requirements
 26
 27You need docker + docker-compose installed for a quick production start or you
 28can figure out how we install and run things via the `Dockerfile` and set it up
 29yourself.
 30
 31If you want to install things without docker then you'll need the following
 32dependencies:
 33
 34- python
 35- uv
 36- bun
 37
 38You can also check the `Dockerfile` for an exact list of dependencies and adjust
 39package names for your desired platform.
 40
 41
 42## Running locally
 43
 44If you have all of the above dependencies installed you can use my Makefile to
 45run and install python and node dependencies locally. Running `make run` will
 46start both the Vite watcher and the Flask dev server.
 47
 48
 49## Checking outdated dependencies
 50
 51This can be done in both bun and uv with the following two commands:
 52
 53    uv lock --upgrade --dry-run
 54    bun outdated
 55
 56You can then upgrade the outdated dependencies with the following two commands:
 57
 58    uv lock --upgrade
 59    bun update
 60
 61I recommend testing everything after this to make sure it's all working.
 62
 63
 64## Optimizing images with webp
 65
 66My development system runs Ubuntu so I installed the official webp utils from
 67Google with `apt install webp`.
 68
 69    cwebp -q 90 -m 6 -o output.webp input.png
 70
 71
 72## Using docker-compose
 73
 74The easiest way to run this project is to run it using
 75`docker-compose up --build -d` if you have `docker-compose` and `docker`
 76installed. This will start the server and have you running at port 8000. Make
 77sure you setup the `.env` file before running, you can copy the sample from
 78`samplefiles/env.sample` into the root of the project as `.env` and change the
 79variables.
 80
 81
 82## Backups
 83
 84All data is stored in the repo itself (markdown files in `content/posts/` and
 85images in `content/images/`). Back up the repo and you have everything.
 86
 87
 88## Support
 89
 90I won't be providing any user support for this project. I'm more than happy to
 91accept good pull requests and fix bugs but I don't have the time to help people
 92run or use this project. I appologize in advance for this. Maintaining
 93mutliple OSS projects has taught me that I need to step back from trying to
 94provide support to avoid burnout.
 95
 96
 97## Server guide
 98
 99This quickstart requires that you have an Alpine Linux server running with a
100domain name pointed to it. I'm currently using Linode as my host since they
101support Alpine Linux nicely. If you don't want to use Linode or Alpine Linux
102you can use these instructions and just change the apk commands at the start to
103whatever Linux distro you're using.
104
105**IMPORTANT NOTE**: Change `blog.bythewood.me` to your domain name where
106relevant in these instructions.
107
108**TIP**: During the ufw portion to enable the firewall I recommend only allowing
109your IP address or your ISP's IP address range which you can find on whois
110lookups at the top. For example, replace `192.230.176.0/20` with your IP or your
111ISP's IP range.
112
113    ufw allow from 192.230.176.0/20 proto tcp to any port 22
114
115I allow my local ISP's range because I have a DHCP lease from them and I get
116tired of logging into my server from my hosting provider's UI to update it. It's
117good enough security and much better than nothing!
118
119Server:
120
121    apk update && apk upgrade && apk add docker docker-compose caddy git iptables ip6tables ufw
122    ufw allow 22/tcp && ufw allow 80/tcp && ufw allow 443/tcp && ufw --force enable
123    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
124    rc-update add docker boot && service docker start
125    mkdir -p /srv/git/blog.bythewood.me.git && cd /srv/git/blog.bythewood.me.git && git init --bare
126
127Local:
128
129    git clone [email protected]:overshard/blog.bythewood.me-flask.git && cd blog.bythewood.me-flask
130    git remote remove origin && git remote add origin [email protected]:/srv/git/blog.bythewood.me.git
131    git push --set-upstream origin master
132
133Server:
134
135    mkdir -p /srv/docker && cd /srv/docker && git clone /srv/git/blog.bythewood.me.git blog.bythewood.me && cd /srv/docker/blog.bythewood.me
136    cp samplefiles/Caddyfile.sample /etc/caddy/Caddyfile && sed -i 's/blog.example.com/blog.bythewood.me/g' /etc/caddy/Caddyfile
137    cp samplefiles/env.sample .env && sed -i 's/blog.example.com/blog.bythewood.me/g' .env
138    cp samplefiles/post-receive.sample /srv/git/blog.bythewood.me.git/hooks/post-receive
139    docker-compose up --build --detach
140    rc-update add caddy boot && service caddy start