blogker/README.md

45 lines
2.2 KiB
Markdown
Raw Permalink Normal View History

2023-07-26 20:22:25 +00:00
# blogker
A nginx-powered container hosting a hugo-built blog regularly pulled off git.
## Run
2023-08-31 17:09:17 +00:00
There are multiple options to get your Hugo blog into blogker:
- by specifying a git URL where it gets pulled from regularly
- by passing in the required files via a bind or volume mount
### Auto-Pull Git
2023-07-26 20:22:25 +00:00
If you store your blog data in a git repository, run the container with env `REPO_URL` set to a Git repo:
`docker run -e REPO_URL=https://git.maride.cc/maride/sec.maride.cc.git -p 80:80 -d blogker`
2023-08-31 17:09:17 +00:00
#### Pull frequency
The repository will be pulled and built every 10 minutes by default.
Other values can be specified by the `BUILDFREQ` environment variable.
For example, if you want to have the blog updated every minute:
`docker run -e REPO_URL=https://... -e BUILDFREQ=1 -p 80:80 -d blogker`
Lowering this value may risk running into rate limits on some git servers.
2023-08-31 17:00:16 +00:00
#### SSH URLs
If you specify a SSH URL (`ssh:// ...`) for your repository, the host key will be automatically pulled and added as trusted host. Make sure to double-check those host keys with your git server - although a [MITM](https://www.rapid7.com/fundamentals/man-in-the-middle-attacks/) scenario is unlikely and won't pose a big risk in the case of blogker. [YMMV](https://www.urbandictionary.com/define.php?term=ymmv), but still, this may be a security risk in some cases.
If you want to pull private repositories, you may need to generate a SSH key for this purpose, and hand in the private key file, e.g. via `-v ./id_rsa:/root/.ssh/id_rsa`.
2023-09-09 17:35:43 +00:00
#### Specify branch
If there is a specific branch to use (other than [master/main](https://about.gitlab.com/blog/2021/03/10/new-git-default-branch-name/)), you can specify the desired branch using the `REPO_BRANCH` environment variable.
### Passthrough via Bind
To just use a specific directory as the hugo blog contents, run the container with the repository passed through as bind directory:
`docker run -v /var/myblog:/repo -p 80:80 -d blogker`
The repository will be built every 10 minutes, but you need to implement a mechanism to update the blog repository on your own. This setup can be handy in a testing/dev environment where you don't want to have all your blog posts published right away.