Skip to content

Commit 2276ad2

Browse files
committed
ref!: various upgrades and fixes
1 parent e156193 commit 2276ad2

17 files changed

+1798
-863
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
---
12
repos:
23
- repo: https://github.com/python-poetry/poetry
3-
rev: master
4+
rev: 1.2.2
45
hooks:
56
- id: poetry-export
67
- repo: https://github.com/psf/black

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.9.7-buster
1+
FROM python:3.10
22

33
WORKDIR /usr/src/app
44

README.md

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,33 @@ Synology Package Repository
77

88
## Development
99
### Installation
10-
1. Install dependencies with `poetry install`
11-
2. Run the next commands in the virtual environment `poetry shell`
12-
3. Create the tables with `python manage.py create`
13-
4. Populate the database with some fake packages with `python manage.py populate`
14-
5. Add an user with `python manage.py user create -u Admin -e [email protected] -p adminadmin`
15-
6. Grant the created user with Administrator permissions `python manage.py roles add [email protected] admin`
16-
7. Grant the created user with Package Administrator permissions `python manage.py roles add [email protected] package_admin`
17-
8. Grant the created user with Developer permissions `python manage.py roles add [email protected] developer`
18-
19-
To reset the environment, clean up with `python manage.py clean`.
10+
1. Run postgres, e.g. using docker with `docker-compose up db`
11+
2. Install dependencies with `poetry install`
12+
3. Run the next commands in the virtual environment `poetry shell`
13+
4. Create the tables with `flask db upgrade`
14+
5. Populate the database with some fake packages with `flask spkrepo populate_db`
15+
6. Add a user with `flask users create username:admin email:[email protected] --password adminadmin`
16+
7. Grant the created user with Administrator permissions `flask roles add [email protected] admin`
17+
8. Grant the created user with Package Administrator permissions `flask roles add [email protected] package_admin`
18+
9. Grant the created user with Developer permissions `flask roles add [email protected] developer`
19+
20+
To clean data created by fake packages, run `flask spkrepo clean`
2021

2122
### Run
22-
1. Start the development server with `python manage.py run`
23-
2. Website is available at http://localhost:5000
24-
3. Admin interface is available at http://localhost:5000/admin
25-
4. NAS interface is available at http://localhost:5000/nas
26-
5. API is available at http://localhost:5000/api
27-
6. Run the test suite with `poetry run pytest -v`
23+
1. Start postgres with `docker-compose up db`
24+
2. Start the development server with `flask run`
25+
3. Website is available at http://localhost:5000
26+
4. Admin interface is available at http://localhost:5000/admin
27+
5. NAS interface is available at http://localhost:5000/nas
28+
6. API is available at http://localhost:5000/api
29+
7. Run the test suite with `pytest -v`
2830

2931
## Docker Compose Run
30-
It is also possible to start a development environment with postgres database
31-
using docker compose:
32-
1. Build and run `docker-compose up --build`
33-
2. On first run you can apply database migrations with `docker exec spkrepo_spkrepo_1 python manage.py db upgrade`.
34-
Also run any other command that you need (populate the databse, create user) as mentioned above but by prefixing
35-
with `docker exec {container_id} [...]`.
36-
3. Browse to http://localhost:5000
37-
4. To tear down the environment, run `docker-compose down --remove`
32+
- If you also want to run the app in docker you can with `docker-compose up app`
33+
- You can run both postgres and the app with `docker-compose up`
3834

39-
## Deployment
4035

36+
## Deployment
4137
### Configuration
4238
Create a config file `./config.py` to disable debug logs, connect to a database, set a secure key and optionally set a cache:
4339

docker-compose.yaml

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
1-
version: "3.9"
1+
---
2+
version: '3.8'
3+
24
services:
35
db:
4-
image: postgres:13
6+
image: postgres:15
57
environment:
68
POSTGRES_DB: spkrepo
79
POSTGRES_USER: spkrepo
810
POSTGRES_PASSWORD: spkrepo
9-
spkrepo:
10-
build: .
11-
command: python manage.py runserver -h 0.0.0.0
12-
ports:
13-
- "5000:5000"
14-
environment:
15-
SPKREPO_SQLALCHEMY_DATABASE_URI: postgresql://spkrepo:spkrepo@db/spkrepo
16-
volumes:
17-
- .:/usr/src/app/
18-
depends_on:
19-
- db
11+
ports:
12+
- 5432:5432
13+
app:
14+
build: .
15+
command: flask run -h 0.0.0.0
16+
ports:
17+
- 5000:5000
18+
environment:
19+
SPKREPO_SQLALCHEMY_DATABASE_URI: postgresql://spkrepo:spkrepo@db/spkrepo
20+
volumes:
21+
- .:/usr/src/app/
22+
depends_on:
23+
- db
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""Add fs_uniquifier
2+
3+
Revision ID: 76d559b4e873
4+
Revises: dc7687894ba7
5+
Create Date: 2022-10-24 09:31:01.814928
6+
7+
"""
8+
revision = "76d559b4e873"
9+
down_revision = "dc7687894ba7"
10+
11+
import sqlalchemy as sa
12+
from alembic import op
13+
14+
15+
def upgrade():
16+
# ### commands auto generated by Alembic - please adjust! ###
17+
op.add_column(
18+
"user", sa.Column("fs_uniquifier", sa.String(length=255), nullable=False)
19+
)
20+
op.create_unique_constraint(None, "user", ["fs_uniquifier"])
21+
# ### end Alembic commands ###
22+
23+
24+
def downgrade():
25+
# ### commands auto generated by Alembic - please adjust! ###
26+
op.drop_constraint(None, "user", type_="unique")
27+
op.drop_column("user", "fs_uniquifier")
28+
# ### end Alembic commands ###

migrations/versions/dc7687894ba7_.py renamed to migrations/versions/dc7687894ba7_increase_field_sizes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""empty message
1+
"""Increase field sizes
22
33
Revision ID: dc7687894ba7
44
Revises: d785f1fb2307

0 commit comments

Comments
 (0)