Skip to content
University-Of-FoolPublic

About

A beautifully simple, self-hosted sharing service.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

Spectra

GitHub Actions Workflow Status GitHub last commit GitHub License Badge showing this repository's Rust code analysis

A beautifully simple, self-hosted sharing service.

Spectra Screenshot

Quickstart

  1. Head to the releases page.
  2. Download the latest release for your platform.
  3. Extract the archive to somewhere like /opt/spectra.
  4. Go to the directory where you extracted the archive.
  5. Run ./Spectra init to generate the configuration file.
  6. Edit the configuration file to your liking.
  7. Run ./Spectra to start the server.

Try it Online

Before deploying your own instance, you can try Spectra on the demo site hosted by RLt. The demo site uses Cloudflare Turnstile to prevent abuse. You can disable it when deploying your own instance.

s.akyuu.cn

Multi-language Support

You can switch languages by clicking the globe icon in the top-right corner. Spectra currently supports the following languages:

  • 简体中文
  • English

Contributions of additional translations are welcome.

Linux Deployment

On Linux distros, you can use the systemd unit file to manage the service. Spectra provides a command for generating the unit file.

sudo ./Spectra systemd
sudo systemctl daemon-reload

After that you can enable and start the service:

sudo systemctl enable --now spectra

Important

For security reasons, it is highly recommended to run the server as a non-root user like spectra. This is not required and can be ignored, but there will be risks.

You can add spectra user like this:

sudo useradd -M -U spectra
# don't forget to replace /opt/spectra with your own path
sudo chown -R spectra:spectra /opt/spectra

And then uncomment the User line in the unit file created above:

- # User=spectra
+ User=spectra

Container Deployment

The public Quay image uses Alpine Linux and is published as quay.io/lingrottin/spectra:latest. It contains the prebuilt static musl binary and a configuration that listens on 0.0.0.0:3000.

Run it with Podman and a named volume so the SQLite database and uploaded files persist:

podman run --detach \
  --name spectra \
  --publish 3000:3000 \
  --volume spectra-data:/var/lib/spectra/data \
  quay.io/lingrottin/spectra:latest

Open http://127.0.0.1:3000. Persistent application data is stored in /var/lib/spectra/data.

To build the image locally, first build the frontend and the static musl binary at target/x86_64-unknown-linux-musl/release/Spectra, then run:

podman build --tag spectra:latest .

To use a host directory instead of a named volume on SELinux-enabled systems:

mkdir -p spectra-data
podman run --detach \
  --name spectra \
  --publish 3000:3000 \
  --volume ./spectra-data:/var/lib/spectra/data:Z,U \
  quay.io/lingrottin/spectra:latest

Reverse Proxy

Spectra itself does not support SSL. Using a reverse proxy software like Nginx is recommended.

Sample configuration block for nginx:

server {
    listen       443 ssl http2;
    listen       [::]:443 ssl http2;
    server_name  spectra.example.com;

    ssl_certificate "/path/to/cert.pem";
    ssl_certificate_key "/path/to/key.pem";
    ssl_session_cache shared:SSL:1m;
    ssl_session_timeout  10m;
    ssl_ciphers PROFILE=SYSTEM;
    ssl_prefer_server_ciphers on;
    include /etc/nginx/default.d/*.conf;

    location / {
        proxy_pass http://127.0.0.1:3000/;
        client_max_body_size 1024M;
    }
}

Development

Before continuing, make sure you have these installed:

  • Rust toolchain
  • Node.js & pnpm (it would be better if your pnpm is installed using npm)
  • Windows Terminal

Then create a .env under the root directory.

Write the content below:

DATABASE_URL=sqlite:./data.db

You can name the database file whatever you want, but make sure it is an SQLite URL.

And run the command below:

pnpm install
cargo install sqlx-cli
sqlx database setup

Finally run the command below to run the project under development mode:

pnpm dev

Note for building on Windows

Cargo might fail to locate the cmake binary on Windows.

You can find its path by running the command below in "Developer PowerShell for VS 20xx":

where.exe cmake

Then add the path to spectra/.cargo/config.toml like below:

[env]
CMAKE = "C:\\path\\to\\cmake.exe"

About

A beautifully simple, self-hosted sharing service.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages