Hi all, I am hoping to access the hive mind to get some advice on working with Docker to deploy and R Shiny Flexdashboard. Everything is working fine locally, but containerising it has been giving me headaches for weeks. I'm all out of ideas so I'm coming here to try get some help!
Notes:
- I've made sure to download the base image
openanalytics/r-shiny
and also installed base R. - As part of my workflow, I ensured I am using the correct ARM64 architecture for my system
- My
Docker-Compose.yaml
has no issues:
version: '3.9'
services:
shiny:
build:
context: ./
container_name: forecast_dashboard
hostname: forecast_dashboard
restart: always
# the default port for Shiny apps
ports:
- 3838:3838
networks:
network
driver: bridge
- Which leads me to believe there is an error with my Dockerfile. I just cannot see what is the issue. The Docker container builds without problems via
docker-compose build
. However, when I try run it viadocker-compose up
, it tries to run app.R but tells me it cannot find Tidyverse. This is despite Tidyverse being successfully installed during the container build. Also despite Tidyverse being the 2nd library I am loading in my app.R file, which tells me the first library I am loading, tidymodels, is being installed and loaded correctly.
# Use an official R base image
FROM r-base:4.3.0
# Set the working directory
WORKDIR /app
# Set the DOCKER_DEFAULT_PLATFORM environment variable
ENV DOCKER_DEFAULT_PLATFORM linux/arm64
# Install system dependencies
RUN apt-get update && apt-get install -y \
libcurl4-openssl-dev \
libssl-dev \
libxml2-dev
# Install required R packages and their dependencies
RUN Rscript -e 'install.packages(c('devtools','shiny', 'shinyjs', 'plotly', 'reactable', 'bslib', 'modeltime', 'tidymodels', 'tidyverse', 'timetk', 'bigrquery'), repos = "https://cloud.r-project.org")'
# Copy the R.app file into the container
COPY app.R /app/app.R
COPY ui.Rmd /app/ui.Rmd
# Set the library path for R packages
RUN echo '.libPaths(c("/usr/local/lib/R/site-library", .libPaths()))' > /app/.Rprofile
# Set the entry point to run Rscript with the R.app file
ENTRYPOINT ["Rscript", "/app/app.R"]
Could anybody help me out? I have run out of ideas!