suntorytimed / resourcespace

Docker image for ResourceSpace based on ubuntu:latest including openCV, poppler, php8.1 and php-mysqlnd
European Union Public License 1.2
20 stars 11 forks source link

Binding Volumes On Host Not Working #9

Open thespecialbeast opened 1 year ago

thespecialbeast commented 1 year ago

I'm not having any success mapping the two volumes (filestore and include) to my host machine. The include folder has all of the expected files within the container, but when you try to map volumes on a host machine, nothing happens to the directories and when the container gets updated, all your files get lost.

suntorytimed commented 1 year ago

I haven't looked too deep into the issue with bind volumes yet. I remember that in the past it resulted in a HTTP 500. It could be a permission issue on the folders with the wrong UID/GID mapping. That's why I used named volumes in the example so far. Not sure what is the recommended way of handling UID/GID mappings of bind mounts in the container, but it is something I will have to look into.

suntorytimed commented 1 year ago

Maybe this helps to resolve the issue? https://stackoverflow.com/a/56844765

shufflerror commented 10 months ago

Is there any progress in mapping the UID and GID to the container?

suntorytimed commented 10 months ago

@shufflerror afaik there is nothing I can do about this in the general container build. Either the container is rebuilt with your personal UID and GID or you map it in the docker compose file or docker run (see my comment and link to Stackoverflow above)

shufflerror commented 10 months ago

@suntorytimed I meant it would be nice to have the UID and GID defined as ENV VARS, so everybody can set them as needed in their project. It is described in the last line of your link. "(or define UID and GID as environment variables)"

Hope I will find some spare time to figure it out by myself in the next weeks. I'm relative new to Docker and it's the first time I have to modify an image. Little holiday project.

Maybe something like this but with variables instead of arguments https://dev.to/izackv/running-a-docker-container-with-a-custom-non-root-user-syncing-host-and-container-permissions-26mb

Thanks for your answer.

Rukongai commented 10 months ago

Problem with bind mounts is that the expose the files from your machine to the docker, not the other way around. So you need to have the folder either links to another location in the docker volume, or set it up to propagate the files after the volume has been created.

I've been messing around with this and I think I have a working version on my repo.

I changed the dockerfile to install to /var/www/resourcespace instead of html, then mount the html folder, then the entrypoint script checks to see if config.php is present in the html folder. If not, it copies the contents over from the resourcespace folder - effectively giving you a "initialization"

I'm still messing around with it (i'm not an expert in the slightest) and I still need to manually do some things post install to make it all happy, but it's a start.

w84no1 commented 9 months ago

@Rukongai do you have this working. I was thinking about doing the same thing. You seem to be further along than me. I would love it if you shared your work. Thanks!

Rukongai commented 9 months ago

You can try using mine on dockerhub. I see that I was talking about manual steps but I can't remember what they were. I ended up not using resourcespace for my project

version: "2"
services:
  resourcespace:
    image: rukongai/resourcespace:latest
    restart: unless-stopped
    environment:
      - PUID=1000
      - PGID=1000
    depends_on:
      - resourcespace-db
    volumes:
      - /path/to/appdata/resourcespace/www/html:/var/www/html
    networks:
      - backend
      - frontend

  resourcespace-db:
    image: lscr.io/linuxserver/mariadb
    container_name: resourcespace-db
    environment:
      - PUID=1000
      - PGID=1000
      - MYSQL_ROOT_PASSWORD=supersecretpassword
      - TZ=America/Denver
      - MYSQL_DATABASE=resourcespace
      - MYSQL_USER=resourcespace
      - MYSQL_PASSWORD=supersecretpassword
    volumes:
      - resourcespace-db:/config
    restart: unless-stopped
    networks:
      - backend
      - frontend

volumes:
  resourcespace-db:
    driver: local

networks:
  frontend:
  backend: