Skip to content

olekspickle/axum-template

Repository files navigation

axum-template

!Image

Axum Template - Portfolio/blog website template

Overview

Portfolio/blog website template for a company that does software/games projects

This README was generated with cargo-readme from src/lib.rs.

This template provides:

  • Axum server with middleware
  • Askama templates
  • Containerization (with compose)
  • Portfolio projects management
  • Blog with markdown support
  • Admin panel with authentication
  • SQLite backend (default)
  • SurrealDB backend (optional, behind feature flag)
  • RBAC (User/Editor/Admin)
  • HttpOnly cookie support
  • Rate limiting on login
  • Enable HTTPS
  • Add login page template
  • Audit logging
  • Secure cookie flag
  • Password reset flow
  • Remember me checkbox with longer token TTL
  • Simple footer with socials

Quick start

Install cargo-generate and run:

cargo generate olekspickle/axum-template -n my-project

Running

# SQLite3 backend:
just run

# SurrealDB backend
just run-surreal

You can peek into justfile for build details

Configuration

Edit config.toml to configure:

  • Server host/port
  • Database path
  • Admin credentials (password is argon2 hashed)
  • Site name and tagline

Afterthoughts and issues

I found axum to be the most ergonomic web framework out there, and while there might be not enough examples at the moment, it is quite a breeze to use

  • static files was sure one noticeable pain in the rear to figure out
  • surrealdb sure adds complexity, I'm adding it under a feature because sqlite integration is so much less crates to compile(190+ vs 500+)

Deploy on Raspberry Pi via Cloudflare Tunnel (dockerless)

  1. Cross-compile for Pi (aarch64):

    Option A — native toolchain:

    rustup target add aarch64-unknown-linux-gnu
    sudo apt install gcc-aarch64-linux-gnu   # Debian/Ubuntu
    just build-pi

    Option B — Docker-based (no toolchain to install):

    cargo install cross
    just cross-build-pi
  2. Copy to Pi:

    rsync -avz target/aarch64-unknown-linux-gnu/release/axum-template \
               config.toml static/ templates/ systemd/ \
               pi@raspberrypi:~/deploy/
  3. Run automated setup on Pi:

    ssh pi@raspberrypi
    cd ~/deploy
    bash setup.sh

    The script downloads cloudflared to /opt/axum-template/cf/, creates symlinks at /usr/local/bin/cloudflared and /usr/local/bin/cf, sets up config directories, installs systemd services, and prompts for ADMIN_PASSWORD.

  4. Configure Cloudflare Tunnel (one-time):

    # Authenticate cloudflared as the dedicated user
    sudo -u cloudflared /opt/axum-template/cf/cloudflared tunnel login
    
    # Create tunnel and DNS route
    sudo -u cloudflared /opt/axum-template/cf/cloudflared tunnel create axum-template
    sudo -u cloudflared /opt/axum-template/cf/cloudflared tunnel route dns axum-template your-domain.com
    
    # Edit config with actual tunnel name and domain
    sudo $EDITOR /opt/axum-template/cf/config.yml
    
    # Start services
    sudo systemctl start axum-template.service
    sudo systemctl start cloudflared.service

Systemd service files are in systemd/

License: MIT OR Apache-2.0

About

Axum template(with static templates) + SQLite + dockerization

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENCE-APACHE
MIT
LICENCE-MIT

Stars

17 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors