The karaf-based docker examples I have seen build a custom karaf
distribution and then creates a Dockerfile that copies the custom karaf
distribution into /opt/apache-karaf in an image based one openjdk:8-jre.

What I would like to do, is to start with the official karaf image on
docker hub https://hub.docker.com/r/apache/karaf and then add a feature
as a part of the build process.

Unless I've misunderstood, the images will be a lot smaller, because
they will only hold the difference between the base image and the
current state of the image file system at the end of the build.

Here's what I have tried:
 1. Add the feature to shell.init.script (partly works, see previous
    email. But loads the feature at startup time so the behaviour may be
    different to what was expected)

 2. Fire up karaf and do commands to set the feature repository and add
    the feature (this failed miserably (as I expected, but I had to try))
     FROM apache/karaf:4.2.8
     COPY org.ops4j.pax.url.mvn.cfg /opt/apache-karaf/etc
     RUN karaf daemon
     RUN feature:repo-add mvn:no.priv.bang.ukelonn/karaf/LATEST/xml/features
     RUN feature:install ukelonn-with-derby
     RUN exit

 3. Fire up karaf as a deamon and then do ssh in to add the feature
    repository and install the feature (this started up the daemon and
    then got stuck)
     FROM apache/karaf:4.2.8
     COPY org.ops4j.pax.url.mvn.cfg /opt/apache-karaf/etc
     RUN karaf daemon
     RUN sshpass -p karaf ssh -p 8101 karaf@localhost 'feature:repo-add 
mvn:no.priv.bang.ukelonn/karaf/LATEST/xml/features'
     RUN sshpass -p karaf ssh -p 8101 karaf@localhost 'feature:install 
ukelonn-with-derby'
     RUN karaf stop

Are there any other ways this could be done?
Is there a way to copy in the bundles as loaded by a feature?

Reply via email to