Skip to main content

Synology Package Repository

Project description

spkrepo

Synology Package Repository

Build Discord

Development

Requirements

  1. Install docker and docker-compose
  2. Install uv
  3. Install pre-commit e.g. uv tool install pre-commit

Installation

  1. Run postgres, e.g. using docker with docker compose up db
  2. Install dependencies with uv sync
  3. Create the tables with uv run flask db upgrade
  4. Populate the database with some fake packages with uv run flask spkrepo populate_db
  5. Add an admin account with uv run flask spkrepo create_admin -u admin -e admin@synocommunity.com -p adminadmin

To clean data created by fake packages, run uv run flask spkrepo depopulate_db

Run

  1. Start postgres with docker compose up db
  2. Start the development server with uv run flask run
  3. Website is available at http://localhost:5000
  4. Admin interface is available at http://localhost:5000/admin
  5. NAS interface is available at http://localhost:5000/nas
  6. API is available at http://localhost:5000/api
  7. Run the test suite with uv run pytest -v

spkrepo CLI Usage

Usage: flask spkrepo [OPTIONS] COMMAND [ARGS]...

  Spkrepo admin commands.

Options:
  --help  Show this message and exit.

Commands:
  clean          Clean data path.
  create_admin   Create a new admin user.
  create_user    Create a new user with an activated account.
  depopulate_db  Depopulate database.
  populate_db    Populate the database with some packages.
  1. Add a user with uv run flask spkrepo create_user -u admin -e admin@synocommunity.com -p adminadmin
  2. Grant the created user with Administrator permissions uv run flask roles add admin@synocommunity.com admin
  3. Grant the created user with Package Administrator permissions uv run flask roles add admin@synocommunity.com package_admin
  4. Grant the created user with Developer permissions uv run flask roles add admin@synocommunity.com developer

Docker Compose Run

  • If you also want to run the app in docker you can with docker compose up app
  • You can run both postgres and the app with docker compose up

Deployment

Configuration

Create a config file ./config.py to disable debug logs, connect to a database, set a secure key and optionally set a cache:

Use LC_CTYPE=C tr -cd '[:print:]' < /dev/urandom | head -c 64 or base64 < /dev/urandom | head -c 64 to get a random string

DEBUG = False
TESTING = False
SECRET_KEY = "Please-change-me-to-some-random-string"
SQLALCHEMY_ECHO = False
SQLALCHEMY_DATABASE_URI = "postgresql://user:pass@localhost/dbname"
# https://pythonhosted.org/Flask-Caching/#configuring-flask-caching
CACHE_TYPE= "SimpleCache"
# For signing packages
GNUPG_PATH= "/usr/local/bin/gpg"

Run Tests & Linters

uv run pytest -v
uvx pre-commit run --all-files

Docker

Example usage:

docker run -it --rm --name spkrepo -v $(pwd)/data:/data -p 8000:8000 ghcr.io/synocommunity/spkrepo

Additional configuration can be mounted in the container and loaded by putting the path into SPKREPO_CONFIG environment variable.

e.g.

docker run -it --rm --name spkrepo -v $(pwd)/data:/data -v $(pwd)/docker-config.py:/docker-config.py -e SPKREPO_CONFIG=/docker-config.py -p 8000:8000 ghcr.io/synocommunity/spkrepo

Serve app via a WSGI server.

Example:

pip install gunicorn
SPKREPO_CONFIG="$PWD/config.py" gunicorn -w 4 'wsgi:app'
# or
SPKREPO_CONFIG="$PWD/config.py" uv run --with gunicorn gunicorn -b 0.0.0.0:8080 -w 4 wsgi:app

Add migration

uv run flask db revision -m "update build path length"

Test NAS API

curl "http://localhost:5000/nas?package_update_channel=beta&build=24922&language=enu&major=6&micro=2&arch=x86_64&minor=2"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spkrepo-0.4.2.tar.gz (252.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spkrepo-0.4.2-py3-none-any.whl (157.0 kB view details)

Uploaded Python 3

File details

Details for the file spkrepo-0.4.2.tar.gz.

File metadata

  • Download URL: spkrepo-0.4.2.tar.gz
  • Upload date:
  • Size: 252.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for spkrepo-0.4.2.tar.gz
Algorithm Hash digest
SHA256 e45c88f99445433a87d9ab575768f67630b22aaf1f58d8ced7cac390e5e02123
MD5 bbe7fb7180588bd1cc4942d144a5e216
BLAKE2b-256 640a735c4aa7befac0246570974e5163091935a97d1db953b9eaf6490fbc16b1

See more details on using hashes here.

File details

Details for the file spkrepo-0.4.2-py3-none-any.whl.

File metadata

  • Download URL: spkrepo-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 157.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for spkrepo-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9dc0e93d31b3b543c11e3bf6ccf7123e3dea7d61c6b1bb296dba4aa3329ab6e7
MD5 148226c0f5b8c8a14f91908472f94940
BLAKE2b-256 bf0d931ed4672789f9232f837c1dfc2b82d28f23eff5b5e9bc526ebaa8914fc0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page