Assumptions

This guide assumes the following:

  • You have a Linux virtual machine where you are currently able to build the appc code
  • Your virtual machine should have adequate resources to run the appc Docker images
    • The Docker images can run in a virtual machine with 4GB of ram, but if you are also running Eclipse, it might be a good idea to configure 6GB or more
    • You should give the virtual machine at least 2, possibly 3 or 4 processor cores
    • Some of the steps in this guide may only work on newer versions of Linux. In this case, you may see a section in red which has steps to use for an older version.

Where to install Docker

You can either run Docker on the same VM that you are using for maven and other development work, or you can install Docker in its own VM. There is less network configuration to be done if Docker is installed in the same VM as your maven builds. In this guide, we will look at installing Docker in the same VM that you are using for builds.


Installing Docker Services

The Docker service is installed on Linux from the package manager. It is available for most Linux distributions.

Install on Ubuntu: sudo apt-get install docker.io

Install on Centos/Redhat: sudo yum install docker


Make sure Docker is set to start

sudo systemctl enable docker

sudo systemctl start docker

For older Linux versions (Ubuntu 1404):

sudo service docker start


Allow Docker to run without root

Note: This could be considered a security risk because your account will basically have root access when it’s in the docker group

  1. sudo groupadd docker
  2. sudo usermod -aG docker $USER
  3. sudo shutdown now -r

Test Docker install

You can test your install by running docker version


Setup proxy server for Docker

  1. Create a new directory for Docker service: sudo mkdir /etc/systemd/system/docker.service.d
  2. Create a new file in the new directory called “http-proxy.conf” with the following contents:


[Service]
Environment=”HTTP_PROXY=<put proxy address here>/”


  1. Reload Docker
    1. sudo systemctl daemon-reload
    2. sudo systemctl restart docker

For Older Linux (Ubuntu 1404):

  1. Edit the file “/etc/default/docker”
  2. Uncomment the line that begins with “export http_proxy”
  3. Replace the proxy address on the same line with the address of your proxy server
  4. Restart Docker: sudo service docker restart

Installing docker-compose

We normally use the docker-compose utility to bring up the appc Docker images.

It can be installed with: sudo apt-get install docker-compose

Depending on your Linux version and repository setup, docker-compose may not be available from the package manager.

  • Python pip can also be used to install docker compose: sudo pip install docker-compose
  • If pip is not installed, it should be able to be installed with: sudo apt-get install python-pip
  • The full install guide for docker-compose can be found on the Docker website: https://docs.docker.com/compose/install/


Preparing for Docker Build in Maven

You need to make sure that you have an entry in your maven “settings.xml” file for your local maven repository. This way, when you run the Docker build, it will be able to download the appc installers from your local computer instead of going out to nexus server.

  1. By default, your maven settings file will be in your Linux home folder, in the .m2 folder (~/.m2/settings.xml)
  2. You’ll want to add a repository entry pointing to your local .m2/repository folder
  3. The local repository entry looks like the following, it should go in the <repositories> tag in the settings file. You need to put your Linux user id in the placeholder.


        <repository>
          <id>local-maven</id>
          <name>local-maven</name>
          <url>file:///home/<Linux user id>/.m2/repository</url>
          <releases>
            <enabled>false</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>local-maven</id>
          <name>local-maven</name>
          <url>file:///home/<Linux user id>/.m2/repository</url>
          <releases>
            <enabled>false</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </pluginRepository>


Cloning the appc deployment project

The appc deployment project contains the maven files which will build the Docker image.

Clone this repository. (git clone https://gerrit.onap.org/r/appc/deployment)


Downloading the pre-requisite Docker images

Our appc image is based on the ccsdk odlsli Docker image. So we need to download this before building the appc Docker image.

  1. First, you need to login Docker to the onap repository
    1. docker login nexus3.onap.org:10001
    2. Use your Linux Foundation credentials for the login
    3. Note: It appears that if you guess your password too many times, you will be locked out.
    4. Now we pull down the image
      1. At the time of this writing, the latest version of the ccsdk-odlsli-image is “v0.1.0”, but this could change in the future
      2. Pull the image with: docker pull nexus3.onap.org:10001/onap/ccsdk-odlsli-alpine-image:0.4.1 (For Dublin Release)
      3. Once it is done, we need to tag this image with the correct name that the appc build will be expecting: docker tag nexus3.onap.org:10001/onap/ccsdk-odlsli-alpine-image:0.4.1 onap/ccsdk-odlsli-alpine-image:0.4.1

Building with Maven on the command line

  1. The first step is to build the main appc project.
    1. This must be done on the same system that you will be building the Docker image on
    2. Go to your appc folder in a terminal
    3. Run mvn clean install
  2. Once this has completed, we will do a Docker build on the deployment project
    1. Go to your deployment project folder in a terminal
    2. mvn clean install -P docker

Checking that the new Docker image was created

The command docker images will show all the Docker images that you have on your system. You should see an image called “onap/appc-image” that was created recently (when you ran the build).


Starting the new Docker image

Note: Starting up the Docker containers from behind a proxy server usually does not work. We have had several experimental methods to make it work, but none have proven to be reliable.

  1. By default, the docker-compose command will use the “docker-compose.yml” file from the current directory that you run the command from as its configuration.
  2. Open a terminal window in the “docker-compose” directory of the appc deployment git repository that you cloned earlier
  3. We want to slightly modify the docker-compose.yml file in this directory
    1. In the file, you will see a “dgbuilder:” line
    2. Remove this line and everything below it and save the file.
    3. Note: If you plan to use the dg-builder, you will want to skip this step. But, if you don’t plan to use it, it will save time and memory to remove it
  4. From the same directory containing the docker-compose.yml file, run the command docker-compose up -d
    1. This will create and start up the appc Docker containers
  5. You can run the docker-compose logs command to see the startup log.
    1. Once the log displays the Opendaylight logo, you know startup is complete. It will take a few minutes.


Opening the Opendaylight api doc explorer

  1. From a browser on the same VM where you have Docker running:
  2. Go to http://localhost:8282/apidoc/explorer/index.html
  3. The username is "admin", password is "Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U"


Commands while running the Docker image

docker-compose logs

Shows the statup log for the containers. This is a good way to check if startup is complete.

docker ps

Shows all running Docker containers

docker ps -a

Shows all running and stopped Docker containers

docker stop <container name or id>

Stops a running Docker container

docker rm -v <container name or id>

Deletes a Docker container and its associated volume (does not delete the Docker image that was used to bring up the container)

docker ps | while read a b c d e f g; do docker stop $a; doneThis will stop all running Docker containers
docker ps -a | while read a b c d e f g; do docker rm -v $a; doneThis will delete all created Docker containers (will not delete the Docker image files)

docker exec -it appc_controller_container bash

Opens the bash shell in the running appc Docker container. The exit command will allow you to leave the Docker container.

docker exec -it appc_controller_container /opt/opendaylight/current/bin/client -u karaf

Directly opens the opendaylight console that is running in the Docker container

docker images

List all of the Docker images that are on your system. Shows their name, version, id, size, and date.

docker rmi -f <docker image id>

Delete the Docker image off your system with the given image id


Accessing the MySQL database Docker container

Once the Docker containers are running, you can directly access the mysql database with this command: docker exec -it sdnc_db_container mysql -uroot -popenECOMP1.0

  • No labels

16 Comments

  1. Hi Patrick Brady What does your full settings.xml look like?  I am using the one found here: https://wiki.onap.org/download/attachments/15997820/settings.xml?version=1&modificationDate=1506156303000&api=v2 with a local repo added as its own profile and when I follow the build instructions above, the resulting docker image does not include my locally built jars/zips but the ones it downloads from nexus.

    Also, as of today my maven build on amsterdam 1.2.1-SNAPSHOT started failing in the IaaS Adapter - bundle.  Very strange that it can no longer pick up the org.mockito dependency. I worked around it by adding that depenency to the pom of that project.  No clue what is going on here as it has happened in multiple environments (mac laptop, ubuntu vm).  Has this happened to you before?

    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:testCompile (default-testCompile) on project appc-iaas-adapter-bundle: Compilation failure: Compilation failure:
    [ERROR] /Users/mkhinda/appc/appc/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestServiceCatalog.java:[42,18] error: package org.mockito does not exist
    [ERROR] /Users/mkhinda/appc/appc/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestServiceCatalog.java:[90,53] error: cannot find symbol
    [ERROR]   symbol:   variable Mockito
    [ERROR]   location: class TestServiceCatalog
    [ERROR] /Users/mkhinda/appc/appc/appc-adapters/appc-iaas-adapter/appc-iaas-adapter-bundle/src/test/java/org/openecomp/appc/adapter/iaas/impl/TestServiceCatalog.java:[90,18] error: cannot find symbol
    [ERROR] -> [Help 1]
    [ERROR]
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR]
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
    [ERROR]
    [ERROR] After correcting the problems, you can resume the build with the command
    [ERROR]   mvn <goals> -rf :appc-iaas-adapter-bundle

  2. I think the Mockito dependency issue was a known issue that caused problems on non-Jenkins builds of Amsterdam. It has been fixed on the master (Beijing) code branch.

  3. If your appc/deployment build is pulling artifacts from nexus instead of locally, it probably means that the ones on nexus are more recent. The most recent version of a snapshot artifact will always be used. So, if the Jenkins jobs ran and put artifacts in nexus more recently than you ran the local build of appc, it will take the ones from nexus.

  4. Cool thanks for the reply - I will try that out.

    I just ran into something else.  After running the mvn install command in the deployment project to build my docker image, a maven plugin runs that adds a license header into files.  It seems to add them into everything including DG jsons source code which then cause them all to fail on startup.  Has that been fixed on master too?

    I wanted to test out amsterdam but maybe I should switch it to master?  Would I run into other problems if I use appc from master and the rest of my onap components from Amsterdam?  Doesn't seem right to me.  I'll look for that fix on master and see if I can back-port it locally.

    EDIT>>> Just found APPC-160 and APPC-293.  Looks like on Amsterdam this is still a problem if you build locally.

    <!-- license plugin -->
    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>license-maven-plugin</artifactId>
    ..
    Processing DG JSON directory : /opt/openecomp/appc/svclogic/graphs/appc/json/dg-loader-dgs
    21:08:07.204 [main] INFO  o.o.sdnc.dg.loader.DGXMLGenerator - DGXML Conversion Started with arguments :/opt/openecomp/appc/svclogic/graphs/appc/json/dg-loader-dgs:/opt/openecomp/appc/svclogic/graphs/appc/json/dg-loader-dgs/converted-xml
    21:08:08.090 [main] INFO  o.o.sdnc.dg.loader.DGXMLGenerator - JSON Files identified 118
    21:08:08.091 [main] INFO  o.o.sdnc.dg.loader.DGXMLGenerator - Cleaning old DG XML under : /opt/openecomp/appc/svclogic/graphs/appc/json/dg-loader-dgs/converted-xml, delete status :true
    21:08:08.092 [main] INFO  o.o.sdnc.dg.loader.DGXMLGenerator - Generating XML from  :APPC_HealthCheck_VNF_vSCP.json
    21:08:08.119 [main] ERROR o.o.sdnc.dg.loader.DGXMLGenerator - Failed to generate generateXMLFromJSON :SyntaxError: Invalid JSON: <json>:1:0 Expected json literal but found /
    /*-
    ^ in <eval> at line number 25
    21:08:08.119 [main] INFO  o.o.sdnc.dg.loader.DGXMLGenerator - DGXML Conversion Completed...
    
    
    21:08:08.911 [main] INFO  o.openecomp.sdnc.dg.loader.DGXMLLoad - ******************** Loading DG into Database *****************************
    21:08:08.912 [main] ERROR o.openecomp.sdnc.dg.loader.DGXMLLoad - /opt/openecomp/appc/svclogic/graphs/appc/json/dg-loader-dgs/converted-xml is not a valid XML Directory
    21:08:09.131 [main] DEBUG o.o.c.s.c.sli.SvcLogicStoreFactory - Using org.onap.ccsdk.sli.dbtype=jdbc
    21:08:09.142 [main] DEBUG o.o.c.sli.core.sli.SvcLogicJdbcStore - Driver com.mysql.jdbc.Driver accepts jdbc:mysql://dbhost:3306/sdnctl
    21:08:09.202 [main] DEBUG o.o.c.sli.core.sli.SvcLogicJdbcStore - SVC_LOGIC table already exists
    21:08:09.203 [main] DEBUG o.o.c.sli.core.sli.SvcLogicJdbcStore - NODE_TYPES table already exists
    21:08:09.210 [main] INFO  o.o.s.dg.loader.DGXMLLoadNActivate - ******************** Activating DG into Database *****************************
    
    
    21:08:09.698 [main] INFO  o.o.s.dg.loader.DGXMLLoadNActivate - Activating DG :APPC:VM_Stop:2.0.0:sync
    java.lang.Exception: Failed to fetch from Database
        at org.openecomp.sdnc.dg.loader.DGXMLActivate.activateDg(DGXMLActivate.java:85)
        at org.openecomp.sdnc.dg.loader.DGXMLActivate.main(DGXMLActivate.java:125)
    
    
    
  5. So I checked and here is what is happening to my build. It tries all my repos including the local one but it ends up selecting the remote one because my local repo doesn't have a maven-metadata.xml file but has a maven-metadata-local.xml and so it defaults to the remote one...  This is getting into some advanced maven stuff I haven't dealt with before.. Good learning experience for me.  It is all happening in the installZips.sh script.  There is a mvn command there and I am not sure how to get it to use the local repo and not the remote one.  Any idea?

    [INFO] Scanning for projects...
    [INFO]
    [INFO] ------------------------------------------------------------------------
    [INFO] Building Maven Stub Project (No POM) 1
    [INFO] ------------------------------------------------------------------------
    [INFO]
    [INFO] --- maven-dependency-plugin:2.9:copy (default-cli) @ standalone-pom ---
    [INFO] Configured Artifact: org.openecomp.appc:appc-ansible-adapter-installer:1.2.1-SNAPSHOT:zip
    Downloading from deep-local: file:///Users/mkhinda/.m2/onap-repository/org/openecomp/appc/appc-ansible-adapter-installer/1.2.1-SNAPSHOT/maven-metadata.xml
    Downloading from openecomp-snapshot: https://nexus.onap.org/content/repositories/snapshots/org/openecomp/appc/appc-ansible-adapter-installer/1.2.1-SNAPSHOT/maven-metadata.xml
    Downloading from opendaylight-snapshot: https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/org/openecomp/appc/appc-ansible-adapter-installer/1.2.1-SNAPSHOT/maven-metadata.xml
    Downloaded from openecomp-snapshot: https://nexus.onap.org/content/repositories/snapshots/org/openecomp/appc/appc-ansible-adapter-installer/1.2.1-SNAPSHOT/maven-metadata.xml (798 B at 667 B/s)
    [INFO] Copying appc-ansible-adapter-installer-1.2.1-SNAPSHOT.zip to /tmp/appc-ansible-adapter-installer-1.2.1-SNAPSHOT.zip
    
    
    ls -lart /Users/mkhinda/.m2/onap-repository/org/openecomp/appc/appc-ansible-adapter-installer/1.2.1-SNAPSHOT/
    total 75096
    drwxr-xr-x  6 mkhinda  NTNET\Domain Users   204B  1 Feb 15:49 ../
    -rw-r--r--  1 mkhinda  NTNET\Domain Users   6.8K  1 Feb 17:00 appc-ansible-adapter-installer-1.2.1-SNAPSHOT.pom
    -rw-r--r--  1 mkhinda  NTNET\Domain Users   734B  1 Feb 17:18 maven-metadata-local.xml
    -rw-r--r--  1 mkhinda  NTNET\Domain Users    37M  1 Feb 17:18 appc-ansible-adapter-installer-1.2.1-SNAPSHOT.zip
    -rw-r--r--  1 mkhinda  NTNET\Domain Users   244B  1 Feb 17:18 _remote.repositories
    -rw-r--r--  1 mkhinda  NTNET\Domain Users   412B  1 Feb 17:29 resolver-status.properties
    -rw-r--r--  1 mkhinda  NTNET\Domain Users    40B  1 Feb 17:29 maven-metadata-openecomp-snapshot.xml.sha1
    -rw-r--r--  1 mkhinda  NTNET\Domain Users   798B  1 Feb 17:29 maven-metadata-openecomp-snapshot.xml

    UPDATE >>>> I tried adding the offline option to lines 89, 95, and 99 of installZips.sh and it worked (mvn -o).  It only looked locally and picked up my snapshot jars in the docker image.  That might be a fix for this.

  6. The maven commands in installZips should use your local maven settings.xml file.

    As for the issue with the license getting added in, I am submitting a fix for that in master branch.  APPC-562 - Getting issue details... STATUS

  7. use "sudo docker login -u docker -p docker nexus.onap.org:10001" is good also

  8. After I do "mvn clean install -P dockerI'm getting below error


    [ERROR] DOCKER> Unable to build image [onap/appc-cdt-image]
    [INFO] ------------------------------------------------------------------------
    [INFO] Reactor Summary:
    [INFO]
    [INFO] appc-deployment .................................... SUCCESS [ 2.448 s]
    [INFO] Platform Logic ..................................... SUCCESS [ 0.082 s]
    [INFO] Platform Logic : APP-C ............................. SUCCESS [ 0.152 s]
    [INFO] Platform Logic Installer for APP-C ................. SUCCESS [ 0.727 s]
    [INFO] Installation ....................................... SUCCESS [ 0.133 s]
    [INFO] Installation - APPC Docker ......................... SUCCESS [03:07 min]
    [INFO] Installation - CDT Docker .......................... FAILURE [ 21.663 s]
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 03:33 min
    [INFO] Finished at: 2018-06-29T15:25:37+09:00
    [INFO] Final Memory: 63M/544M
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal io.fabric8:docker-maven-plugin:0.16.5:build (generate-images) on project installation-cdt: Unable to build image [onap/appc-cdt-image]: lstat config-design-tool: no such file or directory -> [Help 1]
    [ERROR]

  9. you need to go to cdt repo, run "mvn clean install" before run "mvn clean install -P docker" on deployment repo

  10. I am getting the error: Error response from daemon: Get https://nexus3.onap.org:10001/v1/users/: dial tcp 199.204.45.137:10001: getsockopt: connection refused

    after the command 'docker login nexus3.onap.org:10001'; the same error using 'sudo docker login -u docker -p docker nexus.onap.org:10001'.

    'docker version' command returned the following responses,

    Client:  Version:      17.03.2-ce  API version:  1.27  Go version:   go1.6.2  Git commit:   f5ec1e2  Built:        Thu Jul  5 23:07:48 2018  OS/Arch:      linux/amd64

    Server:  Version:      17.03.2-ce  API version:  1.27 (minimum version 1.12)  Go version:   go1.6.2  Git commit:   f5ec1e2  Built:        Thu Jul  5 23:07:48 2018  OS/Arch:      linux/amd64  Experimental: false


    Any suggestion?


    Thanks.

  11. Sorry, I hate to answer my own question; my issue is resolved.

  12. hi, seems not any introduction for the docker hub image onap/appc-image. could any one write a guide for usage of this image?

  13. The ONAP docker image in docker hub is a copy from nexus server in ONAP. You would follow up OOM (k8s) setup and change

    Repository: nexus3.onap.org:10001
    image: onap/appc-image:1.5.3

    in value.yaml file

    point to docker hub.

    This is my assumption. I never tried this  before. but I assume that should work


  14. such error when I build docker images(mvn clean install -P docker -DskipTests | tee -a appc-deployment-docker-image-build.log):

    Downloaded from 60_opendaylight-mirror: https://nexus.opendaylight.org/content/repositories/public/com/google/guava/guava/23.0-android/guava-23.0-android.jar (2.5 MB at 1.0 MB/s)
    [INFO] Building tar: /root/ONAP-APPC/deployment/installation/appc/target/docker/onap/appc-image/tmp/docker-build.tar
    [INFO] DOCKER> [onap/appc-image:latest]: Created docker-build.tar in 4 seconds
    [ERROR] DOCKER> Unable to build image [onap/appc-image] : "The command '/bin/sh -c apk add --no-cache procps' returned a non-zero code: 127" ["The command '/bin/sh -c apk add --no-cache procps' returned a non-zero code: 127" ]
    [INFO] ------------------------------------------------------------------------
    [INFO] Reactor Summary for appc-deployment 1.6.0-SNAPSHOT:
    [INFO]
    [INFO] appc-deployment .................................... SUCCESS [ 5.873 s]
    [INFO] Platform Logic ..................................... SUCCESS [ 0.221 s]
    [INFO] Platform Logic : APP-C ............................. SUCCESS [ 0.355 s]
    [INFO] Platform Logic Installer for APP-C ................. SUCCESS [ 1.145 s]
    [INFO] Installation ....................................... SUCCESS [ 0.126 s]
    [INFO] Installation - APPC Docker ......................... FAILURE [04:05 min]
    [INFO] Installation - CDT Docker .......................... SKIPPED
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 04:15 min
    [INFO] Finished at: 2019-07-15T07:14:37Z
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal io.fabric8:docker-maven-plugin:0.28.0:build (generate-images) on project installation-appc: Unable to build image [onap/appc-image] : "The command '/bin/sh -c apk add --no-cache procps' returned a non-zero code: 127" -> [Help 1]
    [ERROR]
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR]
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
    [ERROR]
    [ERROR] After correcting the problems, you can resume the build with the command
    [ERROR] mvn <goals> -rf :installation-appc

  15. can you do "apk add --no-cache procps" in Alpine docker image manually from your local env? something it failed to add procps package for APPC Alpine image.