Search code examples
rsqlitedockershinyproxy

database not stored on docker-image with shinyproxy


I have developed a solution and decided to use shinyproxy.

I have the following problem:

A user needs to capture data on the solution, which must be stored and updated on the database for all users accessing the solution, I used SQLite and with R for this.

Now when I log in and capture data, it saves, but when i log in with a different user I dont get to find the captured data.

The problem is that saving data doesnt seem to be saving on the docker image, why is this and how can I go about remedying it?

For problem testing purposes:

Solution link: https://xxasdfqexx.com

Data Capturer user:

username: xxxxx

password: Fxxxx

Admin user:

username: inxxx

password: prupxxxxx

Testing:

Inside the solution, if you go to the data management tab, data entry and then right click on an table and insert a new row, click save changes, it must safe new changes to the docker image but its only temporarily doing so, the other user cant see the changes made.


Solution

  • This is expected behavior. The SQLite DB is stored within the running container, not the image. It is therefore lost when the container is shut down. And shinyproxy starts a new container for every user. The general solution with docker is to use an external volume that is mounted into the running container and use that file/directory to store persistent data. Together with shinyproxy, you have to use docker-volumes, c.f. https://www.shinyproxy.io/configuration/#apps.

    Putting this together you can use in the shinyproxy config something like:

    apps:
      - name: ...
        docker-cmd: ...
        docker-image: ...
        docker-volumes: /some/local/path/:/mnt/persistent
    

    And in the shiny app something like:

    dbConnect(RSQLite::SQLite(), "/mnt/persistent/my-db.sqlite")