shiny proxy deployment

I have this dockerfile

Step 1: Use an official R image as a base

FROM rocker/r-ver:4.3.1

Step 2: Install system dependencies and Python dependencies in a single RUN command

RUN apt-get update && apt-get install -y
libcurl4-openssl-dev
libssl-dev
libxml2-dev
zlib1g-dev
libpng-dev
python3-pip
python3-dev
python3-venv
&& rm -rf /var/lib/apt/lists/*

Step 3: Install the R package manager renv and PyArmor in the same RUN command

RUN R -e “install.packages(‘renv’)” &&
pip install pyarmor

Step 4: Set the working directory inside the container to /app

WORKDIR /app

Step 5: Copy only necessary files (e.g., renv.lock and application files)

COPY renv.lock /app/
COPY . /app/

Step 6: Install R dependencies using renv (from renv.lock)

RUN R -e “renv::restore()”

Step 7: Set the environment variable to use the Python virtual environment

ENV PATH=“/app/venv/bin:$PATH”

Step 8: Register PyArmor and obfuscate the AnomalyDragon.py file (combine into fewer layers)

COPY pyarmor-regfile-5224.zip /app/
RUN pyarmor reg -p /app/pyarmor-regfile-5224.zip &&
pyarmor gen -r AnomalyDragon.py &&
rm -rf AnomalyDragon.py

Step 9: Expose port 3838 for Shiny app

EXPOSE 8080

Step 10: Define the command to run your Shiny app

CMD [“R”, “-e”, “shiny::runApp(‘/app’, port = 8080, host = ‘0.0.0.0’)”]
and running the conatiner through
discretekernel@TestServer:~/Latest_version_24Jun2024$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c6bafb99698d anomalydragon:v1 “R -e 'shiny::runApp…” 18 minutes ago Up 18 minutes 0.0.0.0:3838->3838/tcp, :::3838->3838/tcp anomaly_cont

and I am able to access the application through IP:3838 but when i was trying to run the shinyproxy its providing the error -ntainer unresponsive, trying again (17/20): http://e342ac3f3551:3838
2024-11-16T07:14:18.178Z WARN 181472 — [ProxyService-16] e.o.shinyproxy.ShinyProxyTestStrategy : [user=admin proxyId=9880533e-b1f5-4112-b17e-4d5b299c3cbd specId=Anomalt Dragon App] Container unresponsive, trying again (18/20): http://e342ac3f3551:3838
2024-11-16T07:14:20.183Z WARN 181472 — [ProxyService-16] e.o.shinyproxy.ShinyProxyTestStrategy : [user=admin proxyId=9880533e-b1f5-4112-b17e-4d5b299c3cbd specId=Anomalt Dragon App] Container unresponsive, trying again (19/20): http://e342ac3f3551:3838
2024-11-16T07:14:20.210Z WARN 181472 — [ProxyService-16] e.o.containerproxy.service.ProxyService : [user=admin proxyId=9880533e-b1f5-4112-b17e-4d5b299c3cbd specId=Anomalt Dragon App] Any possible answers could be appriciated

In the Dockerfile, what happens if you change port = 8080 to port = 3838?

ShinyProxy expects the container to listen on port 3838.

1 Like