Shinyproxy: I can't edit navbar.html file when shinyproxy is in container

Created on 19 Mar 2020  ·  8Comments  ·  Source: openanalytics/shinyproxy

Hello!

I can't edit navbar.html when ShinyProxy is running as docker container. I tried to put the edited navbar.html in the templates/fragments directory and then copy to /opt/shinyproxy/templates, but still the changes don't show up when I restart the server.

For example, I would like to change "Sign Out" for "Sair".

image


Dockerfile:

FROM openjdk:8-jre

RUN mkdir -p /opt/shinyproxy/
RUN wget https://www.shinyproxy.io/downloads/shinyproxy-2.3.0.jar -O /opt/shinyproxy/shinyproxy.jar
COPY application.yml /opt/shinyproxy/application.yml
RUN mkdir templates
COPY templates/* /opt/shinyproxy/templates/
RUN mkdir templates/fragments
COPY templates/fragments/* /opt/shinyproxy/templates/fragments/

WORKDIR /opt/shinyproxy/
CMD ["java", "-jar", "/opt/shinyproxy/shinyproxy.jar"]


application.yml:

proxy:
title: LicitaR
landing-page: /
template-path: ./templates
port: 8080
authentication: simple
admin-groups: admins
users:

  • name: jack
    password: password
    groups: admins
  • name: jeff
    password: password
    docker:
    internal-networking: true
    container-network: dnv-net
    specs:
  • id: 01_hello
    display-name: Hello Application
    description: Application which demonstrates the basics of a Shiny app
    container-cmd: ["R", "-e", "shinyproxy::run_01_hello()"]
    container-image: openanalytics/shinyproxy-demo
    container-network: "${proxy.docker.container-network}"
  • id: euler
    display-name: Euler's number
    container-cmd: ["R", "-e", "shiny::runApp('/root/euler')"]
    container-image: euler-docker
    container-network: "${proxy.docker.container-network}"

logging:
file:
/log/shinyproxy.log


I don't know if i'm doing something wrong. Could you help me, please? Thank you.

Paulo

Most helpful comment

You should recreate your image.

BTW, you should not copy the files. Instead, you should make the folder as a volume. In this way, after changing the file, you only need to refresh the browser.

All 8 comments

You should recreate your image.

BTW, you should not copy the files. Instead, you should make the folder as a volume. In this way, after changing the file, you only need to refresh the browser.

@shrektan thank you for your reply.

  1. After the changes I recreated the image using sudo docker-compose build, but nothing changed. Is it right?

  2. About the folder as a volume, could you show me an example? I'm new user of ShinyProxy, so I'm a little bit lost.

Thank you.

Sorry, I don't have time to do this right now but I screenshot a production setup for you. It should be easy to understand.

The docker file

image

Docker compose YAML

image

Folder structure

image

@shrektan Thank you so much for your help.

1) I created the 'volumes' in the docker-compose.yml and changed the Dockerfile as you said. The files (admin, app, index, login) are used when the page is refreshed (thanks to you). But, the shinyproxy/application.yml are not used, even though I put sudo docker-compose build and the command sudo docker-compose up -d shinyproxy says "dnv_shinyproxy is up-to-date". So I left one CP in the Dockerfile regarding the application.yml. :(


docker-compose.yml

version: "3.6"
services:
shinyproxy:
image: datanovia/shinyproxy
container_name: dnv_shinyproxy
restart: on-failure
build: ./shinyproxy
networks:
- dnv-net
ports:
- 8080:8080
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
- "./shinyproxy-logs/server:/log"
- "./shinyproxy-logs/container:/container-logs"
- "./shinyproxy/application.yml:/opt/shinyproxy/application.yml"
- "./shinyproxy/templates/:/opt/shinyproxy/templates"
- "./shinyproxy/templates/fragments/navbar.html:/opt/shinyproxy/templates/fragments/navbar.html"
euler:
image: euler-docker
container_name: dnv_euler
build: ./shinyapps/euler-docker
networks:
- dnv-net

networks:
dnv-net:
name: dnv-net


Dockerfile

FROM openjdk:8-jre

RUN mkdir -p /opt/shinyproxy/
RUN wget https://www.shinyproxy.io/downloads/shinyproxy-2.3.0.jar -O /opt/shinyproxy/shinyproxy.jar
COPY application.yml /opt/shinyproxy/application.yml

WORKDIR /opt/shinyproxy/
CMD ["java", "-jar", "/opt/shinyproxy/shinyproxy.jar"]


application.yml

proxy:
title: LicitaR
landing-page: /
hide-navbar: false
template-path: ./templates/
port: 8080
authentication: simple
admin-groups: admins
users:

  • name: jack
    password: pass
    groups: admins
  • name: jeff
    password: pass
    docker:
    internal-networking: true
    container-network: dnv-net
    work-directory: /home/paulo/shinyproxy-config/
    specs:
  • id: 01_hello
    display-name: Hello Simple APP <3
    description: Application Shiny app
    container-cmd: ["R", "-e", "shinyproxy::run_01_hello()"]
    container-image: openanalytics/shinyproxy-demo
    container-network: "${proxy.docker.container-network}"
  • id: euler
    display-name: Euler's number
    container-cmd: ["R", "-e", "shiny::runApp('/root/euler')"]
    container-image: euler-docker
    container-network: "${proxy.docker.container-network}"

logging:
file:
/log/shinyproxy.log


2) I still can't change the navbar.html file. When I put template-path: ./templates/fragments It was possible, but this way the others files that I changed were not used (admin, app, index, login).


3) tree

image

@PauloJhonny

You can put the fragments inside of templates but you need to claim that in index.html or somewhere first (sorry, I don't remember the exact place).

If you don't know (or not very sure) what you are doing, you probably need to place the fragments folder under shinyproxy/. The reason is that you need to keep the same folder structure as shinyproxy it does unless you know how it works. You can find the default folder structure of shinyproxy here: https://github.com/openanalytics/shinyproxy/tree/master/src/main/resources

Well, I actually build a docker-compose example for you. See https://github.com/shrektan/shinyproxy-docker-compose-example. Hope this clarifies your confusion.

(Again, in this way, these template HTML files are hot-loaded. So you don't need to shutdown and restart the docker container again and again. Just edit, save and refresh the browser. This is a much simpler UI tweaking workflow.)

The screenshot of the example

image

@shrektan thank you so much. It really helped me.

It worked. I was putting the fragments folder in the wrong place (see the correct tree). All the files are hot-loaded now, except the application.yml. Thank youuu.

image

Good to hear that.

BTW, closing the issue will be good if you don't have further questions.

Thanks.

Thank you. :)

Was this page helpful?
0 / 5 - 0 ratings