diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..415a462 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +# start by pulling the python image +FROM python:3.11 + +# copy the requirements file into the image +COPY ./requirements.txt /app/requirements.txt + +# switch working directory +WORKDIR /app + +# install the dependencies and packages in the requirements file +RUN pip install -r requirements.txt + +# copy every content from the local file to the image +COPY ./flask/ /app + +# configure the container to run in an executed manner +ENTRYPOINT [ "uwsgi", "--socket=0.0.0.0:5000", "--protocol=http", "-w", "wsgi:app" ] \ No newline at end of file diff --git a/README.md b/README.md index e084021..bb78c7d 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,18 @@ # RAR-Index It's some project for my school which is supposed to index _rar_-archives and make them searchable over a very ugly web frontend. +## Features +- Add and delete archives + - edit their labels (as their owner) +- search through archives based on: + - Keywords + - Category +- log into a user account + ## Downloading ```bash -git clone https://git.marcelsite.com/marcel/rar-index -cd rar-index +git clone https://git.marcelsite.com/marcel/rar-index-py +cd rar-index-py ``` ## Usage @@ -23,9 +31,41 @@ Start the server: ```bash python app.py ``` +This will start the server in a development environment. The Docker image is built with uWSGI for production use. ### Docker -TBA +I recommend just using the provided package on this server: +```yml +version: "2.4" +services: + db: + image: mariadb:latest + environment: + - MARIADB_USER=rar_index_app + - MARIADB_PASSWORD=password + - MYSQL_ROOT_PASSWORD=secretadminpassword + volumes: + - db-data:/var/lib/mysql + restart: unless-stopped + + app: + image: git.marcelsite.com/marcel/rar-index-app + container_name: rar-index-app + environment: + - MARIADB_USER=rar_index_app + - MARIADB_HOST=db + - MARIADB_PASSWORD=password + depends_on: + - db + ports: + - 5000:5000 + restart: unless-stopped + +volumes: + db-data: + +``` +This will make the server accessible from anywhere over port 5000. ## Contributing I don't recommend wasting your time on this project. It is only created to get a (hopefully) good grade in school. \ No newline at end of file diff --git a/flask/func.py b/flask/func.py index c9e3412..63352a5 100644 --- a/flask/func.py +++ b/flask/func.py @@ -2,13 +2,14 @@ import mariadb as sql from os import environ import time,re +from config import * ## 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 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 + "database" : environ.get('MARIADB_DB') if environ.get('MARIADB_DB') else MARIADB_DB } class db: diff --git a/flask/wsgi.py b/flask/wsgi.py new file mode 100644 index 0000000..11e7de6 --- /dev/null +++ b/flask/wsgi.py @@ -0,0 +1,4 @@ +from app import app + +if __name__ == "__main__": + app.run() \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index f0b97de..50f7b51 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ flask mariadb -hashlib \ No newline at end of file +uwsgi \ No newline at end of file