Deployment

This page provides an overview of approaches to deploy RDepot.

It is recommended to have a look at the Architecture page first to familiarize yourself with the RDepot components and their role.

Docker

Images

OpenAnalytics-maintained docker images are available on docker hub:

The images are based on adoptopenjdk images.

Both RDepot images are available under several tagging strategies:

  • versioned (e.g. 1.7.0): Recommended for production.
  • snapshots (e.g. 1.8.0-SNAPSHOT): Bleeding edge. Not recommended for production.
  • latest: Most recent build. Not recommended for production.

Example (Docker Compose)

The following prerequisites are needed:

  • docker (https://www.docker.com/)

  • docker-compose (https://docs.docker.com/compose/)

    While not a strict requirement, docker-compose will help you better manage the multiple containers that are involved. This guide will continue to use docker-compose, but you should be able to convert the example to standard docker.

    (Install i.e. by issuing pip install docker-compose)

  • port 80 is not used (localhost, check for nginx or apache service)

An example docker-compose YAML file:

version: '3'
services:
  proxy:
    image: library/nginx:alpine
    container_name: oa-rdepot-proxy
    restart: unless-stopped
    volumes:
      - ./docker/proxy/nginx.conf:/etc/nginx/nginx.conf:ro
      - ./docker/proxy/sites-enabled/rdepot:/etc/nginx/sites-enabled/rdepot:ro
      - repository:/opt/rdepot/repo/:ro
      - logs:/var/log/nginx/
    ports:
      - 80:80
    depends_on:
      - app
      - repo
    networks:
      - oa-rdepot
  db:
    image: library/postgres:alpine
    restart: unless-stopped
    hostname: oa-rdepot-db
    container_name: oa-rdepot-db
    volumes:
      - ./docker/db/populate_database.sh:/docker-entrypoint-initdb.d/populate_database.sh:ro
      - ./docker/db/rdepot.sql:/opt/rdepot.sql:ro
    environment:
      - POSTGRES_DB=rdepot
      - POSTGRES_USER=rdepot
      - POSTGRES_PASSWORD=mysecretpassword
    networks:
      - oa-rdepot
  app:
    image: openanalytics/rdepot-app:1.7.0
    restart: unless-stopped
    hostname: oa-rdepot-app
    container_name: oa-rdepot-app
    entrypoint:  java -jar /opt/rdepot/rdepot.war
    volumes:
      - repositories:/opt/rdepot/repositories/
      - snapshots:/opt/rdepot/generated/
      - queue:/opt/rdepot/new/
      - ./docker/app/authentication.yml:/opt/rdepot/authentication.yml      
      - ./docker/app/application.yml:/opt/rdepot/application.yml
    networks:
      - oa-rdepot
    depends_on:
      - db
    environment:
      - DB_URL=jdbc:postgresql://oa-rdepot-db:5432/rdepot
      - DB_USERNAME=rdepot
      - DB_PASSWORD=mysecretpassword
    healthcheck:
      test: ["CMD-SHELL", "if [ \"$$(curl -I localhost:8080 2>/dev/null | grep HTTP/1.1 | cut -d\" \" -f2)\" != \"302\" ]; then exit 1; else exit 0; fi;"]
      interval: 10s
      timeout: 10s
      retries: 10
  repo:
    image: openanalytics/rdepot-repo:1.7.0
    restart: unless-stopped
    hostname: oa-rdepot-repo
    container_name: oa-rdepot-repo
    volumes:
      - repository:/opt/rdepot/
    networks:
      - oa-rdepot
networks:
  oa-rdepot:
    ipam:
      config:
        - subnet: 192.168.49.0/24
volumes:
  repository:
  repositories:
  snapshots:
  queue:
  logs:

The missing files (for volume mapping) can be found in our Git repository:

The final step is to launch the Docker containers using docker-compose:

docker-compose up -d

One can then go to http://localhost to log in.

There is an admin user with username einstein and password testpassword.
See authentication.yml for the included configuration which specifies the user credentials. One can override these parameters using environment variables.

To complete an end-to-end flow: R package to R Depot to Repository Server to R client, the following steps are needed:

  • create a repository with (or edit)
  • submit one or more packages to that repository via the R Depot web interface
  • publish the repository using the green button in the repositories view (if needed)
  • go to the published package page (repositories view, click repository name, click package name)
  • use the install URL shown on the published package page to install the package in R
    install.packages("somePackage", repos = c("http://localhost/repo/repositoryName", getOption()))
    

To (re)start with fresh database:

  • remove the containers via docker-compose down -v
  • start up again using docker-compose up -d

Kubernetes

Kustomize

Kustomize is a tool for template-free configuration of applications running in Kubernetes. It offers a purely declarative approach to configuration customization.

Base recipes and a number of overlays are available for RDepot here.

Bases

The recipes are tagged according to the compatible RDepot release version and should be stable to use as a remote base:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
  - github.com/openanalytics/rdepot-kubernetes/base/app-stateful?ref=1.7.0
  - github.com/openanalytics/rdepot-kubernetes/base/repo?ref=1.7.0

You can also clone the bases locally, copy the recipes or use a tool like kpt depending on the amount of independence you want to have w.r.t. the OpenAnalytics upstream.

Overlays

Next to the base recipes you can find a number of overlays which range from simple extensions on top of the base recipes to complete demo deployments. The example below uses one of these overlays.

Helm?

There are currently no plans to maintain RDepot helm charts from OpenAnalytics.

Example (Minikube)

The following prerequisites are needed:

  • kustomize (https://kustomize.io).

    The standalone kustomize binary is recommended as some features are used which are not available in the version included with kubectl

  • minikube (https://minikube.sigs.k8s.io/docs/start/)

    minikube is a distribution of Kubernetes that can easily run on a single machine with moderate resources.

To deploy the demo:

kubectl create namespace demo-rdepot
kustomize build github.com/openanalytics/rdepot-kubernetes/overlays/demo?ref=1.7.0 | kubectl apply -f -

The demo includes:

  • an instance of the RDepot repository server
  • an instance of RDepot manager, preconfigured with a demo repository on the repository server and protected with simple authentication
  • a single-node postgres deployment

All volumes are provided through the dynamic provisioning in minikube

You can port-forward the manager app:

kubectl -n demo-rdepot port-forward svc/rdepot-app 8080:80

and visit the app in your browser at http://localhost:8080 (login einstein/testpassword)

Similarly, you can port-forward the repository:

kubectl -n demo-rdepot port-forward svc/rdepot-repo 8081:80

and point your browser to http://localhost:8081/repo/demo to browse your uploaded packages.

You can tear down the demo with:

kubectl delete namespace demo-rdepot

Refer to the README for more info.

WAR & JAR

The latest versions of RDepot are available on our downloads page in WAR and JAR format.

This is currently not the recommended approach to deploy RDepot. This route is only relevant in the following cases:

  • you wish to develop and/or extend RDepot
  • you are not able to run docker on your platform of choice

Download both rdepot-app-1.7.0-application.war (sha256, md5) and rdepot-repo-1.7.0-application.jar (sha256, md5) and start them by executing java -jar rdepot-app-1.7.0-application.war and java -jar rdepot-repo-1.7.0-application.jar respectively.