Skip to content

Latest commit

 

History

History
95 lines (57 loc) · 1.95 KB

README.md

File metadata and controls

95 lines (57 loc) · 1.95 KB

Deploy FastHTML App to a VPS with Kamal

Minimal project to deploy a FastHtml application on a VPS using a docker image and Kamal deploy.

This project uses Python, FastHTML, Docker desktop, Github container registry, Ruby and Kamal.

Install Ruby & Kamal

gem install kamal

Setup our local develpment environment

python -m venv ./.venv
source ./.venv/Scripts/activate
pip install -r requirements.txt

Create a Github container registry and Github Access Token

https://docs.github.com/fr/packages/working-with-a-github-packages-registry/working-with-the-container-registry

https://docs.github.com/fr/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens

Secrets

Create a .env file with your secrets:

GHCR_TOKEN=<your github container registry access token>
GHCR_REGISTRY_USER=<your github user name>
SERVER_IPS=<your VPS IP>

Build & push docker image

source .env

docker build -t fasthtml-demo .

echo $GHCR_TOKEN | docker login ghcr.io -u $GHCR_REGISTRY_USER --password-stdin
docker tag fasthtml-demo ghcr.io/$GHCR_REGISTRY_USER/fasthtml-demo
docker push ghcr.io/$GHCR_REGISTRY_USER/fasthtml-demo:latest

Run the docker image locally

docker run -p 8000:8000 fasthtml-demo

Open http://localhost:8000 in your browser.

Deploy to VPS

Provision a cheap VPS

Prepare your VPS

ssh ubuntu@vps-ip

copy or create a ssh key

Install base packages

sudo apt update && apt upgrade -y
sudo apt install -y docker.io curl git
sudo usermod -a -G docker ubuntu
sudo mkdir -p /letsencrypt && sudo touch /letsencrypt/acme.json && sudo chmod 600 /letsencrypt/acme.json

Initial setup

kamal setup

Standard deployment

Deploy latest release

kamal deploy