Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Step-by-step guide

...

Expand
titlePhase: Working with Docker image
  1. Build the Docker image inside of the module 

    Code Block
    docker build -t <name> <path>
    where <path> - location of *-fat.jar file and Dockerfile 

    Info
    titleinfo

    The command above will tag you image with default 'latest' tag.

    To change it use

    docker tag image <username>/<repository>:<tag>
    example
    docker tag d_notes<username>/<repository>:test


  2. Check local Docker images

    Code Block
    docker images

  3. Create an account in the Docker hub and then login in 

    Code Block
    docker login


  4. Publish the image with following command

    Code Block
    docker push username/repository:tag

    After successful push you will be able to see following

     

  5. Run Vagrant box

    Code Block
    vagrant up
    vagrant ssh


  6.  Navigate to Vagrant shared folder and pull Docker image

    Code Block
    cd /vagrant/.vagrant
    docker pull <user_name>/<repository>
    Example: docker pull b3946935/d_notes


  7. Find the Container Id of the module you want to replace

  8. Stop the Docker container

    Code Block
    docker stop <container_id>


...

Expand
titlePhase: Module deployment
  1. Publish the Module descriptor

    Code Block
    http://localhost:9130/_/proxy/modules


    Expand
    titlesample Module descriptor


    Code Block
    {
      "id": "mod-notes-2.1.1-SNAPSHOT",
      "name": "Notes",
      "requires": [
        {
          "id": "users",
          "version": "14.0 15.0"
        },
        {
          "id": "notify",
          "version": "1.1"
        }
      ],
      "provides": [
        {
          "id": "notes",
          "version": "1.0",
          "handlers": [
            {
              "methods": ["GET"],
              "pathPattern": "/notes",
              "permissionsRequired": ["notes.collection.get"],
              "permissionsDesired": ["notes.domain.*", "notes.domain.all"]
            },
            {
              "methods": ["GET"],
              "pathPattern": "/notes/natalia"
            },
            {
              "methods": ["POST"],
              "pathPattern": "/notes",
              "permissionsRequired": ["notes.item.post"],
              "permissionsDesired": ["notes.domain.*", "notes.domain.all"]
            },
            {
              "methods": ["GET"],
              "pathPattern": "/notes/_self",
              "permissionsRequired": ["notes.collection.get"],
              "permissionsDesired": ["notes.domain.*", "notes.domain.all"]
            },
            {
              "methods": ["GET"],
              "pathPattern": "/notes/{id}",
              "permissionsRequired": ["notes.item.get"],
              "permissionsDesired": ["notes.domain.*", "notes.domain.all"]
            },
            {
              "methods": ["PUT"],
              "pathPattern": "/notes/{id}",
              "permissionsRequired": ["notes.item.put"],
              "permissionsDesired": ["notes.domain.*", "notes.domain.all"]
            },
            {
              "methods": ["DELETE"],
              "pathPattern": "/notes/{id}",
              "permissionsRequired": ["notes.item.delete"],
              "permissionsDesired": ["notes.domain.*", "notes.domain.all"]
            }
          ]
        },
        {
          "id": "_tenant",
          "version": "1.0",
          "interfaceType": "system",
          "handlers": [
            {
              "methods": [
                "POST"
              ],
              "pathPattern": "/_/tenant"
            },
            {
              "methods": [
                "DELETE"
              ],
              "pathPattern": "/_/tenant"
            }
          ]
        }
      ],
      "permissionSets": [
        {
          "permissionName": "notes.collection.get",
          "displayName": "Notes - get notes collection",
          "description": "Get notes collection"
        },
        {
          "permissionName": "notes.item.get",
          "displayName": "Notes - get individual note from storage",
          "description": "Get individual note"
        },
        {
          "permissionName": "notes.item.post",
          "displayName": "Notes - create note",
          "description": "Create note"
        },
        {
          "permissionName": "notes.item.put",
          "displayName": "Notes - modify note",
          "description": "Modify note"
        },
        {
          "permissionName": "notes.item.delete",
          "displayName": "Notes - delete note",
          "description": "Delete note"
        },
        {
          "permissionName": "notes.domain.all",
          "displayName": "Notes - allow access to all domains",
          "description": "All domains"
        },
        {
          "permissionName": "notes.allops",
          "displayName": "Notes module - all CRUD permissions",
          "description": "Entire set of permissions needed to use the notes modules, but no domain permissions",
          "subPermissions": [
            "notes.collection.get",
            "notes.item.get",
            "notes.item.post",
            "notes.item.put",
            "notes.item.delete"
          ],
          "visible": false
        },
        {
          "permissionName": "notes.all",
          "displayName": "Notes module - all permissions and all domains",
          "description": "Entire set of permissions needed to use the notes modules on any domain",
          "subPermissions": [
            "notes.allops",
            "notes.domain.all"
          ],
          "visible": false
        }
      ]
    }
    
    
    



  2. Publish Deployments descriptor

    Code Block
    http://localhost:9130/_/discovery/modules


    Info

    The Deployment descriptor for Docker image is little different

    Code Block
    {
      "srvcId" : "mod-notes-2.1.1-SNAPSHOT",
      "nodeId" : "10.0.2.15",
      "descriptor" : {
        "dockerImage" : "b3946935/d_notes:latest",
        "dockerArgs" : {
          "HostConfig" : { "PortBindings": { "8081/tcp": [{ "HostPort": "%p" }] } }
        },
        "env" : [
              { "name" : "db.host", "value" : "10.0.2.15" },          
              { "name" : "db.port", "value" : "5432" },          
              { "name" : "db.username", "value" : "folio_admin" },          
              { "name" : "db.password", "value" : "folio_admin" },          
              { "name" : "db.database", "value" : "okapi_modules" },          
              { "name" : "db.maxPoolSize", "value" : "5" },          
              { "name" : "JAVA_OPTIONS", "value" : "-Xmx256m" }        
              ],
        "dockerPull" : false
          }
    }
    "nodeId" - IP of the running Vagrant instance. You may want to use the following command to find it. 
    Code Block
    vagrant ssh -c "ip address show eth0 | grep 'inet ' | sed -e 's/^.*inet //' -e 's/\/.*$//'"
    "dockerImage" - the source, for docker images built locally use name used for 'docker build -t <name> <path>' command

    Deployment descriptors of the modules included into Vagrant box are available in folder

    Code Block
    /etc/folio/deployment-descriptors



  3. Enable the module for the tenant

    Code Block
    http://localhost:9130/_/proxy/tenants/diku/modules

  4. Check the work of the new endpoint

...