Versions Compared

Key

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

...

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


## dmaap buscontroller

Issues encountered:
1) docker-maven-plugin. Original spotify plugin not supported on Arm
2) docker pull repo default nexus/onap does not support multi-platform images
a) fabric8 docker-maven-plugin allows setting from command line
b) or, build machine must set in ~/.m2/settings/xml
3) base image shell differences (alpine is not bash) impacts entrypoint and scripts
4) docker-compose.yml includes dependencies that are not multi-platform
- eg dmaap/buscontroller crunchydata/crunchy-postgres:centos7-10.4-2.0.0
5) docker USER root. Not recommended by ONAP

### 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/

### Step 1: Build and run on local machine (Mac Air)

- in terminal
> git clone ssh://sandovalfrOAM@gerrit.onap.org:29418/dmaap/buscontroller
> cd buscontroller
> mvn clean install -P docker docker:build
> docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nexus3.onap.org:10003/onap/dmaap/dbc-client 1.0.3 c4b7f26a93ba 59 seconds ago 5.94MB
nexus3.onap.org:10003/onap/dmaap/dbc-client latest c4b7f26a93ba 59 seconds ago 5.94MB
nexus3.onap.org:10003/onap/dmaap/dmaap-bc 1.1.1 ad5670a6c7b8 About a minute ago 335MB
nexus3.onap.org:10003/onap/dmaap/dmaap-bc latest ad5670a6c7b8 About a minute ago 335MB
alpine 3.8 491e0ff7a8d5 4 weeks ago 4.41MB
java openjdk-8-jre e44d62cf8862 2 years ago 311MB

> cd dmaap-bc/src/main/resources
> set PWD=$(pwd)
- edit docker-compose.yml
- use $PWD to mount volume
- change repo from nexus 00001 to 00003
- change image from busconroller to dmaap-bc
- edit Dockerfile
- mkdir /opt/app/dmaap/config
- to avoid failure in dmaapbc script
> docker-compose up
- looks good(?)
- script does not 'enter init'

NOTE: running as root in container not recommended

### Step 2: migrate to alpine

- edit buscontroller/dmaapbc/pom.xml
- change java:openjdk-8-jre to openjdk:8-jre-alpine
- add "sh" to entrypoint
> cd <>/buscontroller
> mvn clean install -P docker docker:build
> docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nexus3.onap.org:10003/onap/dmaap/dbc-client 1.0.3 ee726a04cf12 15 seconds ago 5.94MB
nexus3.onap.org:10003/onap/dmaap/dbc-client latest ee726a04cf12 15 seconds ago 5.94MB
nexus3.onap.org:10003/onap/dmaap/dmaap-bc 1.1.1 f70f2363d754 30 seconds ago 109MB
nexus3.onap.org:10003/onap/dmaap/dmaap-bc latest f70f2363d754 30 seconds ago 109MB
openjdk 8-jre-alpine 1b46cc2ba839 3 weeks ago 85MB
alpine 3.8 491e0ff7a8d5 4 weeks ago 4.41MB

> cd dmaap-bc/src/main/resources
> docker-compose up
- debug dmaapbc script (alpine sh v bash)
dmaap-bc_1 | ./bin/dmaapbc: source: line 61: can't open '/opt/app/config/conf/buscontroller.env': Not a directory
- move SOURCE to conditional above

dmaap-bc_1 | ./bin/dmaapbc: line 93: can't create config/PolicyEngineApi.properties: nonexistent directory
- mkdir conf in pom/dockerfile

> docker-compose up
dmaap-bc_1 | ENTER start
...
dmaap-bc_1 | org.onap.dmaap.dbcapi.server.Main
dmaap-bc_1 | + set +x
dmaap-bc_1 | + PIDS=29
dmaap-bc_1 | + set +x

#### 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

- terminal on Arm machine
> git clone https://gerrit.onap.org/r/dmaap/buscontroller
- copy modified files from workstation to Arm server
$ scp misc/dmaapbc root@147.75.94.202:/root/onap/dmaap/buscontroller/dmaap-bc/misc/
$ scp pom.xml root@147.75.94.202:/root/onap/dmaap/buscontroller/dmaap-bc
$ scp src/main/resources/docker-compose.yml root@147.75.94.202:/root/onap/dmaap/buscontroller/dmaap-bc/src/main/resources
$ scp src/main/resources/Dockerfile root@147.75.94.202:/root/onap/dmaap/buscontroller/dmaap-bc/src/main/resources
> mvn clean install -DskipTests -Pdocker -Ddocker.pull.registry=docker.io
> cd src/main/resources
- edit docker-compose.yml
- crunchydata/crunchy-postgres:centos7-10.4-2.0.0 not multi-platform
- use postgres
> docker-compose up

#### Step 5: build docker image from script, not maven

- create dbuild.sh

#### Notes: test spotify dockerfile-maven-plugin

- throws 'broken pipe' error which is amisdirection to registry naming issue
- See https://github.com/spotify/dockerfile-maven/issues/95
- maven install error
- See: https://github.com/spotify/dockerfile-maven/issues/252
- upgrade Arm server to maven 3.6.0
- see: https://maven.apache.org/users/index.html
- requires multiple execution blocks for multiple tags
- see https://github.com/spotify/dockerfile-maven/issues/10