Skip to content

Sample project: deploy a FastHTML application to a VPS with Kamal

License

Notifications You must be signed in to change notification settings

pierrejean-coudert/fh-kamal-deploy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Sample project: deploy a FastHTML application to a VPS with Kamal

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published