diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 90f5fb8..0000000 --- a/Dockerfile +++ /dev/null @@ -1,87 +0,0 @@ -FROM ubuntu:focal -FROM opendatacube/geobase:wheels-3.0.4 as env_builder - -ARG py_env_path=/env - -# config rpy2 mode -ENV RPY2_CFFI_MODE=ABI - -# install required python libraries -RUN mkdir -p /conf -COPY requirements.txt /conf/ -RUN env-build-tool new /conf/requirements.txt ${py_env_path} /wheels - -# install ODC -FROM opendatacube/geobase:runner-3.0.4 -ARG py_env_path=/env - -COPY --chown=1000:100 --from=env_builder $py_env_path $py_env_path -COPY --from=env_builder /bin/tini /bin/tini - -RUN export GDAL_DATA=$(gdal-config --datadir) -ENV LC_ALL=C.UTF-8 \ - PATH="/env/bin:$PATH" - -RUN useradd -m -s /bin/bash -N jovyan -g 100 -u 1000 \ - && chown jovyan /home/jovyan \ - && addgroup jovyan staff - -# install R kernel -RUN apt-get update \ - && apt-get install -y --no-install-recommends \ - software-properties-common \ - dirmngr \ - ed \ - less \ - locales \ - vim-tiny \ - wget \ - ca-certificates \ - && add-apt-repository --enable-source --yes "ppa:marutter/rrutter4.0" \ - && add-apt-repository --enable-source --yes "ppa:c2d4u.team/c2d4u4.0+" - -## Configure default locale, see https://github.com/rocker-org/rocker/issues/19 -RUN echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen \ - && locale-gen en_US.utf8 \ - && /usr/sbin/update-locale LANG=en_US.UTF-8 - -ENV LC_ALL en_US.UTF-8 -ENV LANG en_US.UTF-8 - -## This was not needed before but we need it now -ENV DEBIAN_FRONTEND noninteractive - -## Otherwise timedatectl will get called which leads to 'no systemd' inside Docker -ENV TZ UTC - -# Now install R and littler, and create a link for littler in /usr/local/bin -# Default CRAN repo is now set by R itself, and littler knows about it too -# r-cran-docopt is not currently in c2d4u so we install from source -RUN apt-get update \ - && apt-get install -y --no-install-recommends \ - littler \ - r-base \ - r-base-dev \ - r-recommended \ - && ln -s /usr/lib/R/site-library/littler/examples/install.r /usr/local/bin/install.r \ - && ln -s /usr/lib/R/site-library/littler/examples/install2.r /usr/local/bin/install2.r \ - && ln -s /usr/lib/R/site-library/littler/examples/installGithub.r /usr/local/bin/installGithub.r \ - && ln -s /usr/lib/R/site-library/littler/examples/testInstalled.r /usr/local/bin/testInstalled.r \ - && install.r docopt \ - && rm -rf /tmp/downloaded_packages/ /tmp/*.rds \ - && rm -rf /var/lib/apt/lists/* - -RUN apt-get update&&apt-get install -y --no-install-recommends libudunits2-dev libgdal-dev libgeos-dev r-cran-reticulate #libproj-dev - -RUN R -e 'install.packages(c("IRkernel", "rgdal", "sf", "stars", "raster", "basemaps"))' -#, "raster", "sp", "sf", "stars", "basemaps", "mapview", "mapedit", "devtools", "usethis", "testthat", "roxygen2", "ggplot2"))' - -# configure R kernel for Jupyter -RUN R -e "IRkernel::installspec(user = FALSE)" - -USER jovyan -WORKDIR /notebooks - -ENTRYPOINT ["/bin/tini", "--"] - -CMD ["jupyter", "notebook", "--allow-root", "--ip='0.0.0.0'" "--NotebookApp.token='secretpassword'"] diff --git a/README.md b/README.md index 0b11289..5dc0f65 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,19 @@ # `odc_box` -This repository hosts all you need to install an *Open Data Cube* instance as a docker container that serves a Jupyter notebook environment running a Python kernel and an R kernel. It is based on the [Cube-in-a-box](https://github.com/opendatacube/cube-in-a-box) project. The changes and additions include (i) a revised `Dockerfile`, adding instructions to install R, its upstream dependencies and connect it with the Jupyter environment, (ii) helper scripts for quick re-deploys of the container environment, (iii) a revised `README.md` and (iv) additional Python dependencies. See the commit history for all changes to the original repository. +This repository hosts all you need to install an *Open Data Cube* instance as a docker container that serves a Jupyter notebook environment running a Python kernel and an R kernel. It is based on the [Cube-in-a-box](https://github.com/opendatacube/cube-in-a-box) project. + +## Additional features + +* an R kernel and its upstream dependencies, initialized to connect with the Jupyter environment, +* a pre-installed suite of R packages for spatial analysis as well as there system requirements +* helper scripts for quick starting, stoping and re-deploying of the container environment (see below), +* a revised `README.md` with installation instructions + +See the commit history for all changes to the original repository. ## Installation -Make sure to have [`docker`](https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository) and [`docker-compose`](https://docs.docker.com/compose/install/#install-compose-on-linux-systems) installed on your host system. +Make sure to have [`docker`](https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository) and [`docker-compose`](https://docs.docker.com/compose/install/#install-compose-on-linux-systems) installed on your host system. Depending on your host system and your `docker`/`docker_compose` installation, you might need `sudo` rights for the following steps. Clone this repository to a directory of your choice, e.g. using @@ -15,13 +24,13 @@ git clone https://github.com/16EAGLE/odc_box/ and `cd` into its main directory. To start the container (and build it the first time), run: ``` -sudo ./docker_start +./docker_start ``` To initialize the jupyter environment and pull Sentinel-2A example data, open a new shell and run: ``` -sudo ./docker_init +./docker_init ``` Wait for its completion. You may then now access your local Jupyter environment in a browser on your host machine under [http://localhost](http://localhost). Use the password `secretpassword` to authenticate. @@ -31,16 +40,16 @@ See the notebook `Sentinel_2.ipynb` for examples. Note that you can index additi To stop the container, from a shell other then the one the docker container is running in, run: ``` -sudo ./docker_stop +./docker_stop ``` To fully clean your docker environment from images pulled for `odc_box` and to allow a fresh re-deploy, run ``` -sudo ./docker_clean +./docker_clean ``` -before starting over. Note that with each re-deploy, a new docker volume is created containing your indexed data. You may want to prune your docker volumes from time to time, e.g. using `sudo docker volume rm $(sudo docker volume ls -q -f 'dangling=true')`. Note that this will remove **all** docker volumes, also those from other docker instances that might be running on your host system. +before starting over. Note that with each re-deploy, a new docker volume is created containing your indexed data. You may want to prune your docker volumes from time to time, e.g. using `docker volume rm $(docker volume ls -q -f 'dangling=true')`. Note that this will remove **all** docker volumes, also those from other docker instances that might be running on your host system. ## Troubleshooting @@ -50,12 +59,12 @@ before starting over. Note that with each re-deploy, a new docker volume is crea Error message: ``` -sudo ./docker_start +./docker_start #> ERROR: for postgres Cannot start service postgres: driver failed programming external connectivity on endpoint odc_box_postgres_1 (...): Error starting userland proxy: listen tcp4 0.0.0.0:5432: bind: address already in use ``` Reason: The default `postgres` port `5432` seems to be used by some service (maybe `postgres`?) running on your host system. -Solution: Check whether this is true by running `sudo lsof -i :5432`. You may want to kill the processes that are displayed using their associated PIDs with `kill `. +Solution: Check whether this is true by running `lsof -i :5432`. You may want to kill the processes that are displayed using their associated PIDs with `kill `. diff --git a/docker-compose-prod.yml b/docker-compose-prod.yml deleted file mode 100644 index 38d565e..0000000 --- a/docker-compose-prod.yml +++ /dev/null @@ -1,5 +0,0 @@ -version: '3' - -services: - jupyter: - image: opendatacube/cube-in-a-box:latest diff --git a/docker-compose.yml b/docker-compose.yml deleted file mode 100644 index b9fc799..0000000 --- a/docker-compose.yml +++ /dev/null @@ -1,29 +0,0 @@ -version: '3' - -services: - postgres: - image: postgis/postgis:10-2.5 - environment: - - POSTGRES_DB=opendatacube - - POSTGRES_PASSWORD=opendatacubepassword - - POSTGRES_USER=opendatacube - ports: - - 5432:5432 - restart: always - - jupyter: - build: . - environment: - - DB_HOSTNAME=postgres - - DB_USERNAME=opendatacube - - DB_PASSWORD=opendatacubepassword - - DB_DATABASE=opendatacube - - AWS_NO_SIGN_REQUEST=true - - STAC_API_URL=https://earth-search.aws.element84.com/v0/ - ports: - - "80:8888" - user: root - volumes: - - ./notebooks:/notebooks - restart: always - command: jupyter notebook --allow-root --ip="0.0.0.0" --NotebookApp.token='secretpassword' diff --git a/docker_clean b/docker_clean index 8316993..b769961 100755 --- a/docker_clean +++ b/docker_clean @@ -1,2 +1,3 @@ #!/bin/bash +docker volume rm $(docker volume ls -q -f 'dangling=true') docker-compose down -v --rmi all --remove-orphans \ No newline at end of file