This container enables the static blogging platform hexo to be containerized. It allows for custom themes, plugins and configurations. A sample of this running can be seen at https://blog-test.fletchto99.com. This container is mainly intended for development use and rapid prototyping of blog posts, however it should be possible to run this in a production setting as well. The recommended route would be to setup a deployment and use hexo deploy
via the docker console to send the static files to be served by a CDN or something similar.
docker create \
--name=blog \
-v <path to data>:/config \
-e PGID=<gid> -e PUID=<uid> \
-e HEXO_PLUGINS=<hexo plugins> \
-p 8080:8080 \
fletchto99/hexo-dev-blog
-p 8080
- The port to run the container on-v /config
- Configuration files and generated blog files
Optional paramaters:
-e HEXO_PLUGINS
- Any hexo plugins you wish the blog to have access to, space seperated. For examplehexo-sliding-spoiler hexo-wordcount hexo-deploy-rsync
The first time the container is started up, if the mounted config volume is empty the default contents will be automatically generated. In specific:
config/_config.yml
- The hexo config fileconfig/_posts
- The directory to save your markdown postsconfig/themes/
- Same as the themes directory when generating a hexo blogconfig/public
- The directory in which the static HTML files will be saved and served from (feel free to copy these to your production server to deploy)
Below we explore some more advanced use cases such as deploying via hexo deploy
or using custom themes which require some setup.
Some themes require setup which involves running commands like npm install
. To do so follow these steps:
- Clone the theme into the
config/themes/<my theme>
directory. - Attach to the docker's console and navigate to
/blog/themes/<my theme>
- Run the required commands within the container to generate any required files
That should allow you to use the theme now! Be sure to setup any configurations within the theme as well
Currently this container supports blog deployment via rsync through the hexo-deploy-rsync
plugin. Here's an example of the deploy section of a config. Note that the deploy_key
is a private RSA key which will be used to deploy to the production server. It is saved at config/deploy_key
which is then shared with the container through the mounted volume.
deploy:
type: rsync
host: <prod server>
user: <user>
root: <path / to / blog / dir>
port: 22
delete: true
args: "-e ssh -i /config/deploy_key <user>@<prod server>"
verbose: true
ignore_errors: false
Now to deploy all I need to do is attach to the console and run hexo deploy