This page describes steps taken and issues encountered in transitioning ONAP project to use small, multi-platform images
dmaap
datarouter
### This section describes how to build and test datarouter images on a host such as
a laptop or remote server.
- Install git, maven, docker
- See https://wiki.onap.org/display/DW/Setting+Up+Your+Development+Environment
- See https://docs.docker.com/install/
#### Build
- in terminal
> git clone ssh://sandovalfrOAM@gerrit.onap.org:29418/dmaap/datarouter && scp -p -P 29418 sandovalfrOAM@gerrit.onap.org:hooks/commit-msg datarouter/.git/hooks/
> cd datarouter
> mvn clean install -DskipTests
> docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nexus3.onap.org:10003/onap/dmaap/datarouter-subscriber 2.0.0-SNAPSHOT 03ea672a6d73 28 seconds ago 102MB
nexus3.onap.org:10003/onap/dmaap/datarouter-subscriber latest 03ea672a6d73 28 seconds ago 102MB
nexus3.onap.org:10003/onap/dmaap/datarouter-node 2.0.0-SNAPSHOT 76345553e1ec 43 seconds ago 118MB
nexus3.onap.org:10003/onap/dmaap/datarouter-node latest 76345553e1ec 43 seconds ago 118MB
nexus3.onap.org:10003/onap/dmaap/datarouter-prov 2.0.0-SNAPSHOT db1d6afe5c3f About a minute ago 148MB
nexus3.onap.org:10003/onap/dmaap/datarouter-prov latest db1d6afe5c3f About a minute ago 148MB
openjdk 8-jre-alpine 1b46cc2ba839 3 weeks ago 85MB
nexus3.onap.org:10001/openjdk 8-jre-alpine 1b46cc2ba839 3 weeks ago 85MB
#### Test
> cd datarouter-docker-compose/src/main/resources
- edit docker-compose, change nexus 0001 (remote pull repo) to 0003 (local build)
> docker-compose up
- terminal 2
> docker container ls -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c193317ec860 nexus3.onap.org:10003/onap/dmaap/datarouter-node "sh startup.sh" About a minute ago Up About a minute 0.0.0.0:9090->8080/tcp, 0.0.0.0:9443->8443/tcp datarouter-node
e8dab741550e nexus3.onap.org:10003/onap/dmaap/datarouter-prov "sh startup.sh" About a minute ago Up About a minute (healthy) 0.0.0.0:8080->8080/tcp, 0.0.0.0:8443->8443/tcp, 0.0.0.0:443->8443/tcp datarouter-prov
cf0e996f0f31 nexus3.onap.org:10003/onap/dmaap/datarouter-subscriber "sh startup.sh" About a minute ago Up About a minute 8080/tcp, 0.0.0.0:7070->7070/tcp, 8443/tcp subscriber-node
73affb6364f9 mariadb:10.2.14 "docker-entrypoint.s…" About a minute ago Up About a minute (healthy) 0.0.0.0:3306->3306/tcp mariadb
> docker exec -it datarouter-node /bin/sh
# curl http://dmaap-dr-prov:8080/internal/prov
> docker exec -it datarouter-prov /bin/sh
# curl -v -X POST -H "Content-Type : application/vnd.dmaap-dr.feed" -H "X-DMAAP-DR-ON-BEHALF-OF: rs873m" --data-ascii @/opt/app/datartr/addFeed3.txt --post301 --location-trusted -k https://dmaap-dr-prov:8443
### This section describes the migration of datarouter to small, multi-platform images.
The datarouter project generates 3 docker images:
datarouter-prov
datarouter-node
datarouter-subscriber
Each sub-project is structured similarly, therefore the changes to each to migrate to a small,
multi-platfrom image are similar and involve the following steps:
1. update pom to migrate from spotify docker-maven-plug to fabri8 docker-maven-plugin
2. create Dockerfile
#### Step 1: build and run on Intel (Mac Air)
> git clone ssh://sandovalfrOAM@gerrit.onap.org:29418/dmaap/datarouter && scp -p -P 29418 sandovalfrOAM@gerrit.onap.org:hooks/commit-msg datarouter/.git/hooks/
> cd datarouter
> mvn clean install -DskipTests -Pdocker
> docker images
nexus3.onap.org:10003/onap/dmaap/datarouter-subscriber latest b163a167f8c1 24 seconds ago 672MB
nexus3.onap.org:10003/onap/dmaap/datarouter-node latest eaadf6b93bcf 38 seconds ago 674MB
nexus3.onap.org:10003/onap/dmaap/datarouter-prov latest 8c9adc9a9851 About a minute ago 704MB
java 8 d23bdf5b1b1b 2 years ago 643MB
TEST
> cd datarouter-docker-compose/src/main/resources
- edit docker-compose, change nexus 0001 (remote pull repo) to 0003 (local build)
> docker-compose up
- terminal 2
> docker container ls -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c193317ec860 nexus3.onap.org:10003/onap/dmaap/datarouter-node "sh startup.sh" About a minute ago Up About a minute 0.0.0.0:9090->8080/tcp, 0.0.0.0:9443->8443/tcp datarouter-node
e8dab741550e nexus3.onap.org:10003/onap/dmaap/datarouter-prov "sh startup.sh" About a minute ago Up About a minute (healthy) 0.0.0.0:8080->8080/tcp, 0.0.0.0:8443->8443/tcp, 0.0.0.0:443->8443/tcp datarouter-prov
cf0e996f0f31 nexus3.onap.org:10003/onap/dmaap/datarouter-subscriber "sh startup.sh" About a minute ago Up About a minute 8080/tcp, 0.0.0.0:7070->7070/tcp, 8443/tcp subscriber-node
73affb6364f9 mariadb:10.2.14 "docker-entrypoint.s…" About a minute ago Up About a minute (healthy) 0.0.0.0:3306->3306/tcp mariadb
> docker exec -it datarouter-node /bin/bash
# curl http://dmaap-dr-prov:8080/internal/prov
> docker exec -it datarouter-prov /bin/bash
# curl -v -X POST -H "Content-Type : application/vnd.dmaap-dr.feed" -H "X-DMAAP-DR-ON-BEHALF-OF: rs873m" --data-ascii @/opt/app/datartr/addFeed3.txt --post301 --location-trusted -k https://dmaap-dr-prov:8443
#### Step 2: migrate to alpine
- edit datarouter-[prov, node, subscriber]/pom.xml
+ <baseImage>openjdk:8-jre-alpine</baseImage>
+ <entryPoint>["sh", "/startup.sh"]</entryPoint
- note shell for openjdk:8-jre-alpine is sh, therefore entrypoint = ["sh", "startup.sh"]
> mvn clean install -DskipTests -Pdocker
> docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nexus3.onap.org:10003/onap/dmaap/datarouter-subscriber latest 03ea672a6d73 28 seconds ago 102MB
nexus3.onap.org:10003/onap/dmaap/datarouter-node latest 76345553e1ec 43 seconds ago 118MB
nexus3.onap.org:10003/onap/dmaap/datarouter-prov latest db1d6afe5c3f About a minute ago 148MB
nexus3.onap.org:10001/openjdk 8-jre-alpine 1b46cc2ba839 3 weeks ago 85MB
- Test as above, Note change to "/bin/sh" per alpine
> docker exec -it datarouter-node /bin/sh
# curl http://dmaap-dr-prov:8080/internal/prov
> docker exec -it datarouter-prov /bin/sh
# curl -v -X POST -H "Content-Type : application/vnd.dmaap-dr.feed" -H "X-DMAAP-DR-ON-BEHALF-OF: rs873m" --data-ascii @/opt/app/datartr/addFeed3.txt --post301 --location-trusted -k https://dmaap-dr-prov:8443
#### Step 3: migrate pom to fabric8 docker-maven-plugin
- Note: spotify docker-maven-plugin does not run on Arm
[ERROR] Failed to execute goal com.spotify:docker-maven-plugin:1.0.0:build (default-cli) on project datarouter-prov: Exception caught: java.util.concurrent.ExecutionException: com.spotify.docker.client.shaded.javax.ws.rs.ProcessingException:
java.lang.UnsatisfiedLinkError: could not load FFI provider jnr.ffi.provider.jffi.Provider: ExceptionInInitializerError: Can't overwrite cause with java.lang.UnsatisfiedLinkError: cannot determine CPU -> [Help 1]
- See: https://github.com/spotify/docker-maven-plugin/issues/233
- Note: spotify dockerfile-maven-plugin is alternate to fabric8, but other ONAP teams are using fabric8 so there
appears to be no compelling reason to stick w spotify
- Note: docker pull repo must be managed
- edit datarouter-[prov, node, subscriber]/pom.xml
Note that onap ~/.m2/settings.xml defines
<docker.pull.registry>nexus3.onap.org:10001</docker.pull.registry>
which forces an amd64 specific image.
to support other platforms, add to docker-maven-plugin configuration:
pullRegistry>${docker.pull.registry}</pullRegistry>
and invoke mvn with platfrom specific pull repo, e.g. on Arm
> mvn install -DskipTests -Pdocker -Ddocker.pull.registry=docker.io
- create datarouter-[prov, node, subscriber]/src/main/resources/docker/Dockerfile
- Test, As per step 2
#### Step 4: build and run on Arm
- obtain access to server and install git, maven, docker (not described here)
> git clone https://sandovalfrOAM@gerrit.onap.org/r/a/dmaap/datarouter
Cloning into 'datarouter'...
Password for 'https://sandovalfrOAM@gerrit.onap.org':
- go to gerrit profile/settings/http password - generate password
> cd datarouter
> mvn clean install -DskipTests -Pdocker -Ddocker.pull.registry=docker.io
- Test, as above step 2
- May encounter docker-compose incompatibilities, edit docker-compose
> docker-compose up
ERROR: Version in "./docker-compose.yml" is unsupported. You might be seeing this error because you're using the wrong
Compose file version. Either specify a version of "2" (or "2.0") and place your service definitions under the `services`
key, or omit the `version` key and place your service definitions at the root of the file to use version 1.
For more on the Compose file format versions, see https://docs.docker.com/compose/compose-file/
ERROR: The Compose file './docker-compose.yml' is invalid because:
Unsupported config option for services.datarouter-prov: 'healthcheck'
Unsupported config option for services.mariadb_container: 'healthcheck'
services.datarouter-prov.depends_on contains an invalid type, it should be an array