Skip to content
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
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ docker/*
!docker/plumber.R
!docker/server.R
!docker/verify-r-deps.R
!docker/install-torch.R
tests/
*.Rproj
*.md
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/docker-compose-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ on:
jobs:
test:
runs-on: ubuntu-22.04
timeout-minutes: 360
steps:
- name: Check out code
uses: actions/checkout@v6

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4

- name: Login to Docker Hub
uses: docker/login-action@v4
with:
Expand All @@ -22,8 +26,11 @@ jobs:
with:
context: .
file: ./docker/Dockerfile
platforms: linux/amd64
push: true
tags: brianpondi/openeocraft:latest
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Run docker compose
run: docker compose up -d
12 changes: 7 additions & 5 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ RUN R -e "install.packages(c('devtools'), repos='https://cloud.r-project.org')"
RUN R -e "install.packages(c('gdalcubes','plumber','useful','s2','sf','rstac','geojsonsf', 'jsonlite', 'base64enc', 'ids', 'callr' , 'sits'), repos='https://cloud.r-project.org')"

# Install torch's Lantern library (required for deep learning models like TempCNN).
# TORCH_INSTALL=1 auto-confirms the interactive prompt.
# The second R call fails the build immediately if install_torch() left Lantern
# absent — without it, install failures are silent and only surface at runtime.
RUN TORCH_INSTALL=1 R -e "torch::install_torch()" && \
R -e "t <- torch::torch_tensor(1L); stopifnot(as.numeric(t) == 1L); message('Lantern OK')"
# TORCH_INSTALL=1 auto-confirms the interactive prompt; CUDA=cpu avoids GPU binary
# detection on build hosts without NVIDIA drivers. Retries + long timeout help CI
# survive slow downloads (~170 MB libtorch as of torch 0.17).
ENV TORCH_INSTALL=1
ENV CUDA=cpu
COPY docker/install-torch.R /tmp/install-torch.R
RUN Rscript /tmp/install-torch.R


# create directories
Expand Down
33 changes: 33 additions & 0 deletions docker/install-torch.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env Rscript
# Install torch Lantern during Docker build with retries for flaky CI downloads.

Sys.setenv(TORCH_INSTALL = "1", CUDA = "cpu")

if (!requireNamespace("torch", quietly = TRUE)) {
install.packages("torch", repos = "https://cloud.r-project.org")
}

max_attempts <- 3L
ok <- FALSE
for (attempt in seq_len(max_attempts)) {
ok <- tryCatch(
{
torch::install_torch(timeout = 1800)
t <- torch::torch_tensor(1L)
stopifnot(as.numeric(t) == 1L)
TRUE
},
error = function(e) {
message("install_torch attempt ", attempt, " failed: ", conditionMessage(e))
FALSE
}
)
if (ok) break
if (attempt < max_attempts) Sys.sleep(60)
}

if (!ok) {
stop("install_torch failed after ", max_attempts, " attempts", call. = FALSE)
}

message("Lantern OK")
Loading