Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

start server locally #26

Merged
merged 1 commit into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
Loading