diff --git a/.gitea/workflows/buildah-ci.yml b/.gitea/workflows/buildah-ci.yml new file mode 100644 index 0000000..1e1c4ff --- /dev/null +++ b/.gitea/workflows/buildah-ci.yml @@ -0,0 +1,22 @@ +name: Build and Push Image with Buildah +on: [ push ] + +jobs: + build: + name: Build and push image + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Build Image + id: build-image + uses: redhat-actions/buildah-build@v2 + with: + image: my-app + tags: latest ${{ github.sha }} + containerfiles: | + ./Containerfile + + - name: Print image url + run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}" \ No newline at end of file diff --git a/.gitignore b/.gitignore index 7c1773c..5d9bc76 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,9 @@ !/.gitignore !/README.md !/requirements.txt +!/.gitea** /flask/static/covers/** !/flask/static/covers/default.webp +/flask/config.py **__pycache__** \ No newline at end of file diff --git a/README.md b/README.md index 5203310..e084021 100644 --- a/README.md +++ b/README.md @@ -13,9 +13,14 @@ Install the dependencies: ```bash pip install -r requirements.txt ``` -Start the server: +Edit the configuration: ```bash cd flask +cp example.config.py config.py +$EDITOR config.py +``` +Start the server: +```bash python app.py ``` diff --git a/flask/app.py b/flask/app.py index 53ec682..3e33cf5 100644 --- a/flask/app.py +++ b/flask/app.py @@ -5,6 +5,8 @@ from hashlib import sha256 from uuid import uuid4 as uuid ## Import db class from func.py and initialise it from func import db +## import all config variables +from config import * db=db() db.startup() @@ -82,7 +84,7 @@ def loginpage(): return passhash # if passwords match, create session and return cookie if password.upper() == passhash.upper(): - lifetime=3000000 # lifetime of the sesskey in seconds + lifetime=RAR_COOKIE_LIFETIME # lifetime of the sesskey in seconds sesskey=str(uuid()) db.set_sesskey(sesskey,userid,lifetime) resp=setcookie("session",sesskey,lifetime) diff --git a/flask/example.config.py b/flask/example.config.py new file mode 100644 index 0000000..573c4c0 --- /dev/null +++ b/flask/example.config.py @@ -0,0 +1,6 @@ +MARIADB_USER="rar_index_app" +MARIADB_PASSWORD="password" +MARIADB_HOST="db" +MARIADB_DB="rar_index" + +RAR_COOKIE_LIFETIME=3000000 # cookie lifetime in seconds \ No newline at end of file diff --git a/flask/func.py b/flask/func.py index e31bf22..c9e3412 100644 --- a/flask/func.py +++ b/flask/func.py @@ -5,10 +5,10 @@ import time,re ## params populated with environment variables, defaults can be changed for a permanent solution conn_params={ - "user" : environ.get('MARIADB_USER') if environ.get('MARIADB_USER') else "rar_index_app", - "password" : environ.get('MARIADB_PASSWORD') if environ.get('MARIADB_PASSWORD') else "password", - "host" : environ.get('MARIADB_HOST') if environ.get('MARIADB_HOST') else "marcelsite.com", - "database" : environ.get('MARIADB_DB') if environ.get('MARIADB_DB') else "rar_index" + "user" : environ.get('MARIADB_USER') if environ.get('MARIADB_USER') else MARIADB_USER, + "password" : environ.get('MARIADB_PASSWORD') if environ.get('MARIADB_PASSWORD') else MARIADB_PASSWORD, + "host" : environ.get('MARIADB_HOST') if environ.get('MARIADB_HOST') else MARIADB_HOST, + "database" : environ.get('MARIADB_DB') if environ.get('MARIADB_DB') else MARIAD_DB } class db: