From 5c2b1d05c6c082705d86652720989771fa36a772 Mon Sep 17 00:00:00 2001 From: Tomas Martinovic Date: Tue, 23 Apr 2024 11:17:36 +0200 Subject: [PATCH] add base_path improve dockerfile --- Dockerfile | 12 ++++++++++++ app/main.R | 6 ++++-- app/view/honeybee/beekeeper_control.R | 10 ++++++---- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7d7405f..61408ae 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,18 @@ FROM rocker/r-ver:4.3.3 RUN apt-get update -y && apt-get install -y make pandoc zlib1g-dev libcurl4-openssl-dev libssl-dev libicu-dev libpng-dev libgdal-dev gdal-bin libgeos-dev libproj-dev libsqlite3-dev git libudunits2-dev libxt6 && rm -rf /var/lib/apt/lists/* RUN mkdir -p /usr/local/lib/R/etc/ /usr/lib/R/etc/ +# Add Docker's official GPG key: +RUN apt-get update -y +RUN apt-get install ca-certificates curl -y +RUN install -m 0755 -d /etc/apt/keyrings +RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc +RUN chmod a+r /etc/apt/keyrings/docker.asc + +# Add the repository to Apt sources: +RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null +RUN apt-get update -y +RUN apt-get install -y docker-ce docker-ce-cli + RUN mkdir /.cache RUN chmod 777 /.cache . WORKDIR /code diff --git a/app/main.R b/app/main.R index ffb289a..ee78956 100644 --- a/app/main.R +++ b/app/main.R @@ -121,9 +121,11 @@ ui <- function(id) { server <- function(id) { shiny$moduleServer(id, function(input, output, session) { ns <- session$ns - + + base_path <- Sys.getenv("BASE_PATH") + session_dir <- file.path( - "shared", + paste0(base_path, "shared"), paste0( Sys.time() |> format(format = "%Y-%m-%d_%H-%M-%S"), "_", diff --git a/app/view/honeybee/beekeeper_control.R b/app/view/honeybee/beekeeper_control.R index daa0cc9..8963056 100644 --- a/app/view/honeybee/beekeeper_control.R +++ b/app/view/honeybee/beekeeper_control.R @@ -138,8 +138,8 @@ beekeeper_control_server <- function( # BEWARE !!!!!!!!!!!! # HARDCODED paths follows - - file_copy(file.path("shared", "uc-pollinators", "beehave", "Beehave_BeeMapp2015_Netlogo6version_PolygonAggregation.nlogo"), + + file_copy(file.path("app", "data", "honeybee", "Beehave_BeeMapp2015_Netlogo6version_PolygonAggregation.nlogo"), file.path(run_dir, "Beehave_BeeMapp2015_Netlogo6version_PolygonAggregation.nlogo"), overwrite = TRUE ) @@ -172,9 +172,11 @@ beekeeper_control_server <- function( file = locations_file, row.names = FALSE ) - # Run workflow ---- - docker_call <- paste0("shared/uc-pollinators/scripts/cloud/cloud_execution.sh shared/uc-pollinators/R ", run_dir, " shared/uc-pollinators/scripts/cloud") + # docker_call <- paste0("shared/uc-pollinators/scripts/cloud/cloud_execution.sh shared/uc-pollinators/R ", run_dir, " shared/uc-pollinators/scripts/cloud") + # Execute docker run, no socket should be needed for this + docker_call <- paste0('docker run -v "', Sys.getenv("SCRIPT_PATH"), '":"/scripts" -v "', Sys.getenv("R_PATH"), '":"/R" -v "', paste0(Sys.getenv("DATA_PATH"), stringr::str_remove(run_dir, paste0(Sys.getenv("HOME_PATH"), "shared"))), '":"/data" -e INPUT_DIR="/data" -e OUTPUT_DIR="/data/output" -e MAP="map.tif" -e LOOKUP_TABLE="lookup_table.csv" -e LOCATIONS="locations.csv" -e PARAMETERS="parameters.csv" -e MODEL_PATH="/data/Beehave_BeeMapp2015_Netlogo6version_PolygonAggregation.nlogo" -e CPUS="1" --cpus 1 --platform linux/amd64 --entrypoint /scripts/run_docker_flow.sh ghcr.io/biodt/beehave:0.3.7') + system(docker_call) # Update output data ----