diff --git a/Dockerfile b/Dockerfile index 5a0d2c0..ac146d3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,7 +29,7 @@ COPY ./ /opt/dockerfiles/ RUN R -e "remotes::install_local('/opt/dockerfiles', dependencies = TRUE)" # CMD or entrypoint for startup -CMD ["R", "-q", "--no-save", "-f", "/opt/dockerfiles/Dockerfiles/start.R"] +CMD ["R", "-q", "--no-save", "-f", "/opt/dockerfiles/startProduction.R"] # Expose the port EXPOSE 8000 \ No newline at end of file diff --git a/README.md b/README.md index 48bd346..980ac90 100644 --- a/README.md +++ b/README.md @@ -49,3 +49,12 @@ If there are new changes on the images or Dockerfiles: ```bash docker-compose build --no-cache && docker-compose up ``` + +## Development Notes: +While developing, you can skip rebuilding the docker container everytime. Instead you can run the server locally. Just run "Rscript startLocal.R" inside this directory. + +This will compile this Repository as a R Package and start the server. + +```bash +Rscript startLocal.R +``` \ No newline at end of file diff --git a/startLocal.R b/startLocal.R new file mode 100644 index 0000000..dc8adfa --- /dev/null +++ b/startLocal.R @@ -0,0 +1,19 @@ +# build and install package locally (use for development) +remotes::install_local("./", dependencies = TRUE, force = TRUE) + +# Start service +library(openeosits) + +aws.host <- Sys.getenv("AWSHOST") + +if (aws.host == "") { + aws.host <- NULL +} else { + message("AWS host port id is: ", aws.host) +} + + +config <- SessionConfig(api.port = 8000, host = "0.0.0.0", aws.ipv4 = aws.host) +config$workspace.path <- "/var/openeo/workspace" +createSessionInstance(config) +Session$startSession() diff --git a/Dockerfiles/start.R b/startProduction.R similarity index 66% rename from Dockerfiles/start.R rename to startProduction.R index 7298bdb..48ed6a7 100644 --- a/Dockerfiles/start.R +++ b/startProduction.R @@ -3,13 +3,13 @@ library(openeosits) aws.host <- Sys.getenv("AWSHOST") -if (aws.host == ""){ - aws.host = NULL -}else{ - message("AWS host port id is:", aws.host) +if (aws.host == "") { + aws.host <- NULL +} else { + message("AWS host port id is: ", aws.host) } config <- SessionConfig(api.port = 8000, host = "0.0.0.0", aws.ipv4 = aws.host) config$workspace.path <- "/var/openeo/workspace" createSessionInstance(config) -Session$startSession() \ No newline at end of file +Session$startSession()