Added Dockerfile

The server can now be used on Docker
This commit is contained in:
Michael Rodin 2023-10-20 00:26:56 +02:00
parent edc3e55ead
commit 958c5db462
5 changed files with 67 additions and 5 deletions

17
Dockerfile Normal file
View file

@ -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" ]

View file

@ -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.

View file

@ -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:

4
flask/wsgi.py Normal file
View file

@ -0,0 +1,4 @@
from app import app
if __name__ == "__main__":
app.run()

View file

@ -1,3 +1,3 @@
flask
mariadb
hashlib
uwsgi