...
The "docker" profile defines an additional phase in which the docker image is built and deployed to NEXUS_DOCKER_REPO with the image name ${image.name}:${project.docker.latesttag.version}, which currently translates to "onap/ccsdk-odlsli-image:0.3-STAGING-latest."
The Dockerfile
Running the ODLSLI pom.xml file
Running the command "mvn clean process-sources" will create the correct file and folder structure in ./target/docker-stage so one can then navigate to that folder and build the docker image with the command "docker build ." I expect that the "docker build profile" in the pom.xml file requires special privileges because it deploys the image to NEXUS_DOCKER_REPO.
The Dockerfile
Creating the zip installation files for karaf features
We now see how the karaf features for CCSDK are structured so they can be installed and OpenDaylight launched. The next step is to understand how the zip installation files are created. A good example is the "sliapi" feature, which is in the gerrit repository ccsdk/sli/core.
The sliapi directory contains the usual directories for a karaf feature with an additional directory "installer." This directory contains the code that creates the installation zip file that is included in the dependencies section of the ODLSLI pom.xml file.
Taking a look at the pom.xml file.
Inspecting the installer pom.xml file
Below is the annotated pom.xml file. It executes two maven phases: prepare-package and package. Maven executes the prepare-package phase before the package phase, although, in the pom.xml file, the prepare-package code appears after the prepare code. In the annotations, the sequence is indicated by number.
Building the docker image
By running the command 'mvn clean process-sources' and getting a BUILD SUCCESS, a properly constructed directory will have been created at ~/git/ccsdk/distribution/odlsli/target/docker-stage/.
Before building the image, remember that the Dockerfile begins with a local image of OpenDaylight Oxygen: onap/ccsdk-odl-oxygen-image${project.version} (currently 0.3.0-SNAPSHOT). One can download the image from NEXUS_DOCKER_IMAGE and then rename it as a local image using the commands below.
Building the docker image
By running the command 'mvn clean process-sources' and getting a BUILD SUCCESS, a properly constructed directory will be created at ~/git/ccsdk/distribution/odlsli/target/docker-stage/.
Before building the image, remember that the Dockerfile begins with a local image of OpenDaylight Oxygen: onap/ccsdk-odl-oxygen-image${project.version} (currently 0.3.0-SNAPSHOT). One can download the image from NEXUS_DOCKER_IMAGE and then rename it as a local image using the commands below.
Code Block | ||
---|---|---|
| ||
%: docker pull ${NEXUS_DOCKER_REPO}/onap/ccsdk-odl-oxygen-image:0.3.0-SNAPSHOT
0.3.0-SNAPSHOT: Pulling from onap/ccsdk-odl-oxygen-image
95871a411089: Pull complete
f7253e37cce8: Pull complete
12d05d7bd5c4: Pull complete
db27ec99c6c2: Pull complete
8fd62e3405ff: Pull complete
ce430a842b90: Pull complete
de7dcf5d4be1: Pull complete
e3de3d1054ec: Pull complete
d66bd2234856: Pull complete
6be70fc7e3a6: Pull complete
Digest: | ||
Code Block | ||
| ||
%: docker pull ${NEXUS_DOCKER_REPO}/onap/ccsdk-odl-oxygen-image:0.3.0-SNAPSHOT
0.3.0-SNAPSHOT: Pulling from onap/ccsdk-odl-oxygen-image
95871a411089: Pull complete
f7253e37cce8: Pull complete
12d05d7bd5c4: Pull complete
db27ec99c6c2: Pull complete
8fd62e3405ff: Pull complete
ce430a842b90: Pull complete
de7dcf5d4be1: Pull complete
e3de3d1054ec: Pull complete
d66bd2234856: Pull complete
6be70fc7e3a6: Pull complete
Digest: sha256:80da6c8e0f70d0dddd2be462634b297fc0dc5256cb93619b30a66441d1a89cb8
Status: Downloaded newer image for nexus3.onap.org:10001/onap/ccsdk-odl-oxygen-image:0.3.0-SNAPSHOT
%: docker tag ${NEXUS_DOCKER_REPO}/onap/ccsdk-odl-oxygen-image:0.3.0-SNAPSHOT onap/ccsdk-odl-oxygen-image:0.3.0-SNAPSHOT
%: docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
onap/ccsdk-odl-oxygen-image 0.3.0-SNAPSHOT bb02ebe49933 8 hours ago 1.72GB
nexus3.onap.org:10001/onap/ccsdk-odl-oxygen-image 0.3.0-SNAPSHOT bb02ebe49933 8 hours ago 1.72GB
nexus3.onap.org:10001/onap/ccsdk-dgbuilder-image 0.3-STAGING-latest eb208aa7f163 4 days ago 1.04GB
nexus3.onap.org:10001/onap/ccsdk-odlsli-image 0.3-STAGING-latest 665a42becd61 4 days ago 1.8GB
mysql/mysql-server 5.6 8d97ef4de156 3 months ago 226MB
|
Running the ODLSLI pom.xml file
Running the command "mvn clean process-sources" will create the correct file and folder structure in ./target/docker-stage. One can navigate to that folder and build the docker image as shown below.
One can then build the ODLSLI container and give it the name onap/sdnr:0.3.0-SNAPSHOTDOCK SNAPSHOT with this command.
Code Block | ||
---|---|---|
| ||
%: pwd ~/git/ccsdk/distribution/odlsli/target/docker-stage %: docker build --tag onap/sdnr:0.3.0-SNAPSHOT . Sending build context to Docker daemon 55.83MB Step 1/21 : FROM onap/ccsdk-odl-oxygen-image:0.3.0-SNAPSHOT ---> bb02ebe49933 Step 2/21 : MAINTAINER CCSDK Team (onap-ccsdk@lists.onap.org) ---> Running in 53c7a075af9e Removing intermediate container 53c7a075af9e ---> 9a53d8633de9 Step 3/21 : ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64 ---> Running in fc2c568526be Removing intermediate container fc2c568526be ---> 15899d4e7cc9 Step 4/21 : ENV ODL_HOME /opt/opendaylight ---> Running in 615c57b21e5f Removing intermediate container 615c57b21e5f ---> a64fa9d9330c Step 5/21 : ENV SDNC_CONFIG_DIR /opt/onap/ccsdk/data/properties ---> Running in 89dc0febedb7 Removing intermediate container 89dc0febedb7 ---> ca823ba18f85 Step 6/21 : ENV CCSDK_SLI_CORE_REPO mvn:org.onap.ccsdk.sli.core/ccsdk-sli-core-all/0.3.0-SNAPSHOT/xml/features ---> Running in 8ea3b1ecefc9 Removing intermediate container 8ea3b1ecefc9 ---> c786ac0d9a80 Step 7/21 : ENV CCSDK_SLI_ADAPTORS_REPO mvn:org.onap.ccsdk.sli.adaptors/ccsdk-sli-adaptors-all/0.3.0-SNAPSHOT/xml/features ---> Running in aabf49f35e52 Removing intermediate container aabf49f35e52 ---> 910373c6697f Step 8/21 : ENV CCSDK_SLI_NORTHBOUND_REPO mvn:org.onap.ccsdk.sli.northbound/ccsdk-sli-northbound-all/0.3.0-SNAPSHOT/xml/features ---> Running in 6501bdd82056 Removing intermediate container 6501bdd82056 ---> 7b0d785416d8 Step 9/21 : ENV CCSDK_SLI_PLUGINS_REPO mvn:org.onap.ccsdk.sli.plugins/ccsdk-sli-plugins-all/0.3.0-SNAPSHOT/xml/features ---> Running in 47475306a7bd Removing intermediate container 47475306a7bd ---> 701ef990e4be Step 10/21 : ENV ANSIBLE_GPG_KEY 93C4A3FD7BB9C367 ---> Running in 57f328a63e52 Removing intermediate container 57f328a63e52 ---> 3d9bfd557bdc Step 11/21 : COPY idmlight.db.mv.db $ODL_HOME/data ---> c9cc49e5e720 Step 12/21 : COPY system /tmp/system ---> 896e83ab462d Step 13/21 : RUN rsync -a /tmp/system $ODL_HOME && rm -rf /tmp/system ---> Running in 3dc894642df7 Removing intermediate container 3dc894642df7 ---> 08607a4ce498 Step 14/21 : RUN cp $ODL_HOME/etc/org.apache.karaf.features.cfg $ODL_HOME/etc/org.apache.karaf.features.cfg.orig ---> Running in 2693ca9a78ad Removing intermediate container 2693ca9a78ad ---> 9bd7f358f988 Step 15/21 : RUN cat $ODL_HOME/etc/org.apache.karaf.features.cfg.orig | sed -e "\|featuresRepositories|s|$|, ${CCSDK_SLI_CORE_REPO}, ${CCSDK_SLI_ADAPTORS_REPO}, ${CCSDK_SLI_NORTHBOUND_REPO}, ${CCSDK_SLI_PLUGINS_REPO}|" > $ODL_HOME/etc/org.apache.karaf.features.cfg ---> Running in c146dfabcba8 Removing intermediate container c146dfabcba8 ---> 0998b89e66b1 Step 16/21 : RUN echo featuresBoot=config,standard,region,package,kar,ssh,management,odl-restconf-all,odl-mdsal-all,odl-mdsal-apidocs,odl-daexim-all,ccsdk-sli-core-all,ccsdk-sli-adaptors-all,ccsdk-sli-northbound-all,ccsdk-sli-plugins-all >> $ODL_HOME/etc/org.apache.karaf.features.cfg ---> Running in 3734bb36ecf4 Removing intermediate container 3734bb36ecf4 ---> 9136e8973268 Step 17/21 : RUN useradd odl ---> Running in 4133971b9022 Removing intermediate container 4133971b9022 ---> ba1a79490ec7 Step 18/21 : COPY opt /opt ---> 9cee59b90658 Step 19/21 : COPY org.ops4j.pax.logging.cfg /opt/opendaylight/etc/org.ops4j.pax.logging.cfg ---> 2988c82b7851 Step 20/21 : ENTRYPOINT /opt/onap/ccsdk/bin/startODL.sh ---> Running in d71effd4e8dc Removing intermediate container d71effd4e8dc ---> 0fc9beea32f3 Step 21/21 : EXPOSE 8181 ---> Running in 654509364e8f Removing intermediate container 654509364e8f ---> f5aa4c5644d0 Successfully built f5aa4c5644d0 Successfully tagged onap/sdnr:0.3.0-SNAPSHOT gc731h@ant-vm-45/docker-stage 84338: docker images REPOSITORY TAG IMAGE ID CREATED SIZE onap/sdnr 0.3.0-SNAPSHOT f5aa4c5644d0 48 seconds ago 1.8GB onap/ccsdk-odl-oxygen-image 0.3.0-SNAPSHOT bb02ebe49933 9 hours ago 1.72GB nexus3.onap.org:10001/onap/ccsdk-odl-oxygen-image 0.3.0-SNAPSHOT bb02ebe49933 9 hours ago 1.72GB nexus3.onap.org:10001/onap/ccsdk-dgbuilder-image 0.3-STAGING-latest eb208aa7f163 4 days ago 1.04GB nexus3.onap.org:10001/onap/ccsdk-odlsli-image 0.3-STAGING-latest 665a42becd61 4 days ago 1.8GB mysql/mysql-server 5.6 8d97ef4de156 3 months ago 226MB %: |
...
Code Block | ||
---|---|---|
| ||
%: docker run --interactive --tty --publish 8484:8181 --name sdnr onap/sdnr:0.3.0-SNAPSHOT Waiting for mysql ................................................................................................ |
SDNR will not progress if it cannot login to the MySQL server. Remember that the entry point script /opt/onap/ccsdk/bin/startODL.sh will execute and that it waits to login to the db server, as shown here.
Code Block | ||
---|---|---|
| ||
...
#
# Wait for database
#
echo "Waiting for mysql"
until mysql -h dbhost -u root -p${MYSQL_PASSWD} mysql &> /dev/null
do
printf "."
sleep 1
done
echo -e "\nmysql ready"
... |
So we want to connect SDNR to ccsdk_db_container. We can inspect the CCSDK containers to learn about their network.
Let's shut down the ccsdk_odlsli_container to avoid conflicts.
We shut down the ccsdk_odlsli_container to avoid conflicts.
Code Block | ||||
---|---|---|---|---|
| ||||
%: docker ps
CONTAINER ID IMAGE | ||||
Code Block | ||||
| ||||
%: docker ps CONTAINER ID IMAGE COMMAND CREATED COMMAND STATUS CREATED PORTS STATUS NAMES 4e3ba68fb7bb PORTS NAMES 4e3ba68fb7bb nexus3.onap.org:nexus3.onap.org:10001/onap/ccsdk-dgbuilder-image:0.3-STAGING-latest "/bin/bash -c 'cd /o…" 3 days ago Up 3 days 0.0.0.0:3000->3100/tcp ccsdk_dgbuilder_container a68fc2f266e6 nexus3.onap.org:10001/onap/ccsdk-odlsli-image:0.3-STAGING-latest "/opt/onap/ccsdk/bin…" 3 days ago Up 3 days 0.0.0.0:8383->8181/tcp ccsdk_odlsli_container 26e84acaae56 mysql/mysql-server:5.6 "/entrypoint.sh mysq…" 3 days ago Up 3 days (healthy) 0.0.0.0:32790->3306/tcp ccsdk_db_container %: docker stop ccsdk_odlsli_container ccsdk_odlsli_container %: docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 4e3ba68fb7bb nexus3.onap.org:10001/onap/ccsdk-dgbuilder-image:0.3-STAGING-latest "/bin/bash -c 'cd /o…" 3 days ago Up 3 days 0.0.0.0:3000->3100/tcp ccsdk_dgbuilder_container 26e84acaae56 mysql/mysql-server:5.6 "/entrypoint.sh mysq…" 3 days ago Up 3 days (healthy) 0.0.0.0:32790->3306/tcp ccsdk_db_container %: docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES f550d9a98fb7 onap/sdnr:0.3.0-SNAPSHOT "/bin/sh -c /opt/ona…" 10 minutes ago Exited (130) 52 seconds ago sdnr 4e3ba68fb7bb nexus3.onap.org:10001/onap/ccsdk-dgbuilder-image:0.3-STAGING-latest "/bin/bash -c 'cd /o…" 3 days ago Up 3 days 0.0.0.0:3000->3100/tcp ccsdk_dgbuilder_container a68fc2f266e6 nexus3.onap.org:10001/onap/ccsdk-odlsli-image:0.3-STAGING-latest "/opt/onap/ccsdk/bin…" 3 days ago Exited (137) 9 seconds ago ccsdk_odlsli_container 26e84acaae56 mysql/mysql-server:5.6 "/entrypoint.sh mysq…" "/entrypoint.sh mysq…" 3 days ago Up 3 days (healthy) 0.0.0.0:32790->3306/tcp ccsdk_db_container %:3 days ago Up 3 days (healthy) 0.0.0.0:32790->3306/tcp ccsdk_db_container %: |
Remember that the entrypoint script /opt/onap/ccsdk/bin/startODL.sh will execute and that it waits to login to the db server, so SDNR will not progress if it cannot login to the MySQL server. We want to connect SDNR to ccsdk_db_container, so we inspect the CCSDK containers to learn about their network.
We now have the information we need to start the container and use the command described here to launch it.
Creating the zip installation files for karaf features
We now see how the karaf features for CCSDK are structured so they can be installed and OpenDaylight launched. The next step is to understand how the zip installation files are created. A good example is the "sliapi" feature, which is in the gerrit repository ccsdk/sli/core.
The sliapi directory contains the usual directories for a karaf feature with an additional directory "installer." This directory contains the code that creates the installation zip file that is included in the dependencies section of the ODLSLI pom.xml file.
Taking a look at the pom.xml file.
Inspecting the installer pom.xml file
Below is the annotated pom.xml file. It executes two maven phases: prepare-package and package. Maven executes the prepare-package phase before the package phase, although, in the pom.xml file, the prepare-package code appears after the prepare code. In the annotations, the sequence is indicated by number.