rommapp / romm

A beautiful, powerful, self-hosted rom manager
https://romm.app
GNU Affero General Public License v3.0
1.77k stars 80 forks source link

[Bug] installation failure #884

Closed iroQuai closed 3 months ago

iroQuai commented 3 months ago

RomM version I'm using the docker compose example from here.

Describe the bug Romm isn't starting properly.

To Reproduce This is my compose data

version: "3"
volumes:
  mysql_data: 
  romm_resources: 
  romm_redis_data: 
services:
  romm:
    image: rommapp/romm:latest
    container_name: romm
    restart: unless-stopped
    environment:
      - DB_HOST=romm-db
      - DB_NAME=romm # Should match MYSQL_DATABASE in mariadb
      - DB_USER=romm-user # Should match MYSQL_USER in mariadb
      - DB_PASSWD=${ROMM_DB_PW} # Should match MYSQL_PASSWORD in mariadb
      - IGDB_CLIENT_ID=${IGDB_ID} # Generate an ID and SECRET in IGDB
      - IGDB_CLIENT_SECRET=${IGDB_SECRET} # https://api-docs.igdb.com/#account-creation
      - MOBYGAMES_API_KEY=${MOBY_API} # https://www.mobygames.com/info/api/
      - ROMM_AUTH_SECRET_KEY=${ROMM_AUTH_KEY} # Generate a key with `openssl rand -hex 32`
      - ROMM_AUTH_USERNAME=stijn
      - ROMM_AUTH_PASSWORD=${ROMM_PW} # default: admin
    volumes:
      - romm_resources:/romm/resources # Resources fetched from IGDB (covers, screenshots, etc.)
      - romm_redis_data:/redis-data # Cached data for background tasks
      - /volume1/gaming/roms:/romm/library # Your game library
      - ./assets:/romm/assets # Uploaded saves, states, etc.
      - ./config:/romm/config # Path where config.yml is stored
    ports:
      - 7777:8080
    depends_on:
      - romm-db
  romm-db:
    image: mariadb:latest
    container_name: romm-db
    restart: unless-stopped
    environment:
      - MYSQL_ROOT_PASSWORD=mysql_root_pw123 # Use a unique, secure password
      - MYSQL_DATABASE=romm
      - MYSQL_USER=romm-user
      - MYSQL_PASSWORD=${ROMM_DB_PW}
    volumes:
      - mysql_data:/var/lib/mysql
networks: {}

I have an .env file with all mentioned ${STRINGS} filled in.

I use dockge to manage my stacks. Through dockge I created a stack (=folder) called "romm" and added above compose file and matching .env file. I also added a /config/ and an /assets/ folder in that /romm/ folder.

I pressed "start" which is the dockge equivalent of "docker compose up".

The mariaDB container just runs. The Romm container runs, but isn't visible.it exits with code 1, mentioning "something went horribly wrong with our database" and also something about sqlalchemy.exc.operationalError "host 192.168.112.3 is not allowed to connect to this MariaDB server.

After some time the Romm container tries to restart, over and over. Untill I stop it.

If needed I can try and discover how to get the full logs (probably not that hard just never did it before)

Expected behavior I expected both the mariadb container as the romm container to be created and running. I expected to be able to visit romm at the specified port

Additional context I'm on Synology DS220+ if that matters? I've manage around 10 other stacks that work fine this way. If it matters I can spin up the compose file via cli once too (but I can't believe that would matter)

gantoine commented 3 months ago

host 192.168.112.3 is not allowed to connect to this MariaDB server.

for some reason mariadb is rejecting connections from romm/the localhost. i asked chatgpt and it said to do this:

Configure MariaDB to Listen on All IP Addresses: You need to modify the MariaDB configuration to bind to all IP addresses. This can be done by creating a custom configuration file.

Create a custom configuration file my_custom.cnf with the following content:

[mysqld]
bind-address = 0.0.0.0

Then, mount this configuration file in your docker-compose.yml:

services:
  romm-db:
    image: mariadb:latest
    container_name: romm-db
    restart: unless-stopped
    environment:
      - MYSQL_ROOT_PASSWORD=mysql_root_pw123 # Use a unique, secure password
      - MYSQL_DATABASE=romm
      - MYSQL_USER=romm-user
      - MYSQL_PASSWORD=${ROMM_DB_PW}
    volumes:
      - mysql_data:/var/lib/mysql
      - ./my_custom.cnf:/etc/mysql/conf.d/my_custom.cnf  # Mount the custom configuration file
    ports:
      - "3306:3306"  # Expose port 3306

Grant User Permissions: Access the MariaDB container and grant the necessary permissions to the user from the specified IP address.

# Access the MariaDB container
docker exec -it romm-db bash

# Access MariaDB as root
mysql -u root -p

Inside the MariaDB shell, grant the necessary permissions:

GRANT ALL PRIVILEGES ON *.romm TO 'romm-user'@'192.168.112.3' IDENTIFIED BY 'your_password';
FLUSH PRIVILEGES;
iroQuai commented 3 months ago

This is way more complex as installing with docker should be... The IP varies from time to time too so that doesn't seem to help.

I was thinking, couldn't it have something to do with user- and group permissions? With other docker instances, most of the time problems like this disappear when I set those as environment data:

Environment:
- PGID=1000 # sometimes GROUP_ID
- PUID=1000 # sometimes USER_ID

Here is some info on that from Linux server.io: https://docs.linuxserver.io/general/understanding-puid-and-pgid/


so when I try to add PGID / PUID it still doesn't work. Same with user_id and group_id, but the errors with the last one seem different. (Still no connection to DB, but nothing about that sqlalchemy.exc.blabla

gantoine commented 3 months ago

PUID and GUID are exclusively supported by linuxserver images, we don't use them in romm. You can try setting user in the docker compose; i set romm to use user 1001, which is a special media user with full permissions on all my legally obtained linux ISOs.

user: 1001:1001

iroQuai commented 3 months ago

Okay thanks for explaining. Didnt really work though. Seems like I'm the only one reporting this problem? You have any idea what to do next? (Maybe I should follow your chatGPT advice but I'm really hoping on a more simple solution that also works out of the box when reinstalling via docker compose some other time)

Op ma 27 mei 2024 20:09 schreef Georges-Antoine Assi < @.***>:

PUID and GUID are exclusively supported by linuxserver images, we don't use them in romm. You can try setting user in the docker compose; i set romm to use user 1001, which is a special media user with full permissions on all my legally obtained linux ISOs.

user: 1001:1001

— Reply to this email directly, view it on GitHub https://github.com/rommapp/romm/issues/884#issuecomment-2133899076, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABVODUCXPPINMD6IUAIIZADZENZEVAVCNFSM6AAAAABIKAKWOKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMZTHA4TSMBXGY . You are receiving this because you authored the thread.Message ID: @.***>

iroQuai commented 3 months ago

I just noticed a reference to this issue in the logs: https://docs.sqlalchemy.org/en/20/errors.html#error-e3q8

gantoine commented 3 months ago

Exactly, it's not something under our control, but related to a specific of your setup. Unfortunately self-hosting is anything but simple when things go wrong, and you'll need to dig your heels into some of the complexities of docker/mariadb. At least this is a great way to learn!

iroQuai commented 3 months ago

I thought docker was invented to eliminate that exact problem; as long as you use docker, aren't containers the same on every machine?

gantoine commented 3 months ago

Sorta, but in your case, those instructions I posted above aren't related to the content of the containers themselves (the images that run on them), but the data and config, which will very with each machine. I would suggest following them to fix your issue, or just wiping your containers and volumes, and starting from scratch.

iroQuai commented 3 months ago

Aahhhh thanks for pointing that out! I'll try it when I find the time!

gantoine commented 3 months ago

Ok cool, I'm gonna close this issue since it's outside the scope of the code, but feel free to post updates here (or on discord).