Skip to content

Commit

Permalink
add base_path
Browse files Browse the repository at this point in the history
improve dockerfile
  • Loading branch information
Nithador committed Apr 23, 2024
1 parent 849bd55 commit 5c2b1d0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
12 changes: 12 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions app/main.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
"_",
Expand Down
10 changes: 6 additions & 4 deletions app/view/honeybee/beekeeper_control.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down Expand Up @@ -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 ----
Expand Down

0 comments on commit 5c2b1d0

Please sign in to comment.