linuxserver / docker-emulatorjs

Web based retro emulation frontend with rom scanning and automated art ingestion.
GNU General Public License v3.0
509 stars 51 forks source link

[Feature] Separate paths for data and roms so that the latter is readonly #62

Closed bphenriques closed 7 months ago

bphenriques commented 8 months ago

Hello,

Would like to mount the roms directory separate from the data directory as I would like emulatorjs to have readonly permissions to the roms:

    volumes:
      - "${DATA_DIR}/emulatorjs:/config"
      - "${GAMING_ROMS_DIR}:/data/roms:ro"

As I understand emulatorjs writes files next to the roms directory. In order to have this working, the roms directory needs to be configurable. E.g.,

    environment:
      - PUID=${PUID}
      - PGID=${PGID}
      - TZ=${TZ}
      - ROMS_PATH="/media/roms"
    volumes:
      - "${DATA_DIR}/emulatorjs:/config"
      - "${DATA_DIR}/emulatorjs:/data"
      - "${GAMING_ROMS_DIR}:/media/roms:ro"

Thank you!

If interested I can look into it if makes sense and there is interest :) I am sort-off new so I might be tackling the problem on the wrong way.

LinuxServer-CI commented 7 months ago

This issue has been automatically marked as stale because it has not had recent activity. This might be due to missing feedback from OP. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] commented 7 months ago

Thanks for opening your first issue here! Be sure to follow the relevant issue templates, or risk having this issue marked as invalid.

bphenriques commented 7 months ago

Thanks for opening your first issue here! Be sure to follow the relevant issue templates, or risk having this issue marked as invalid.

Should I open a new ticket following the template? I checked the template and fortunately it seems that I provide enough information

thelamer commented 7 months ago

No you have identified the problem properly just have not had time yet to bite this off I need to do some heavy upgrade testing to ensure I don't break a bunch of peoples stuff.

thelamer commented 7 months ago

@bphenriques can you test this image on your local machine and confirm: lspipepr/emulatorjs:amd64-1.8.3-pkg-10384e5e-dev-aab6d5e6ca153cca48eeb0355448e46e98a96345-pr-65

The new ro path for roms is /roms the usage is detailed in the readme:

Mounting in existing rom directories Read Only can be achieved by using a special root path /roms, For example for NES:

-v /path/to/nes/roms:/roms/nes:ro

You still need the data and config directories, but this isolates them down using a symlink so there are no upgrade pathing issues.

bphenriques commented 7 months ago

Thank you for looking at this!

Did a fresh install with that same approach and it worked: setup, play a game :+1:

While I did this, I remembered an pattern and re-did the same test:

  emulatorjs:
    image: lscr.io/linuxserver/emulatorjs:latest
    container_name: emulatorjs
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Etc/UTC
    volumes:
      - ./tmp/config:/config
      - ./tmp/data:/data
      - "${ROMS_DIR}/gba:/data/gba/roms:ro"
    ports:
      - "3000:3000"
      - "1300:80"
      - "4001:4001" #optional
    restart: unless-stopped

Since it works, you may not need to patch, perhaps we only need to document.

I am making assumption regarding the subdirectory and only that subdirectory is read-only. It did work using the same test plan above. Locally the roms directory is created and is empty, but the volume is actually mounted and the emulatiorjs has access to the roms.

bphenriques commented 7 months ago

Now, I am the opinion that data should be different from the roms directory (keep the medium, i.e., emulatorjs separate from the main content). Therefore I like your approach with the /roms, more explicit and does not require hacking with volume paths.

thelamer commented 7 months ago

Building now