Systemd Deployment
This guide shows how to run the rs-ibed server directly on a Linux host with systemd.
What you need
Section titled “What you need”- A Linux host with
systemd - The
rs-ibedbinary installed somewhere stable such as/opt/rs-ibed/rs-ibed - A
config.tomlfile - Writable storage directories for uploads, cache, and optionally SQLite data
The server binary is rs-ibed. If your config file is not in the working directory, start it with --config /path/to/config.toml.
Required environment variables
Section titled “Required environment variables”By default, RS-IBED reads secrets from environment variables using the IMG_ prefix:
IMG_AUTH_TOKENIMG_JWT_SECRETIMG_DATABASE_URL
If you changed server.env_prefix in config.toml, rename these variables to match.
Prepare directories
Section titled “Prepare directories”Create a working directory that contains your config file and writable data paths. The checked-in sample config uses ./data/uploads and ./data/cache, so those paths resolve relative to the service working directory.
sudo mkdir -p /opt/rs-ibed/data/uploadssudo mkdir -p /opt/rs-ibed/data/cachesudo mkdir -p /opt/rs-ibed/dataIf you use SQLite, make sure the parent directory of the database file is also writable. For example, this URL needs /opt/rs-ibed/data to exist and be writable:
export IMG_DATABASE_URL="sqlite:///opt/rs-ibed/data/image_host.db?mode=rwc"Example environment file
Section titled “Example environment file”Storing secrets in an environment file is usually cleaner than embedding them directly in the unit.
IMG_AUTH_TOKEN=replace-with-a-long-random-tokenIMG_JWT_SECRET=replace-with-a-long-random-secretIMG_DATABASE_URL=sqlite:///opt/rs-ibed/data/image_host.db?mode=rwcSave that as /etc/rs-ibed/rs-ibed.env and restrict its permissions.
Example unit file
Section titled “Example unit file”Create /etc/systemd/system/rs-ibed.service:
[Unit]Description=RS-IBED image hosting serviceAfter=network-online.targetWants=network-online.target
[Service]Type=simpleWorkingDirectory=/opt/rs-ibedExecStart=/opt/rs-ibed/rs-ibed --config /opt/rs-ibed/config.tomlEnvironmentFile=/etc/rs-ibed/rs-ibed.env# You can also use inline values instead of EnvironmentFile:# Environment=IMG_AUTH_TOKEN=replace-me# Environment=IMG_JWT_SECRET=replace-me# Environment=IMG_DATABASE_URL=sqlite:///opt/rs-ibed/data/image_host.db?mode=rwcRestart=on-failureRestartSec=5
[Install]WantedBy=multi-user.targetStart and inspect the service
Section titled “Start and inspect the service”Reload the unit files, enable the service, and start it:
sudo systemctl daemon-reloadsudo systemctl enable --now rs-ibedCheck current status:
sudo systemctl status rs-ibedFollow logs:
sudo journalctl -u rs-ibed -fNotes for SQLite and PostgreSQL
Section titled “Notes for SQLite and PostgreSQL”SQLite
Section titled “SQLite”- Set
IMG_DATABASE_URLto a SQLite path such assqlite:///opt/rs-ibed/data/image_host.db?mode=rwc - Keep the SQLite database file on persistent storage
- Keep uploads and cache on persistent storage too, otherwise image files and generated variants will disappear after cleanup or restart
PostgreSQL
Section titled “PostgreSQL”- Set
IMG_DATABASE_URLto a PostgreSQL URL such aspostgres://ibed:[email protected]:5432/ibed - On startup, the app connects to the maintenance database first and may create the target database automatically
- The PostgreSQL user therefore needs permission to connect to
postgresand create the target database, unless the target database already exists or you usepostgresitself as the database name
Verify the deployment
Section titled “Verify the deployment”After the service is running, open http://your-host:3000/ in a browser and upload a test image.
Then restart the service and confirm metadata, uploads, and cached variants still work:
sudo systemctl restart rs-ibedsudo systemctl status rs-ibed