First Steps Hosting
Created 2024-07-04
Step 1 is to actually get this site up on https://xylemphloem.xyz, rather than just sitting here on localhost
. I'm using a static site generator called Zola, which, as it turns out, is a little annoying to get going on Ubuntu.
Backing up a little, here's my current setup:
- I am currently writing these posts on my desktop computer, which is running Arch Linux. Installing zola here was as simple as
sudo pacman -S zola
. - I rented the absolute cheapest $3.50-per-month VPS from RamNode, which is a hosting provider I've used before and which in my experience has great customer service.
- Since it's the absolute cheapest VPS, it runs on a shared kernel, which means I can't install my own OS and so I have an Ubuntu server VM.
- The source code from the site is currently in a private repository on my personal github (i.e. the one tied to my real name). I'll move that eventually to something I can be more open about. The VPS has a "deploy key" (which means read-only) access to that repository.
Zola does not distribute a package in the default apt
repositories. I briefly tried installing the flatpak
but ran into permissions errors that I didn't feel like resolving. I've settled on docker
for now.
sudo apt install git
git clone git@github.com:[redacted]/xylemphloem.xyz.git
sudo apt install docker.io
sudo usermod -aG docker xylem
docker pull ghcr.io/getzola/zola:v0.17.1
Yes, I know that giving my user access to run docker commands unprivileged gives them root access. My user already has sudo
privileges.
Just to get something up there, I followed this guide and created the following:
dockerfile:
# dockerfile
FROM ghcr.io/getzola/zola:v0.19.1 as zola
COPY . /project
WORKDIR /project
RUN ["zola", "build"]
FROM ghcr.io/static-web-server/static-web-server:2
WORKDIR /
COPY --from=zola /project/public /public
run.sh:
#!/bin/bash
# run.sh
docker build -t xylemphloem.xyz:latest .
# something else was already on 80, gotta look into that
docker run --rm -p 8000:80 xylemphloem.xyz:latest
It turns out there was an apache2
process running by default (weird), so after I stopped that and disabled its systemd
service I could run on port 80. I'll likely use something like nginx or apache eventually, especially once I need SSL termination.
Since my deployment is a bash script that runs a docker container for now, I stuck it in a tmux
session to run in the background. Figuring out a continuous integration/deployment methodology is definitely on my TODO list. My ideal is for a script to be triggered by a push to the source repository which would pull the changes and rebuild the site.