# spkrepo
Synology Package Repository
![Build](https://img.shields.io/github/actions/workflow/status/SynoCommunity/spkrepo/build.yml?branch=main&style=for-the-badge)
[![Discord](https://img.shields.io/discord/732558169863225384?color=7289DA&label=Discord&logo=Discord&logoColor=white&style=for-the-badge)](https://discord.gg/nnN9fgE7EF)
## Development
### Requirements
1. Install docker and docker-compose
2. Install python and poetry
3. Optionally install direnv and a working poetry layout as described [here](https://github.com/direnv/direnv/issues/592#issuecomment-856227234) in your `~/.config/direnv/direnvrc`
### Installation
1. Run postgres, e.g. using docker with `docker compose up db`
2. Install dependencies with `poetry install`
3. Run the next commands in the virtual environment `poetry shell`
4. Create the tables with `flask db upgrade`
5. Populate the database with some fake packages with `flask spkrepo populate_db`
6. Add a user with `flask spkrepo create_user -u admin -e admin@synocommunity.com -p adminadmin`
7. Grant the created user with Administrator permissions `flask roles add admin@synocommunity.com admin`
8. Grant the created user with Package Administrator permissions `flask roles add admin@synocommunity.com package_admin`
9. Grant the created user with Developer permissions `flask roles add admin@synocommunity.com developer`
To clean data created by fake packages, run `flask spkrepo depopulate_db`
### Run
1. Start postgres with `docker compose up db`
2. Start the development server with `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 `pytest -v`
## 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
```python
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"
```
### Docker
Example usage:
```bash
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.
```bash
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](https://flask.palletsprojects.com/en/1.1.x/deploying/).
Example:
```bash
pip install gunicorn
SPKREPO_CONFIG="$PWD/config.py" gunicorn -w 4 'wsgi:app'
```
## Add migration
```
cd migrations/
alembic revision -m "update build path length"
```
Raw data
{
"_id": null,
"home_page": "https://synocommunity.com",
"name": "spkrepo",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.9,<4.0",
"maintainer_email": "",
"keywords": "synology,package,repository",
"author": "Antoine Bertin",
"author_email": "diaoulael@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/4a/07/1411f0719c677b7d47dd9cc9096f827c3d7df07cf4ed0dfd31e231543b4a/spkrepo-0.2.6.tar.gz",
"platform": null,
"description": "# spkrepo\nSynology Package Repository\n\n![Build](https://img.shields.io/github/actions/workflow/status/SynoCommunity/spkrepo/build.yml?branch=main&style=for-the-badge)\n[![Discord](https://img.shields.io/discord/732558169863225384?color=7289DA&label=Discord&logo=Discord&logoColor=white&style=for-the-badge)](https://discord.gg/nnN9fgE7EF)\n\n\n## Development\n### Requirements\n1. Install docker and docker-compose\n2. Install python and poetry\n3. Optionally install direnv and a working poetry layout as described [here](https://github.com/direnv/direnv/issues/592#issuecomment-856227234) in your `~/.config/direnv/direnvrc`\n\n### Installation\n1. Run postgres, e.g. using docker with `docker compose up db`\n2. Install dependencies with `poetry install`\n3. Run the next commands in the virtual environment `poetry shell`\n4. Create the tables with `flask db upgrade`\n5. Populate the database with some fake packages with `flask spkrepo populate_db`\n6. Add a user with `flask spkrepo create_user -u admin -e admin@synocommunity.com -p adminadmin`\n7. Grant the created user with Administrator permissions `flask roles add admin@synocommunity.com admin`\n8. Grant the created user with Package Administrator permissions `flask roles add admin@synocommunity.com package_admin`\n9. Grant the created user with Developer permissions `flask roles add admin@synocommunity.com developer`\n\nTo clean data created by fake packages, run `flask spkrepo depopulate_db`\n\n### Run\n1. Start postgres with `docker compose up db`\n2. Start the development server with `flask run`\n3. Website is available at http://localhost:5000\n4. Admin interface is available at http://localhost:5000/admin\n5. NAS interface is available at http://localhost:5000/nas\n6. API is available at http://localhost:5000/api\n7. Run the test suite with `pytest -v`\n\n## Docker Compose Run\n- If you also want to run the app in docker you can with `docker compose up app`\n- You can run both postgres and the app with `docker compose up`\n\n\n## Deployment\n### Configuration\nCreate a config file `./config.py` to disable debug logs, connect to a database, set a secure key and optionally set a cache:\n\nUse `LC_CTYPE=C tr -cd '[:print:]' < /dev/urandom | head -c 64` or `base64 < /dev/urandom | head -c 64` to get a random string\n\n```python\nDEBUG = False\nTESTING = False\nSECRET_KEY = \"Please-change-me-to-some-random-string\"\nSQLALCHEMY_ECHO = False\nSQLALCHEMY_DATABASE_URI = \"postgresql://user:pass@localhost/dbname\"\n# https://pythonhosted.org/Flask-Caching/#configuring-flask-caching\nCACHE_TYPE= \"SimpleCache\"\n# For signing packages\nGNUPG_PATH= \"/usr/local/bin/gpg\"\n```\n\n\n### Docker\nExample usage:\n\n```bash\ndocker run -it --rm --name spkrepo -v $(pwd)/data:/data -p 8000:8000 ghcr.io/synocommunity/spkrepo\n```\n\nAdditional configuration can be mounted in the container and loaded by putting\nthe path into `SPKREPO_CONFIG` environment variable.\n\ne.g.\n```bash\ndocker 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\n```\n\n\n### Serve app via [a WSGI server](https://flask.palletsprojects.com/en/1.1.x/deploying/).\nExample:\n\n```bash\npip install gunicorn\nSPKREPO_CONFIG=\"$PWD/config.py\" gunicorn -w 4 'wsgi:app'\n```\n\n## Add migration\n\n```\ncd migrations/\nalembic revision -m \"update build path length\"\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Synology Package Repository",
"version": "0.2.6",
"project_urls": {
"Homepage": "https://synocommunity.com",
"Repository": "https://github.com/SynoCommunity/spkrepo"
},
"split_keywords": [
"synology",
"package",
"repository"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "ddf8d56ecc12dfec9306f0bd5f912cd011b9b0386e71827ec831d6eb039764fe",
"md5": "0caa1df45de9352862f3d936641afc53",
"sha256": "8ec59bb1dc1f6686803731b6b4906dcf149bc3733953098cf9fb4a8382ce4930"
},
"downloads": -1,
"filename": "spkrepo-0.2.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0caa1df45de9352862f3d936641afc53",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9,<4.0",
"size": 200404,
"upload_time": "2024-02-25T11:36:56",
"upload_time_iso_8601": "2024-02-25T11:36:56.625853Z",
"url": "https://files.pythonhosted.org/packages/dd/f8/d56ecc12dfec9306f0bd5f912cd011b9b0386e71827ec831d6eb039764fe/spkrepo-0.2.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "4a071411f0719c677b7d47dd9cc9096f827c3d7df07cf4ed0dfd31e231543b4a",
"md5": "fdb86a2913f65e2c217b39e1e309fa78",
"sha256": "50f9c139759d2f247c40005bca3d10668be55422298d90c8bbc403fe632aab0a"
},
"downloads": -1,
"filename": "spkrepo-0.2.6.tar.gz",
"has_sig": false,
"md5_digest": "fdb86a2913f65e2c217b39e1e309fa78",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9,<4.0",
"size": 191727,
"upload_time": "2024-02-25T11:36:58",
"upload_time_iso_8601": "2024-02-25T11:36:58.445763Z",
"url": "https://files.pythonhosted.org/packages/4a/07/1411f0719c677b7d47dd9cc9096f827c3d7df07cf4ed0dfd31e231543b4a/spkrepo-0.2.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-02-25 11:36:58",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "SynoCommunity",
"github_project": "spkrepo",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "spkrepo"
}