Skip to content

izkluxcvy/tinyap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

197 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TinyAP

micro-blogging software built on ActivityPub, part of the Fediverse.

NoJS, Fast, Lightweight.

Demo: @alice@tinyap.izkluxcvy.foo

Features

  • Federate with remote users
  • Create text note
  • Follow, Reply, Like, Boost, Undo them
  • Block domain
  • Tiny memory usage
  • Tiny web UI
  • Mastodon-compatible API

Memory usage

Real memory usage of tinyap.izkluxcvy.foo

$ watch -n 360 'echo $(date "+%F %T"),$(cat /sys/fs/cgroup/system.slice/tinyap.service/memory.current) >> memory.csv'

memory usage

(Note that Argon2 password hasher costs 19MB memory)

Tested clients

Requirements

  • Rust (for building from source)
  • SQLite or PostgreSQL
  • HttpS

Installation

Debian package

Download .deb package(features: sqlite, web, api) from Releases

Install TinyAP

$ sudo apt install ./tinyap_amd64.deb
$ tinyap --version

Configure and run

$ sudo vi /etc/tinyap/config.yaml
$ sudo systemctl enable --now tinyap.service

Build from source

Clone git repo.

$ git clone --depth 1 https://github.com/izkluxcvy/tinyap.git
$ cd tinyap

Create database.

$ # for SQLite
$ sqlite3 tinyap.db < schema.sql

$ # for PostgreSQL
$ psql -U postgres -c "CREATE DATABASE tinyap"
$ sed -e "s/INTEGER PRIMARY KEY AUTOINCREMENT/BIGSERIAL PRIMARY KEY/g" schema.sql | psql -U postgres -d tinyap

Configure your config.yaml.

$ vi config.yaml

Build and run

$ cargo build --release --features=sqlite,web,api

$ mv target/release/tinyap ./
$ cargo clean

$ ./tinyap --help
$ ./tinyap serve

For Linux/glibc, MALLOC_MMAP_THRESHOLD_=131072 environment variable can suppress memory fragmentation.

Build feature flags:

  • mimalloc: use mimalloc for memory allocator instead of system allocator
  • sqlite: use SQLite for DB (must be exclusive with postgres)
  • postgres: use PostgreSQL for DB
  • web: text-based tiny Web UI
  • api: mastodon-compatible API
  • tls: tinyap as a TLS termination

Config file path

You can place in ./config.yaml or /etc/tinyap/config.yaml or $TINYAP_CONFIG

$ TINYAP_CONFIG=/path/to/config.yaml ./tinyap serve

Example nginx.conf

http {
    gzip  on;
    limit_req_zone $binary_remote_addr zone=tinyaplogin:3m rate=1r/s;

	server {
        listen 80;
        server_name example.com;

        return 301 https://$host$request_uri;
    }

    server {
        listen 443 ssl;
        http2 on;
        server_name example.com;

        location / {
            proxy_pass http://127.0.0.1:8080;
            proxy_set_header Host $host;
            proxy_set_header X-Real_IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
        }
        location /static/style.css {
            proxy_pass http://127.0.0.1:8080;
            expires 1d;
        }
        location /login {
            proxy_pass http://127.0.0.1:8080;
            limit_req zone=tinyaplogin burst=5 nodelay;
        }
        location /oauth/authorize {
            proxy_pass http://127.0.0.1:8080;
            limit_req zone=tinyaplogin burst=5 nodelay;
        }

        ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
    }

}

You can also build with tls feature for tinyap as a TLS termination, using remote proxy like cloudflare without httpd like nginx.

Customizing Web UI

templates/

HTML with Jinja template format.

Loaded once when server starts.

static/

Static files like style.css.

Loaded on each access to /static/xxx.xx.