Phalcode / gamevault-backend

Backend for the self-hosted gaming platform for drm-free games
https://gamevau.lt
Other
156 stars 13 forks source link

ARM64 - docker container crashes #272

Closed LoganJFisher closed 3 months ago

LoganJFisher commented 3 months ago

Describe the bug Docker container crashes

To Reproduce Steps to reproduce the behavior:

  1. Download the phalcode/gamevault-backend image
  2. Create a container for that image (the only changes I made were to make it auto-restart and to set a local port number)
  3. Run container
  4. Container crashes a few seconds later

Expected behavior I expect the container to run successfully.

Screenshots If applicable, add screenshots to help explain your problem. tco14p0

Desktop (please complete the following information):

Alfagun74 commented 3 months ago

Hey @LoganJFisher,

Just starting the Container isn't enough for GameVault to work properly because it needs a database. It seems like your Container has Postgres configured, but it can't connect to your Postgres database server. Could you please share your configuration files with me?

Alfagun74 commented 3 months ago

Also see: https://gamevau.lt/docs/server-docs/setup/docker-compose#step-1-creating-a-docker-compose-file

Or, if you don't want to use postgres: https://gamevau.lt/docs/server-docs/setup/docker-compose#alternative-step-1-running-without-a-postgresql-database

LoganJFisher commented 3 months ago

Would it be possible for you to add setup instructions for Synology Container Manager? It uses a GUI instead of being command line, so I'm not entirely sure how to use the instructions you have provided there.

I don't have Postgres set up (and have struggled to figure it out), but I'm not strictly opposed to using it.

Alfagun74 commented 3 months ago

@LoganJFisher I understand your perspective and thanks for using GameVault in advance.

I haven't delved into the Synology Container Manager extensively, so initially, I didn't find an apparent way to easily publish a one-click app template or anything similar for it. However, it seems like it's essentially a frontend for Docker Compose. In this case, you can simply replicate the example docker-compose file available at here

Though I haven't personally utilized Synology Container Manager, I can attempt to provide a brief written guide based on my understanding, primarily referencing this resource. Please bear with me if there are any discrepancies:

  1. Begin by establishing folders for the containers to utilize. Navigate to File Station and create the following directories:

    • /docker/projects/gamevault-compose
    • /docker/gamevault
    • /docker/gamevault/files
    • /docker/gamevault/images
    • /docker/gamevault/database
  2. Next, set up a 'Project' in Container Manager. Access Container Manager, click on 'Project,' and then click 'Create' on the right-hand side. Fill in the following details:

    • Project Name: gamevault
    • Path: /docker/projects/gamevault-compose
    • Source: Select 'Create docker-compose.yml'
  3. Copy and paste the following code into the editor:

version: "3.8"
services:
  gamevault-backend:
    image: phalcode/gamevault-backend:latest
    restart: unless-stopped
    environment:
      DB_HOST: db
      DB_USERNAME: gamevault
      DB_PASSWORD: YOURDATABASEPASSWORD # Enter a secure password here
      # Uncomment and insert your RAWG API Key here if you have one (http://rawg.io/login?forward=developer)
      # RAWG_API_KEY: YOURAPIKEYHERE
    volumes:
      - /volume1/docker/gamevault/files:/files
      - /volume1/docker/gamevault/images:/images
    ports:
      - 8080:8080/tcp #Change the left one if you want
  db:
    image: postgres:16
    restart: unless-stopped
    environment:
      POSTGRES_USER: gamevault
      POSTGRES_PASSWORD: YOURDATABASEPASSWORD # Enter the same secure password from above password here
      POSTGRES_DB: gamevault
    volumes:
      - /volume1/docker/gamevault/database:/var/lib/postgresql/data

These settings should be sufficient to get the application up and running.

  1. You should now be able to access the web interface via your NAS's IP address followed by port 8080. image

  2. If you wish to make the application accessible outside your LAN, you'll need to configure reverse proxy settings and possibly adjust firewall rules. Refer to guides similar to https://drfrankenstein.co.uk/jellyseerr-in-container-manager-on-a-synology-nas/ for detailed instructions.

In general, you can often apply these guides to most Docker services, as the core concepts remain consistent (i.e., utilizing a compose file). It's advisable to read through the referenced guide as well, as it provides clearer explanations.

If this guide works for you, tell me so i can add it to our documentation :)

Alfagun74 commented 3 months ago

documented in https://gamevau.lt/docs/server-docs/setup/synology-container-manager

LoganJFisher commented 3 months ago

It works! Thank you.

Also thanks for the introduction to Projects. I had been meaning to figure out what that was all about. I had been using the GUI to go direct from image to container instead before.

Alfagun74 commented 3 months ago

I'm glad I could help. I've also added a role for Synology users on our Discord server. If you'd like to be my guest and be the first to use it, should any other users have questions regarding that platform, I would be glad if you joined. We aim to officially support Synology as a platform.

LoganJFisher commented 3 months ago

Is it possible to, instead of putting games in "/volume1/docker/gamevault/files", put them in "/volume1/Media/Games"?

I've tried just changing the volume, but games then aren't actually being detected.

This would be a preference due to the nature of my organization system.

Alfagun74 commented 3 months ago

I understand your issue. As I mentioned, I'm not deeply familiar with Synology specifics, but from Docker's perspective, technically, a volume mapping like - /volume1/Media/Games:/files should work fine. Make sure to run Action -> Restart so the configuration actually gets applied.

The reason why your container might not be detecting games could also be due to linux file system permissions. By default, GameVault runs on a non-root user (usually 1000:1000) for security reasons, so this user needs to have read permissions for the specified folder. For instance, if your host-linux-user has UID 1234 and GID 1234 and owns /volume1/Media/Games exclusively on your host system, you'll need to utilize the environment variables PGID=1234 and PUID=1234 in our image to grant GameVault the necessary permissions to read that folder.

You can also test if this is the issue by running GameVault as root user once and seeing if it then sees the files (root usually has PUID and PGID 0).

As for whether Synology restricts the volume scope to /volume1/docker, I'm not certain, but it seems unlikely. As mentioned it only looks like a docker-compose frontend using the "Project" feature.

LoganJFisher commented 3 months ago

That sounds like the same cause of this other issue I'm having. I'm not sure how to actually go about solving this. I'll do some reading and report back if I figure it out.

LoganJFisher commented 3 months ago

Okay, so I SSH'd into my NAS then did the command "id". I received "uid=1026(Logan) gid=100(users) groups=100(users),101(administrators)

I added the following environment variables for gamevault-backend: PGID: 100 (also tried it with 101) PUID: 1026

As well as changing the first volume to: /volume1/Media/Games:/files and the left port value and both of the passwords to the same custom password.

With those changes, it just seems to crash. :(

Tried again with both PUID and PGID as 0 as you suggested, and that works. So... is it really that bad of a security issue to just leave it on that? For the record, it also solved the other issue that I linked.

Alfagun74 commented 3 months ago

To understand why the gamevault-backend docker container is crashing, check its log. To find the Docker container, use the command docker ps -a in the terminal. This will list all running containers. Look for the container running the gamevault-backend image.

To read the logs, you can use the docker logs [container_id] command. Replace [container_id] with the ID of the gamevault-backends container. This will display the logs, helping you understand why it's crashing and if it is due to other reasons or a permissions issue.

If the problem is because of permissions, it's not directly related to gamevault but to how your server controls access to files. Here's what you can do:

Setting PUID and PGID to 0 (root user) grants the container elevated privileges. If you can't bother you can do it, be fine and probably won't ever hear from this again, but personally i'd try to fix the permissions on your setup.

To do so, first, find out who can access your folder. Use the "ls" command in the terminal. cd to your games folder (like /volume1/Media/Games) and run ls -lan. This command will show you who can read, write, and execute files in that folder.

For example:

total 20
drwxr-xr-x 2 1001 1001 4096 Apr  4 10:00 1001 1001 .
drwxr-xr-x 7 1001 1001 4096 Apr  4 10:00 1001 1001 ..
-rw-r--r-- 1 1001 1001 1024 Apr  4 09:30 1001 1001 file1.txt
-rw-r--r-- 1 1000 1000 2048 Apr  4 08:45 1000 1001 file2.txt

This shows that the current directory (.) is owned by user 1001 and group id 1001.

In your case, it might say something like:

drwxr-xr-x 2 1027 100 4096 Apr  4 10:00 1027 100 .

It also shows that the user owning the directory has read, write, and execute permissions for this directory. (drwxr-xr-x)

So, changing the PUID of gamevault to 1027 should give it read access to this directory and its files. You might not even need to change the PGID.

If the contents of the directory don't matter for permissions, you can also opt to just give all users read access to it by running "chmod o+r /volume1/Media/Games". But remember, this won't be enough for images, as they need write permissions too (chmod o+rw).

More information about linux file systems permissions can be found here: https://www.redhat.com/sysadmin/linux-file-permissions-explained

Does this solve #274 and this for you?

LoganJFisher commented 3 months ago

Thanks. Yes, both this and #274 are now solved.