Basic Single VM Deployment Instructions

Our deployment is on an Oracle Enterprise Linux 7 VM that is running docker engine.  We are currently running folio in 20 docker containers.  Okapi does not deploy any of the containers, everything is deployed by hand/manually.  Here is an overview of our deployment process:

  1. Docker - Install and configure docker.
  2. PostgreSQL - We have a postgresql container image.  (NOTE: Running postgresql in a container is not recommended for a production environment and is done here only as a proof of concept.) In this image we use a postgresql database dump from the "snapshot" vagrant VM to initialize the database.  We also add several postgresql users and roles that are necessary to get the databases up and running. The postgresql image is based upon this website.
  3. OKAPI - We have a custom image for okapi.  This image is based upon Wayne's documentation, and we build okapi from source using maven to build the code.  We point okapi at the postgresql container.
  4. Stripes - We have a custom image for stripes.  This image is also based upon Wayne's documentation, and we use the folio-testing-platform as our base to build stripes.  We serve up stripes using nginx.  Currently, we have to re-build this image each time the okapi external url changes.
  5. Create Tenant - Next we execute a shell script with curl commands to create a tenant within okapi and to enable the default okapi module. 

    #Create Tenant
    curl -i -w '\n' -X POST -H 'Content-type: application/json' \
    -d @tenant/tenant.json http://<okapi_extneral_url>:9130/_/proxy/tenants
    
    #Okapi internal module for the tenant
    curl -w '\n' -D - -X POST -H "Content-type: application/json" -d '{"id":"okapi"}' http://<okapi_extneral_url>:9130/_/proxy/tenants/diku/modules
  6. Dependencies - Either using a test instance of okapi or the current instance of okapi, we pull all of the registered modules from indexdata to okapi.  

    curl -w '\n' -D - -X POST -H "Content-type: application/json" -d '{"urls":["http://folio-registry.aws.indexdata.com"]}' http://<okapi_extneral_url>:9130/_/proxy/pull/modules


    We create an enable.json file (either edit one by hand or using Wayne's Pearl Script).  We then pass enable.json to install&simulate=true to determine what modules we need to enable/register (output to full-install.json).  

    curl -w '\n' -X POST -D - -H "Content-type: application/json" -d @enable.json -o full-install.json http://<okapi_extneral_url>:9130/_/proxy/tenants/diku/install?simulate=true
  7. Back End Modules - Using the information supplied in full-install.json, we find the necessary modules in dockerhub.com/folioci.  We spin up the backend module containers using docker commands and point them at the postgresql database container (approximately 17 containers).
  8. Okapi Scripts - Once the containers are up, we run a shell script to determine the docker ip addresses to use to register the containers with the okapi discovery service.  

    #Authtoken
    cat > deployment-descriptor-authtoken.json <<END
    {
      "srvcId" : "mod-authtoken-1.2.0-SNAPSHOT.15",
      "instId" : "mod-authtoken-1.2.0-SNAPSHOT.15",
      "url" : "http://$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' <mod-authtoken-container-name>):8081"
    }
    END

    We run another shell script to (a) register backend modules with okapi (b) deploy the modules to the okapi discovery service and (c) enable the modules for the tenant. It is important to do this in the correct order or some modules will not enable/register with okapi.  

    #Authtoken
    #Register
    curl -i -w '\n' -X POST -H 'Content-type: application/json' \
    -d @module-descriptors/module-descriptor-authtoken.json http://<okapi_extneral_url>:9130/_/proxy/modules
    
    #Deploy to discovery Service
    curl -i -w '\n' -X POST -H 'Content-type: application/json' \
    -d @deploy-descriptors/deployment-descriptor-authtoken.json http://<okapi_extneral_url>:9130/_/discovery/modules
    
    #Enable for tenant
    curl -i -w '\n' -X POST -H 'Content-type: application/json' \
    -d @tenant/enable-authtoken.json http://<okapi_extneral_url>:9130/_/proxy/tenants/diku/modules

    Lastly, we run a shell script to (a) register the front-end modules with okapi and (b) enable them for the tenant.

    #Checkin
    curl -i -w '\n' -X POST -H 'Content-type: application/json' \
    -d @stripes/ModuleDescriptors/checkin.json http://<okapi_extneral_url>:9130/_/proxy/modules
    
    curl -i -w '\n' -X POST -H 'Content-type: application/json' \
    -d @stripes/tenant/checkin.json http://<okapi_extneral_url>:9130/_/proxy/tenants/diku/modules
  9. Finished - You should now be able to point a browser at stripes and login.  (We have our stripes instance behind our load balancer).