-- Leo's gemini proxy
-- Connecting to r.bdr.sh:1965...
-- Connected
-- Sending request
-- Meta line: 20 text/gemini; lang=en
I have a very simple website available in gemini[1] and https[2]: It's gemini-first so it consists of gemtext and some assorted static files so I built a tool called page[3,4] to help me generate the static version of the site. In this post I describe how I use that tool and sourcehut to publish my site.
You can read more about page in the link above, but in short:
it reads a _layout.html at the root of the directory.
it takes every .gmi file, and converts it to html using the layout file above.
it copies over static files and creates two "upload-ready" directories with html and gemini content.
This is easy enough to run locally, but I have the build set up in sourcehut so I can update it on push. Breaking down my .build.yml, it goes something like this:
Step 1. Specify an image. I've been using arch for a while so I went with archlinux, but the rest doesn't change that much.
image: archlinux
Step 2. Install dependencies. page needs rust and make, and I use rsync to copy files to my VPS so I only need those three.
packages: - make - rust - rsync
Step 3. Select which sources to clone. I'm building page from source and I'm using my website so I specify those two.
sources: - https://git.sr.ht/~rbdr/page - git@git.sr.ht:~rbdr/www.unlimited.pizza
Step 4. My secrets. I need a set of credentials to clone the sources, and another to connect to my VPS. Sourcehut has great documentation[4] on this, but it basically corresponds to keyfiles I can use to connect.
secrets: - 01234567-89ab-cdef-0123-456789abcdef - fedcba98-7654-3210-fedc-ba9876543210
Step 5. Do the actual work. I've separated my task in four steps. First we build page, then we generate the static files, then we rsync the html, and finally we rsync the gemini content. One thing of note is that I exclude the .build.yml because page will upload everything in the directory, including hidden files.
tasks: - build_page: | cd page make -e profile=release - generate_page: | cd www.unlimited.pizza ../page/target/release/page - sync_html: | rsync -r --exclude '.build.yml' www.unlimited.pizza_html/ deploy@www.unlimited.pizza:/srv/http/www - sync_gemini: | rsync -r --exclude '.build.yml' www.unlimited.pizza_gemini/ deploy@gemini.unlimited.pizza:/srv/gemini/content
And that's it! The build system in sourcehut is very straightforward, so using this for other website builders shouldn't be a big change. And maybe, if you're also publishing with gemini you will find page useful. In upcoming posts I'll write about how I use stargazer to host the gemini capsule (+ some cgi scripts), and how I use nginx to host the https version. Anyway! here's the complete .build.yml:
image: archlinux packages: - make - rust - rsync sources: - https://git.sr.ht/~rbdr/page - git@git.sr.ht:~rbdr/www.unlimited.pizza secrets: - 01234567-89ab-cdef-0123-456789abcdef - fedcba98-7654-3210-fedc-ba9876543210 tasks: - build_page: | cd page make -e profile=release - generate_page: | cd www.unlimited.pizza ../page/target/release/page - sync_html: | rsync -r --exclude '.build.yml' www.unlimited.pizza_html/ deploy@www.unlimited.pizza:/srv/http/www - sync_gemini: | rsync -r --exclude '.build.yml' www.unlimited.pizza_gemini/ deploy@gemini.unlimited.pizza:/srv/gemini/content
-- Response ended
-- Page fetched on Mon May 20 20:48:42 2024