Leprechault
Leprechault

Reputation: 1823

Dockerized R package don't find "hidden" Google Cloud SDK installation

I don't find Google Cloud SDK installed inside a dockerized R package (https://sen2r.ranghetti.info/articles/docker.html) in WLS2.

In my WLS2 console the gcloud is installed and active:

asantos@ASANTOS-DELL:~$ gcloud config configurations list
NAME     IS_ACTIVE  ACCOUNT                   PROJECT                COMPUTE_DEFAULT_ZONE  COMPUTE_DEFAULT_REGION
default  True       [email protected]  xxxxx-client-323918
asantos@ASANTOS-DELL:~$ pwd
/home/asantos
asantos@ASANTOS-DELL:~/.config$ ls
R  earthengine  gcloud  htop  matplotlib  rstudio
asantos@ASANTOS-DELL:~/.config$

But I try to run the docker using the directory(/home/asantos), destite gcloud is in \\wsl.localhost\Ubuntu-20.04\home\asantos\.config\gcloud:

docker run --rm -e PASSWORD=sen2r -e USERID=$(id -u) -v $(pwd):/home/asantos -p 8777:8787 ranghetti/sen2r

Inside the Rstudio:

localhost

My outputs is always:

Searching for a valid Google Cloud SDK installation...
Error: 
Google Cloud SDK was not found; press install it following the instructions at
https://cloud.google.com/sdk/docs/install or set an existing installation using function check_gcloud()
(eventually specifying the argument 'gsutil_dir' if the automatic check would fail).
In addition: Warning message:
In normalizePath(path, ...) : path[1]="": No such file or directory

Please, any help with it?

Upvotes: 1

Views: 218

Answers (1)

Nick ODell
Nick ODell

Reputation: 25220

You have two problems - first, you don't have the gcloud command line tool installed inside the container. Second, the ~/.config/gcloud directory is not showing up inside the container.

You can install the gcloud tool by writing a Dockerfile like this:

FROM ranghetti/sen2r:latest
RUN apt-get update \
 && apt-get install -y --no-install-recommends \
        apt-transport-https ca-certificates gnupg \
 && apt-get clean autoclean
RUN echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" > /etc/apt/sources.list.d/google-cloud-sdk.list \
 && curl -fSs https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add - \
 && apt-get update \
 && apt-get install google-cloud-sdk

This is all pretty much copied from the Google SDK documentation on how to install gcloud on Debian. (The image you're using is based on Debian.)

Once you have that Dockerfile, you can build it using this command:

docker build . -t sen2r-plus-gcloud

Once it's built, you can substitute the new image name, sen2r-plus-gcloud where you used ranghetti/sen2r before.

As for the second problem, with the config directory not showing up, I don't know what's causing the second problem.

Upvotes: 1

Related Questions