Skip to content

Commit

Permalink
start server locally
Browse files Browse the repository at this point in the history
start server locally
  • Loading branch information
PondiB authored Dec 15, 2023
2 parents c552a97 + 696a05d commit fbb2af7
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
19 changes: 19 additions & 0 deletions startLocal.R
Original file line number Diff line number Diff line change
@@ -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()
10 changes: 5 additions & 5 deletions Dockerfiles/start.R → startProduction.R
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Session$startSession()

0 comments on commit fbb2af7

Please sign in to comment.