axewater / sharewarez

SharewareZ transforms any game folder into a dynamic, searchable and shareable library.
145 stars 1 forks source link

Feature Request: Unraid Container #4

Closed Ronald-Diemicke closed 8 months ago

Ronald-Diemicke commented 8 months ago

Cool idea... Would love to see a containerized version of this for Unraid!

axewater commented 8 months ago

the docker compose files are right there, including an image on docker hub if you use something like portainer, setup a 'stack', import the yml and .env file etc if your partition with docker images is small, there's a path where the images are stored you can mount outside of the container

Ronald-Diemicke commented 7 months ago

@axewater - can you point me toward the image on docker hub? I found two; one is outdated, the other doesn't seem to work?...

Ronald-Diemicke commented 7 months ago

nm - found kapitanczarnobrod/sharewarez:1.1.0 which seems to be yours... but getting this in unraid: /app/entrypoint.sh: 7: /app/entrypoint.sh: cannot open database_host: No such file /app/entrypoint.sh: 7: /app/entrypoint.sh: psql: not found Traceback (most recent call last): File "/app/docker_adduser.py", line 100, in <module> create_admin_user(DATABASE_URI) File "/app/docker_adduser.py", line 59, in create_admin_user if not check_postgres_port_open(parsed_uri.hostname, parsed_uri.port or 5432): File "/app/docker_adduser.py", line 47, in check_postgres_port_open with socket.create_connection((host, port), timeout=10): File "/usr/local/lib/python3.9/socket.py", line 823, in create_connection for res in getaddrinfo(host, port, 0, SOCK_STREAM): File "/usr/local/lib/python3.9/socket.py", line 954, in getaddrinfo for res in _socket.getaddrinfo(host, port, family, type, proto, flags): socket.gaierror: [Errno -5] No address associated with hostname Traceback (most recent call last): File "/app/app.py", line 4, in <module> app = create_app() File "/app/modules/__init__.py", line 60, in create_app check_postgres_port_open(parsed_url.hostname, 5432, 60, 2); File "/app/modules/__init__.py", line 41, in check_postgres_port_open with socket.create_connection((host, port), timeout=10): File "/usr/local/lib/python3.9/socket.py", line 823, in create_connection for res in getaddrinfo(host, port, 0, SOCK_STREAM): File "/usr/local/lib/python3.9/socket.py", line 954, in getaddrinfo for res in _socket.getaddrinfo(host, port, family, type, proto, flags): socket.gaierror: [Errno -5] No address associated with hostname SharewareZ container strapping boots PostgreSQL is now available.

Ronald-Diemicke commented 7 months ago

Looking at the code a bit and these errors... I suspect this is because it's expecting an external postgres database ... I was thinking this was built into the container, but I guess not.

axewater commented 7 months ago

Yes v1. 1.0 is the latest. The postgresql docker is included via the docker-compose.yml file. It's 2 images that work together and the compose file does that. Try it this way, first it clone the repo, docker-compose build docker-compose up

Ronald-Diemicke commented 7 months ago

Interesting... so unraid just you just point it at the dockerhub image and it goes...

I'll continue messing with it to see if I can get it to work.

Ronald-Diemicke commented 7 months ago

Also - would it be possible for you to tag the latest version with the 'latest' tag as well?

Ronald-Diemicke commented 7 months ago

So I tried this locally rather than through unraid:

@###-M1-MBP sharewarez % docker run tex8503/sharewarez

SharewareZ container strapping boots PostgreSQL is now available. /app/entrypoint.sh: 7: cannot open database_host: No such file Traceback (most recent call last): File "/app/docker_adduser.py", line 8, in from config import Config ModuleNotFoundError: No module named 'config' Traceback (most recent call last): File "/app/app.py", line 2, in from modules import create_app File "/app/modules/init.py", line 11, in from config import Config ModuleNotFoundError: No module named 'config'

@###-M1-MBP sharewarez % docker-compose build

WARN[0000] The "SHAREWAREZ_USERNAME" variable is not set. Defaulting to a blank string. WARN[0000] The "SHAREWAREZ_PASSWORD" variable is not set. Defaulting to a blank string. WARN[0000] The "POSTGRES_USER" variable is not set. Defaulting to a blank string. WARN[0000] The "POSTGRES_PASSWORD" variable is not set. Defaulting to a blank string. WARN[0000] The "POSTGRES_DB" variable is not set. Defaulting to a blank string. WARN[0000] The "DATA_FOLDER_WAREZ" variable is not set. Defaulting to a blank string. WARN[0000] The "DATA_FOLDER_IMAGEZ" variable is not set. Defaulting to a blank string. WARN[0000] The "POSTGRES_USER" variable is not set. Defaulting to a blank string. WARN[0000] The "POSTGRES_PASSWORD" variable is not set. Defaulting to a blank string. WARN[0000] The "POSTGRES_DB" variable is not set. Defaulting to a blank string. invalid spec: :/storage: empty section between colons

@###-M1-MBP sharewarez % docker-compose up

WARN[0000] The "SHAREWAREZ_USERNAME" variable is not set. Defaulting to a blank string. WARN[0000] The "SHAREWAREZ_PASSWORD" variable is not set. Defaulting to a blank string. WARN[0000] The "POSTGRES_USER" variable is not set. Defaulting to a blank string. WARN[0000] The "POSTGRES_PASSWORD" variable is not set. Defaulting to a blank string. WARN[0000] The "POSTGRES_DB" variable is not set. Defaulting to a blank string. WARN[0000] The "DATA_FOLDER_WAREZ" variable is not set. Defaulting to a blank string. WARN[0000] The "DATA_FOLDER_IMAGEZ" variable is not set. Defaulting to a blank string. WARN[0000] The "POSTGRES_USER" variable is not set. Defaulting to a blank string. WARN[0000] The "POSTGRES_PASSWORD" variable is not set. Defaulting to a blank string. WARN[0000] The "POSTGRES_DB" variable is not set. Defaulting to a blank string. invalid spec: :/storage: empty section between colons

Ronald-Diemicke commented 7 months ago

Note that to get this to even get to this point, I needed to update the dockerfile: from: FROM python:3.9-slim-buster

to: FROM python:latest

axewater commented 7 months ago

wow I dont understand why Unraid is so different. I have tested it on Windows, Ubuntu, QNAP NAS (a little more tricky, but works), using docker, without docker. Ronald if you are Dutch we can setup a remote session to debug.

Ronald-Diemicke commented 7 months ago

No worries... I think I figured our why this was being dumb... or rather why I was being dumb... I never updated the .env.example to .env

axewater commented 7 months ago

when in your last attempt, you ran the docker seperately, did you provide it an .env file ? there is a list of settings it needs, like where you are putting the database, and your IGDB API keys. when you run the app like a Python app, it uses config.py, when running a docker it will look for .env or the variables in your environment. all of this is on the readme. Just because you use the docker, doesnt mean it doesnt require any config.

axewater commented 7 months ago

we came to the same conclusion ! pls let me know if it all works on Unraid

Ronald-Diemicke commented 7 months ago

So - I'm getting closer....

in addition to updating the dockerfile; I packaged the dockerhub image with a .env and set the tag to 'latest'

https://hub.docker.com/repository/docker/tex8503/sharewarez/general

The reason this is important is that if an image isn't build specifically for unraid in the community applications store; you can import a dockerhub image and it tries to auto set it up.

However, to do this, it pulls the image first with the latest tag and looks for the .env to see what variables you should allow to be configured.

Pulling the dockerhub image I created is getting me a bit further in unraid, however, now I'm getting this in the log: exec /usr/bin/sh: exec format error

axewater commented 7 months ago

that error would point to an architechtural difference. meaning the image was meant for x86 and you have ARM processor or something else. In that case you need to build an image yourself.

git clone https://github.com/axewater/sharewarez cd sharewarez (create your .env file) python -m venv venv source venv/bin/activate

docker-compose build docker-compose up

that should install and run the SQL server and APP on your box and run them combined NB: its possible on your system the command is 'docker compose' without the - dash

Ronald-Diemicke commented 7 months ago

Ok - I was able to get docker-compose to work locally on my M1 Mac.

However, Unraid continues to balk at this and reading up a bit, it seems like it just doesn't like docker-compose either

But I suspect my image isn't happy because I'm on an M1 Mac and the unraid box is x86

axewater commented 7 months ago

hmm it might be a problem with one of the libraries, psycopg2-binary its a weird library .. I think its precompiled binary .. maybe if you find a Mac M1 version of that, pip install that snazzlejazzle

Ronald-Diemicke commented 7 months ago

Ok - I finally got this to work...

Here's what I did:

One quick additional note that it took me a hot min to figure out: compose manager by default wants to write it's files to /boot/config/plugins/compose.manager which seemed to be causing the DB an issue (I'm assuming permissions related since the DB got stuck in a restart loop since it couldn't create it's files) ; so I repointed this to /mnt/user/appdata/compose.manager - Postgres seemed a lot happier about this and it all just worked.