Setting up Pelican on a Dokku host with server-side content rendering
This is somewhat of a continuation of the previous blog post on setting up a static site on Dokku. It assumes a directory with a .static
file and a Dokku remote host.
# setting up some variables for the tutorial
DIR_NAME=sample_site
# enter the project directory
cd DIR_NAME
# this command below will create the following directory structure
pelican-quickstart
# > ls
# content/ Makefile output/ pelicanconf.py publishconf.py tasks.py
# content/ is where Markdown pages go
# Makefile are shorthands for running pelican commands
# output is where the *rendered* Markdown pages go
# pelicanconf.py and publishconf.py are config files for Pelican
# tasks.py is unnecessary, it can be deleted
# for futher information how to use the Makefile, please check Pelican docs
# the following is needed to enable content rendering on the Dokku host
mkdir bin
touch bin/post_compile
echo "make html" >> bin/post_compile
# a Python buildpack is needed for Dokku to install necessary dependencies
# and essentially install Pelican inside the Dokku container
touch .buildpacks
echo "https://github.com/heroku/heroku-buildpack-python.git" >> .buildpacks
# It's good to specify python version to prevent breakage
# Note: make sure you have loaded the right virtual environment
touch .python-version
python --version | cut -d' ' -f2 >> .python-version
# a Procfile is needed to start a server serving the static files
touch Procfile
echo "web: python -m http.server $PORT --directory output" >> Procfile
# create some content to show
mkdir content/pages
touch content/pages/index.md
# commit the changes and push to Dokku host
git add ./*
git commit -m ""
git push dokku main