Synology Package Repository
- Install dependencies with
poetry install
- Run the next commands in the virtual environment
poetry shell
- Create the tables with
python manage.py db create
- Populate the database with some fake packages with
python manage.py db populate
- Add an user with
python manage.py user create -u Admin -e admin@admin.adm -p adminadmin
- Grant the created user with Administrator permissions
python manage.py user add_role -u admin@admin.adm -r admin
- Grant the created user with Package Administrator permissions
python manage.py user add_role -u admin@admin.adm -r package_admin
- Grant the created user with Developer permissions
python manage.py user add_role -u admin@admin.adm -r developer
To reset the environment, clean up with python manage.py clean
.
- Start the development server with
python manage.py runserver
- Website is available at http://localhost:5000
- Admin interface is available at http://localhost:5000/admin
- NAS interface is available at http://localhost:5000/nas
- API is available at http://localhost:5000/api
- Run the test suite with
poetry run pytest -v
It is also possible to start a development environment with postgres database using docker compose:
- Build and run
docker-compose up --build
- On first run you can apply database migrations with
docker exec spkrepo_spkrepo_1 python manage.py db upgrade
. Also run any other command that you need (populate the databse, create user) as mentioned above but by prefixing withdocker exec {container_id} [...]
. - Browse to http://localhost:5000
- To tear down the environment, run
docker-compose down --remove
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= "simple"
# For signing packages
GNUPG_PATH= "/usr/local/bin/gpg"
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'