### Start Database Container Source: https://github.com/rr-/szurubooru/blob/master/doc/INSTALL.md For the first run, it is recommended to start the database container separately. ```bash user@host:szuru$ docker compose up -d sql ``` -------------------------------- ### Initialize and Start PostgreSQL Source: https://github.com/rr-/szurubooru/wiki/Installation-without-Docker Initializes the PostgreSQL data directory and starts the PostgreSQL service. This is a prerequisite for creating databases. ```console user@host:~$ sudo -i -u postgres initdb --locale en_US.UTF-8 -E UTF8 -D /var/lib/postgres/data user@host:~$ sudo systemctl start postgresql user@host:~$ sudo systemctl enable postgresql ``` -------------------------------- ### Install Hard Dependencies with Apt Source: https://github.com/rr-/szurubooru/wiki/Installation-without-Docker Installs essential packages for Szurubooru using Apt on Ubuntu 24.04. This includes PostgreSQL, Python, FFmpeg, and development libraries. Ensure you have curl and ca-certificates installed. ```console # Import the repository signing key: sudo apt install curl ca-certificates sudo install -d /usr/share/postgresql-common/pgdg sudo curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc # Create the repository configuration file: sudo sh -c 'echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' # Update the package lists: user@host:~$ sudo apt update # Install the latest version of PostgreSQL: # If you want a specific version, use 'postgresql-16' or similar instead of 'postgresql' sudo apt -y install postgresql sudo apt -y install python3 sudo apt -y install python3-pip sudo apt -y install ffmpeg sudo apt -y install python3-virtualenv sudo apt -y install libheif-dev sudo apt -y install libavif-dev mv /usr/lib/python3.12/EXTERNALLY-MANAGED /usr/lib/python3.12/EXTERNALLY-MANAGED.old pip3 install alembic>=0.8.5 pip3 install certifi>=2017.11.5 pip3 install coloredlogs==5.0 pip3 install heif-image-plugin pip3 install numpy>=1.8.2 pip3 install pillow-avif-plugin~=1.1.0 pip3 install pillow>=4.3.0 pip3 install psycopg2-binary>=2.6.1 pip3 install pyheif pip3 install pynacl>=1.2.1 pip3 install pyRFC3339>=1.0 pip3 install pytz>=2018.3 pip3 install pyyaml>=3.11 pip3 install "SQLAlchemy>=1.0.12, <1.4" pip3 install yt-dlp pip3 install pillow-avif-plugin pip3 install freezegun ``` -------------------------------- ### Server Configuration Example Source: https://context7.com/rr-/szurubooru/llms.txt An example of the server configuration file (config.yaml), showing settings for name, secret key, data paths, database connection, and SMTP. ```yaml # server/config.yaml example name: My Image Board secret: your-secret-key-change-this data_url: /data/ data_dir: /data/ database: postgresql://szuru:password@sql:5432/szuru default_rank: regular enable_safety: true contact_email: admin@example.com smtp: host: smtp.example.com port: 587 user: notifications@example.com pass: smtp-password privileges: 'posts:create:identified': regular 'posts:create:anonymous': power 'posts:edit:tags': regular 'posts:delete': moderator 'tags:create': regular 'users:create:any': administrator ``` -------------------------------- ### Start All Docker Containers Source: https://github.com/rr-/szurubooru/blob/master/doc/INSTALL.md Start all the Docker containers defined in the Docker Compose configuration. ```bash user@host:szuru$ docker compose up -d ``` -------------------------------- ### Szurubooru Config.yaml Example Source: https://github.com/rr-/szurubooru/wiki/Installation-without-Docker Example configuration for data URL and directory in config.yaml. These settings are crucial for Szurubooru to locate and serve data correctly. ```yaml data_url: 'http://example.com/data/' data_dir: '/srv/www/booru/client/public/data' ``` -------------------------------- ### Docker Deployment: Start and Manage Containers Source: https://context7.com/rr-/szurubooru/llms.txt Commands to pull Docker images, start containers in the correct order, view logs, and run administrative tasks. ```bash # Pull and start containers docker compose pull docker compose up -d sql # Start database first docker compose up -d # Start all services # View logs docker compose logs -f # Administrative tasks docker compose run server ./szuru-admin --help docker compose run server ./szuru-admin users create admin admin@example.com administrator docker compose run server ./szuru-admin users reset-password admin ``` -------------------------------- ### Post Snapshot Data Example Source: https://github.com/rr-/szurubooru/blob/master/doc/API.md Example of the 'data' field for a 'post' resource creation snapshot. ```json { "source": "http://example.com/", "safety": "safe", "checksum": "deadbeef", "tags": ["tag1", "tag2"], "relations": [1, 2], "notes": [, , ], "flags": ["loop"], "featured": false } ``` -------------------------------- ### Install Frontend Dependencies Source: https://github.com/rr-/szurubooru/wiki/Installation-without-Docker Navigates to the client directory and installs frontend dependencies using npm. It is recommended to run 'npm audit fix' afterwards to address vulnerabilities. ```console user@host:szuru$ cd client user@host:szuru/client$ npm install ``` -------------------------------- ### Example Docker Compose for Szurubooru Source: https://github.com/rr-/szurubooru/wiki/ARM-and-Raspberry-Pi-Support-for-Docker-builds This is an example Docker Compose configuration file for Szurubooru. It serves as a template for setting up the service using Docker Compose. ```yaml ## Example Docker Compose configuration ## ## Use this as a template to set up docker-compose, or as guide to set up other ``` -------------------------------- ### Copy Configuration Files Source: https://github.com/rr-/szurubooru/blob/master/doc/INSTALL.md Copy the example configuration files for the server and Docker Compose to their respective locations. ```bash user@host:szuru$ cp server/config.yaml.dist server/config.yaml user@host:szuru$ cp doc/example.env .env ``` -------------------------------- ### Install Hard Dependencies with Pacman Source: https://github.com/rr-/szurubooru/wiki/Installation-without-Docker Installs essential packages for Szurubooru using Pacman on Arch Linux. Ensure Python 3.8+ and pip are installed. ```console user@host:~$ sudo pacman -S postgresql user@host:~$ sudo pacman -S python user@host:~$ sudo pacman -S python-pip user@host:~$ sudo pacman -S ffmpeg user@host:~$ sudo pacman -S npm user@host:~$ sudo pip install virtualenv ``` -------------------------------- ### Tag Snapshot Data Example Source: https://github.com/rr-/szurubooru/blob/master/doc/API.md Example of the 'data' field for a 'tag' resource creation snapshot. ```json { "names": ["tag1", "tag2", "tag3"], "category": "plain", "implications": ["imp1", "imp2", "imp3"], "suggestions": ["sug1", "sug2", "sug3"] } ``` -------------------------------- ### Docker Environment Variables Example Source: https://context7.com/rr-/szurubooru/llms.txt An example of the .env file for Docker Compose, specifying port, base URL, database credentials, and data directory. ```ini # .env example PORT=:8080 BASE_URL=/ POSTGRES_USER=szuru POSTGRES_PASSWORD=secure-db-password POSTGRES_DB=szuru DATA_DIR=./data ``` -------------------------------- ### Install Backend Dependencies with Virtualenv Source: https://github.com/rr-/szurubooru/wiki/Installation-without-Docker Sets up a Python virtual environment named 'python_modules' in the server directory, activates it, and then installs backend dependencies from 'requirements.txt'. This isolates project dependencies. ```console user@host:szuru/client$ cd ../server user@host:szuru/server$ virtualenv python_modules # consistent with node_modules user@host:szuru/server$ source python_modules/bin/activate # enters the sandbox (python_modules) user@host:szuru/server$ pip install -r requirements.txt # installs the dependencies ``` -------------------------------- ### Run Szurubooru with Waitress Source: https://github.com/rr-/szurubooru/wiki/Installation-without-Docker Install Waitress and run the Szurubooru application using the waitress-serve command. Ensure the virtual environment is activated. ```bash user@host:szuru/server$ source python_modules/bin/activate (python_modules) user@host:szuru/server$ pip install waitress (python_modules) user@host:szuru/server$ waitress-serve --port 6666 szurubooru.facade:app ``` -------------------------------- ### Install libseccomp2 on Raspbian Source: https://github.com/rr-/szurubooru/wiki/ARM-and-Raspberry-Pi-Support-for-Docker-builds Use these commands to download and install the libseccomp2 package, which is necessary for Alpine 3.13 compatibility on Raspbian. ```bash $ wget http://ftp.de.debian.org/debian/pool/main/libs/libseccomp/libseccomp2_2.5.1-1_armhf.deb $ dpkg -i libseccomp2_2.5.1-1_armhf.deb ``` -------------------------------- ### Post Modification Snapshot Diff Example Source: https://github.com/rr-/szurubooru/blob/master/doc/API.md Example of a modification snapshot diff for a post, showing changes to 'source' and 'notes'. ```json { "type": "object change", "value": { "source": { "type": "primitive change", "old-value": null, "new-value": "new source" }, "notes": { "type": "list change", "removed": [], "added": [ {"polygon": [[0, 0], [0, 1], [1, 1]], "text": "new note"} ] } } } ``` -------------------------------- ### Tag Category Snapshot Data Example Source: https://github.com/rr-/szurubooru/blob/master/doc/API.md Example of the 'data' field for a 'tag_category' resource creation snapshot. ```json { "name": "character", "color": "#FF0000", "default": false } ``` -------------------------------- ### Szurubooru .env configuration Source: https://github.com/rr-/szurubooru/wiki/ARM-and-Raspberry-Pi-Support-for-Docker-builds This is an example .env file for configuring Szurubooru. It includes settings for database credentials, build information, ports, and data storage directories. Remember to set appropriate permissions for the data directory. ```env # Database credentials POSTGRES_USER=[name] POSTGRES_PASSWORD=[password] # This shows up on the homescreen, indicating build information BUILD_INFO=latest # Port to expose HTTP service PORT=[port] # Directory to store image data ## remember to chmod this directory MOUNT_DATA=/var/local/[name]/data # Directory to store database files MOUNT_SQL=/var/local/[name]/sql ``` -------------------------------- ### Apache Configuration for Szurubooru Source: https://github.com/rr-/szurubooru/wiki/Installation-without-Docker Example Apache configuration for serving static content and proxying the API. Use this if Nginx is not preferred. ```apache ServerName example.com Redirect 302 /api /api/ ProxyPreserveHost On ProxyPass /api/ http://127.0.0.1:6666/ ProxyPassReverse /api/ http://127.0.0.1:6666/ DocumentRoot "/srv/www/booru/client/public" FallbackResource /index.htm AllowEncodedSlashes On ``` -------------------------------- ### Search Query Example Source: https://github.com/rr-/szurubooru/blob/master/doc/API.md Demonstrates a search query combining multiple token types: anonymous, named, and sort tokens, with ranged values. ```text sea -fav-count:8.. type:swf uploader:Pirate ``` -------------------------------- ### Run Szurubooru Docker Container Source: https://github.com/rr-/szurubooru/wiki/Customizing-UI-Colors Start the Szurubooru Docker containers in detached mode after building the image. ```bash docker-compose up -d ``` -------------------------------- ### Create Pool Response Source: https://context7.com/rr-/szurubooru/llms.txt Example response after creating a pool, showing its assigned ID, version, names, category, associated posts with thumbnails, creation time, post count, and description. ```json { "version": 1, "id": 5, "names": ["Nature Photography Tutorial", "nature_tutorial"], "category": "series", "posts": [ {"id": 123, "thumbnailUrl": "/data/posts/123_thumb.jpg"}, {"id": 124, "thumbnailUrl": "/data/posts/124_thumb.jpg"} ], "creationTime": "2024-01-20T16:00:00Z", "postCount": 4, "description": "Step-by-step guide to nature photography" } ``` -------------------------------- ### Getting Global Info Source: https://github.com/rr-/szurubooru/blob/master/doc/API.md Retrieves global statistics and server configuration information. ```APIDOC ## GET /info ### Description Retrieves simple statistics about the server, including post count, disk usage, and featured post information. It also returns server configuration details. ### Method GET ### Endpoint /info ### Response #### Success Response (200) - **postCount** (integer) - The total number of posts. - **diskUsage** (integer) - The total disk usage in bytes. - **featuredPost** (object|null) - Information about the featured post, or null if none exists. - **featuringTime** (string) - The time when the post was featured. - **featuringUser** (string) - The user who featured the post. - **serverTime** (string) - The current server time. - **config** (object) - Server configuration details: - **userNameRegex** (string) - Regular expression for validating usernames. - **passwordRegex** (string) - Regular expression for validating passwords. - **tagNameRegex** (string) - Regular expression for validating tag names. - **tagCategoryNameRegex** (string) - Regular expression for validating tag category names. - **defaultUserRank** (integer) - The default user rank. - **privileges** (array) - An array of available privileges (keys are converted to lower camel case). #### Response Example ```json { "postCount": 12345, "diskUsage": 5432109876, "featuredPost": { "id": 100, "title": "Example Featured Post" }, "featuringTime": "2023-10-27T10:00:00Z", "featuringUser": "admin", "serverTime": "2023-10-27T10:30:00Z", "config": { "userNameRegex": "^[a-zA-Z0-9_]{3,32}$", "passwordRegex": "^.{8,}$", "tagNameRegex": "^[a-z0-9]+$", "tagCategoryNameRegex": "^[a-z0-9_]+$", "defaultUserRank": 0, "privileges": [ "view_posts", "upload_files" ] } } ``` ``` -------------------------------- ### Get Server Information Source: https://context7.com/rr-/szurubooru/llms.txt Retrieves global server statistics, configuration details, and information about the featured post. Requires an 'Accept: application/json' header. ```bash curl -X GET "http://localhost:8080/api/info" \ -H "Accept: application/json" ``` -------------------------------- ### Nginx Configuration for Szurubooru Source: https://github.com/rr-/szurubooru/wiki/Installation-without-Docker Example Nginx configuration to serve static files and proxy API requests. Ensure the API URL matches the config.yaml setting. ```nginx server { listen 80; server_name example.com; location ~ ^/api$ { return 302 /api/; } location ~ ^/api/(.*)$ { if ($request_uri ~* "/api/(.*)") { # preserve PATH_INFO as-is proxy_pass http://127.0.0.1:6666/$1; } } location / { root /srv/www/booru/client/public; try_files $uri /index.htm; } } ``` -------------------------------- ### Run Szurubooru with Gunicorn Source: https://github.com/rr-/szurubooru/wiki/Installation-without-Docker Install Gunicorn and run the Szurubooru application using the gunicorn command. This is an alternative to Waitress for serving the WSGI application. ```bash user@host:szuru/server$ source python_modules/bin/activate (python_modules) user@host:szuru/server$ pip install gunicorn (python_modules) user@host:szuru/server$ gunicorn szurubooru.facade:app -b 127.0.0.1:6666 ``` -------------------------------- ### Client Dockerfile for Szurubooru Source: https://github.com/rr-/szurubooru/wiki/ARM-and-Raspberry-Pi-Support-for-Docker-builds This Dockerfile builds the client component of Szurubooru using a multi-stage build process. It installs Node.js dependencies, builds the client, and then copies the static assets to an Nginx image. ```docker FROM arm32v7/node:9 as builder WORKDIR /opt/app COPY package.json ./ RUN npm install COPY . ./ ARG BUILD_INFO="docker-latest" ARG CLIENT_BUILD_ARGS="" RUN BASE_URL="__BASEURL__" node build.js --gzip ${CLIENT_BUILD_ARGS} FROM tobi312/rpi-nginx:alpine WORKDIR /var/www RUN \ # Create init file echo "#!/bin/sh" >> /init && \ echo 'sed -i "s|__BACKEND__|${BACKEND_HOST}|" /etc/nginx/nginx.conf' >> /init && \ echo 'sed -i "s|__BASEURL__|${BASE_URL:-/}|g" /var/www/index.htm /var/www/manifest.json' >> /init && \ echo 'exec nginx' >> /init && \ chmod a+x /init CMD ["/init"] VOLUME ["/data"] COPY nginx.conf.docker /etc/nginx/nginx.conf COPY --from=builder /opt/app/public/ . ``` -------------------------------- ### Get Global Server Information Source: https://github.com/rr-/szurubooru/blob/master/doc/API.md Retrieves key statistics about the server, including post count, disk usage, and configuration details. The configuration values are directly from the server, with privilege keys converted to lower camel case. ```json { "postCount": , "diskUsage": , "featuredPost": , "featuringTime":