Continuous deployment of Pollen-built website
I'm building a static website that I want to have continuously deployed to a website. I wanted to write up my experience with Gitlab Pages here in case it helps anybody (since this repository has helped me so much I should at least try to give back!)
Because Gitlab Pages is very similar to Github Pages, it shouldn't be too hard to adapt this to work with it.
To deploy a website to Gitlab Pages we need to write a script specifying the environment used to build the website files and how to build them (see the documentation linked above for the details). Gitlab Pages allows you to use a container image from Docker Hub as your environment, so I grabbed Racket's container image. To speed up the build I tried caching the pollen installation (so that it wouldn't reinstall it at every build), but alas I was taking too long to figure out how to do it so I created a new container image. This new image is built on top of the Racket one, and simply specifies an additional step of installing pollen.
The build/deploy script is very simple, it just calls
pollen render and moves the output files to a special directory that gets deployed by Gitlab Pages (does
pollen render have an option to specify an output directory? it would simplify things!)
The deploy script and the Dockerfile that build the container image are in this gist if anyone is interested!
Some observations and questions:
- One could adapt this script to deploy the website anywhere (save Github Pages, maybe?) You're not bound to Gitlab Pages;
- Does anyone have a container image for this purpose already?
- The container image I built is simple and it works, but maybe we want to have a more official one, that gets deployed to docker hub automatically and is not tied to my name;
- If you want to change the Pollen or Racket versions of the build environment you must rewrite the Dockerfile and re-upload it to Docker hub (unless we set up a repository with this deployment automatically made)
- I used a Dockerfile because Gitlab Pages only uses images from Docker Hub (AFAIK), but the image was built with Podman, which is fully open source (unlike Docker)
That's very cool! My personal approach is to build everything locally and
rsync only the output HTML files to my server.
Timely thread. I’ve used plain old
rsync before now as well, but I’ve been looking into repo-based auto-deploy as well.
Netlify is sitting on a PR that would add Racket support and dependency caching. I’ve been hoping they would approve it for a couple of months now.
It looks like it should be possible to use Travis CI for this, deploying to an S3 bucket. Greg Hendershott has travis-racket for this. I was planning to try this out and write up a how-to sometime soon, but if anyone else does so first I definitely won’t be mad.
does pollen render have an option to specify an output directory? it would simplify things!
You can follow up a
raco pollen render with
raco pollen publish
/project/folder /path/to/output. The output folder will contain the contents of the project folder minus any pollen sources or cache files. So there could be additional files in there that you might want to remove but that will get you very close.
rsync seems like a great solution if you have a server available! if you set up a git hook so that it runs at every commit or push, I'd say it might even be better than the CD approach
Netlify is sitting on a PR
I've added my thumbs up if that helps anything, I don't see why they'd take so long… we could try the same thing for gitlab (does github have this option of creating new custom images too?)
You can follow up a raco pollen render with raco pollen publish/project/folder /path/to/output
thank you :) that should do it!
Deleting a branch is permanent. It CANNOT be undone. Continue?