Skip to content

Commit

Permalink
Upgrade Karaf images to 4.0.9 Alpine (#46)
Browse files Browse the repository at this point in the history
Between the release of Alpine 4.0.9 and the release of Alpine 3.6, the tty
issue with jansi that prevented Karaf from running on Alpine has been
resolved.
fusesource/jansi#58

* Upgrade from Karaf 4.0.7 to 4.0.9
* Use latest openjdk alpine image for karaf
* Minor clean ups of Dockerfiles
  • Loading branch information
birkland authored and emetsger committed Jun 13, 2017
1 parent ed37e1f commit 8528c3f
Show file tree
Hide file tree
Showing 12 changed files with 124 additions and 141 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.sh text eol=lf
*.cfg text eol=lf
*.patch text eol=lf
65 changes: 21 additions & 44 deletions acrepo/1.1.0/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,62 +1,39 @@
FROM fcrepoapix/apix-karaf:4.0.7
FROM fcrepoapix/apix-karaf-camel:4.0.9@sha256:bbea3acdab13f6f6a321b1b9e08e2ce1af4e741f2ca31b36014f087f0fefa1a6

MAINTAINER Elliot Metsger <emetsger@jhu.edu>
LABEL description = "Provides a Karaf container configured with Amherst features"
# Needed for -image
RUN apt-get update && apt-get -y install imagemagick && rm -rf /var/lib/apt/lists/* && apt-get purge -y

# The port acrepo Karaf will listen on when debugging is enabled

ENV DEBUG_PORT 5008
ENV JAVA_DEBUG_PORT ${DEBUG_PORT}
EXPOSE ${DEBUG_PORT}
EXPOSE 9102

# The host and port that the Fedora repository is running on (in a separate container)
ENV FCREPO_HOST localhost
ENV FCREPO_PORT 80
ENV FCREPO_CONTEXT_PATH /fcrepo

ENV ACREPO_VERSION 1.1.0
ENV CAMEL_VERSION 2.18.3
ENV FCREPO_CAMEL_VERSION 4.5.0

#ADD maven/ /build/repository/

# Allow the string "acrepo" to be recognized by Karaf as the Amherst feature repository

RUN echo "acrepo=mvn:edu.amherst.acdc/acrepo-karaf/${ACREPO_VERSION}/xml/features" >> etc/org.apache.karaf.features.repos.cfg

# Add acrepo as a registered features repository by default

RUN sed -e "s:^\( mvn\:org.apache.karaf.features/enterprise/${KARAF_VERSION}/xml/features\):\1, \\\
ENV ACREPO_VERSION=1.1.0 \
FCREPO_CAMEL_VERSION=4.5.0 \
FCREPO_HOST=localhost \
FCREPO_PORT=80 \
DEBUG_PORT=5008 \
JAVA_DEBUG_PORT=5008 \
FCREPO_CONTEXT_PATH=/fcrepo

#ADD maven/docke /build/repository/

# Install all of the latest features found in the acrepo features repository)
RUN apk --no-cache add --update imagemagick && \
echo "acrepo=mvn:edu.amherst.acdc/acrepo-karaf/${ACREPO_VERSION}/xml/features" >> etc/org.apache.karaf.features.repos.cfg && \
sed -e "s:^\( mvn\:org.apache.karaf.features/enterprise/${KARAF_VERSION}/xml/features\):\1, \\\
mvn\:edu.amherst.acdc/acrepo-karaf/${ACREPO_VERSION}/xml/features \\\:" \
-i etc/org.apache.karaf.features.cfg

# Install all of the latest features found in the acrepo features repository (typically these features will be SNAPSHOT versions)

RUN bin/start && \
-i etc/org.apache.karaf.features.cfg && \
bin/start && \
bin/client -r 10 -d 5 "feature:repo-add mvn:edu.amherst.acdc/acrepo-karaf/${ACREPO_VERSION}/xml/features" && \
bin/client -r 10 -d 5 "feature:repo-add mvn:org.apache.camel.karaf/apache-camel/${CAMEL_VERSION}/xml/features" && \
bin/client -r 10 -d 5 "feature:repo-add mvn:org.fcrepo.camel/fcrepo-camel/${FCREPO_CAMEL_VERSION}/xml/features" && \
bin/client -r 10 -d 5 "feature:install camel fcrepo-camel acrepo-exts-ore acrepo-exts-image acrepo-exts-pcdm acrepo-exts-fits acrepo-exts-serialize-xml" && \
/bin/sleep 15 && \
bin/stop

# Update the Karaf logging configuration so that `bin/karaf` will echo logging
# to the console, viewable by `docker logs`. This makes using the Karaf console
# difficult, so the recommended way to obtain the Karaf console is to use
# `docker exec -ti <container> bin/client` after the container has been started
# by `docker run`

RUN sed -e "s/osgi:/stdout, osgi:/" -i etc/org.ops4j.pax.logging.cfg
bin/stop && \
rm -rf instances/*

COPY entrypoint.sh /entrypoint.sh

RUN chmod 700 /entrypoint.sh

ENTRYPOINT [ "/entrypoint.sh" ]

# Launch Karaf with no console, and debugging enabled by default.
# Launch Karaf with no console

CMD [ "server", "debug" ]
CMD [ "server" ]
2 changes: 1 addition & 1 deletion acrepo/1.1.0/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh

# Update the Karaf configuration so that the Maven repository under ${MAVEN_REPO}
# is used by Karaf to discover features.
Expand Down
62 changes: 20 additions & 42 deletions apix/0.3.0-SNAPSHOT/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,64 +1,42 @@
FROM fcrepoapix/apix-karaf:4.0.7@sha256:b258ee07e6e578fc80b791aa0a02d54bcf18dc94acb7c3b340bea3ea8949f7c7
FROM fcrepoapix/apix-karaf-camel:4.0.9@sha256:bbea3acdab13f6f6a321b1b9e08e2ce1af4e741f2ca31b36014f087f0fefa1a6

MAINTAINER Elliot Metsger <emetsger@jhu.edu>
LABEL description = "Provides a Karaf container configured with API-X features"

# The port Karaf will listen on when debugging is enabled
ENV DEBUG_PORT 5011
ENV JAVA_DEBUG_PORT ${DEBUG_PORT}
EXPOSE ${DEBUG_PORT}

# The version of API-X being included in the image
ENV APIX_VERSION 0.3.0-SNAPSHOT

# The Fedora repository base URI
ENV FCREPO_HOST=fcrepo
ENV FCREPO_PORT=80
ENV FCREPO_CONTEXT_PATH=fcrepo
ENV FCREPO_PROXYURI=http://${FCREPO_HOST}/${FCREPO_CONTEXT_PATH}
ENV FCREPO_BASEURI=http://${FCREPO_HOST}/${FCREPO_CONTEXT_PATH}/rest
ENV APIX_VERSION=0.3.0-SNAPSHOT \
APIX_PORT=80 \
APIX_BASEURI=http://localhost:${APIX_PORT}/${APIX_INTERCEPT_PATH} \
FCREPO_HOST=fcrepo \
FCREPO_PORT=80 \
FCREPO_CONTEXT_PATH=fcrepo \
APIX_PROXY_PATH=fcrepo \
APIX_INTERCEPT_PATH=fcrepo/rest \
FCREPO_PROXYURI=http://${FCREPO_HOST}/${FCREPO_CONTEXT_PATH} \
FCREPO_BASEURI=http://${FCREPO_HOST}/${FCREPO_CONTEXT_PATH}/rest \
DEBUG_PORT=5011 \
JAVA_DEBUG_PORT=5011

# API-X base URI
ENV APIX_PORT=80
ENV APIX_PROXY_PATH=${FCREPO_CONTEXT_PATH}
ENV APIX_INTERCEPT_PATH=${FCREPO_CONTEXT_PATH}/rest
ENV APIX_BASEURI=http://localhost:${APIX_PORT}/${APIX_INTERCEPT_PATH}
EXPOSE ${APIX_PORT}

# Allow the string "apix" to be recognized by Karaf as the Fedora API-X feature repository

RUN echo "apixrepo=mvn:org.fcrepo.apix/fedora-api-x-karaf/${APIX_VERSION}/xml/features" >> etc/org.apache.karaf.features.repos.cfg

# Add apixrepo as a registered features repository by default

RUN sed -e "s:^\( mvn\:org.apache.karaf.features/enterprise/${KARAF_VERSION}/xml/features\):\1, \\\
mvn\:org.fcrepo.apix/fcrepo-api-x-karaf/${APIX_VERSION}/xml/features \\\:" \
-i etc/org.apache.karaf.features.cfg

# Update the Karaf logging configuration so that `bin/karaf` will echo logging
# to the console, viewable by `docker logs`

RUN sed -e "s/osgi:/stdout, osgi:/" -i etc/org.ops4j.pax.logging.cfg

# Copy API-X Karaf feature configuration files into the image
# (these files cannot be distributed with the Karaf feature due to issues with Karaf)

COPY cfg/* etc/
EXPOSE ${DEBUG_PORT}

# Temporary for local development; copy any Maven artifacts into `maven/` that you want the image build process to see (e.g. locally build features that have yet to be published)
#ADD maven/ /build/repository/

# Install all of the latest features found in the apixrepo features repository (typically these features will be SNAPSHOT versions) ...
# ... but do not create registry containers or attept to index registry content, as the Fedora repository is not available at image build time

RUN export REGISTRY_ONTOLOGY_CREATE=false && \
export REGISTRY_EXTENSION_CREATE=false && \
export REGISTRY_SERVICE_CREATE=false && \
export REGISTRY_ONTOLOGY_INDEX=false && \
echo "apixrepo=mvn:org.fcrepo.apix/fedora-api-x-karaf/${APIX_VERSION}/xml/features" >> etc/org.apache.karaf.features.repos.cfg && \
bin/start && \
bin/client -r 10 -d 5 "feature:repo-add mvn:org.fcrepo.apix/fcrepo-api-x-karaf/${APIX_VERSION}/xml/features" && \
bin/client -r 10 -d 5 "feature:install fcrepo-api-x" && \
bin/stop
bin/stop && \
rm -rf instances/*

COPY cfg/* etc/

COPY entrypoint.sh /entrypoint.sh

Expand All @@ -68,4 +46,4 @@ ENTRYPOINT [ "/entrypoint.sh" ]

# Launch Karaf with no console, and debugging enabled by default.

CMD [ "server", "debug" ]
CMD [ "server" ]
2 changes: 1 addition & 1 deletion apix/0.3.0-SNAPSHOT/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh

# Update the Karaf configuration so that the Maven repository under ${MAVEN_REPO}
# is used by Karaf to discover features.
Expand Down
25 changes: 9 additions & 16 deletions indexing/0.3.0-SNAPSHOT/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM fcrepoapix/apix-karaf:4.0.7@sha256:b258ee07e6e578fc80b791aa0a02d54bcf18dc94acb7c3b340bea3ea8949f7c7
FROM fcrepoapix/apix-karaf-camel:4.0.9@sha256:bbea3acdab13f6f6a321b1b9e08e2ce1af4e741f2ca31b36014f087f0fefa1a6

MAINTAINER Elliot Metsger <emetsger@jhu.edu>
LABEL description = "Provides a Karaf container configured with indexing features"
Expand All @@ -10,7 +10,9 @@ ENV APIX_VERSION=0.3.0-SNAPSHOT \
FCREPO_PORT=80 \
FCREPO_CONTEXT_PATH=/fcrepo \
DEBUG_PORT=5010 \
REINDEXING_PORT=9090
REINDEXING_PORT=9090 \
JAVA_DEBUG_PORT=${DEBUG_PORT} \
FCREPO_BASEURI=http://${FCREPO_HOST}:${FCREPO_PORT}${FCREPO_CONTEXT_PATH}/rest

# Temporary for local development; copy any Maven artifacts into `maven/` that you want the image build process to see (e.g. locally build features that have yet to be published)
#ADD maven/ /build/repository/
Expand All @@ -19,22 +21,12 @@ RUN bin/start && \
bin/client -r 10 -d 5 "feature:install fcrepo-api-x-registry" && \
bin/client -r 10 -d 5 "feature:install fcrepo-api-x-indexing" && \
bin/client -r 10 -d 5 "feature:install fcrepo-indexing-triplestore" && \
bin/stop


ENV JAVA_DEBUG_PORT=${DEBUG_PORT} \
FCREPO_BASEURI=http://${FCREPO_HOST}:${FCREPO_PORT}${FCREPO_CONTEXT_PATH}/rest

bin/stop && \
rm -rf instances/*

# Copy Karaf feature configuration files into the image
COPY cfg/* etc/


# Update the Karaf logging configuration so that `bin/karaf` will echo logging
# to the console, viewable by `docker logs`

RUN sed -e "s/osgi:/stdout, osgi:/" -i etc/org.ops4j.pax.logging.cfg

# Temporary for local development; copy any Maven artifacts into `maven/` that you want the image build process to see (e.g. locally build features that have yet to be published)
#ADD maven/ /build/repository/

Expand All @@ -45,5 +37,6 @@ RUN chmod 700 /entrypoint.sh
EXPOSE ${DEBUG_PORT} ${REINDEXING_PORT}
ENTRYPOINT [ "/entrypoint.sh" ]

# Launch Karaf with no console, and debugging enabled by default.
CMD [ "server", "debug" ]
# Launch Karaf with no console,

CMD [ "server" ]
2 changes: 1 addition & 1 deletion indexing/0.3.0-SNAPSHOT/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/bin/sh

# Update the Karaf configuration so that the Maven repository under ${MAVEN_REPO}
# is used by Karaf to discover features.
Expand Down
17 changes: 17 additions & 0 deletions karaf/4.0.9-camel/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM fcrepoapix/apix-karaf:4.0.9@sha256:d0a2910efaa3b97b508ca80225377ba2ce07a66078e61364d291b731f1bea1e8

MAINTAINER Elliot Metsger <emetsger@jhu.edu>
LABEL description = "Provides a Karaf container configured with Camel and Activemq pre-loaded"

# Camel and Activemq versions
ENV CAMEL_VERSION=2.18.4 \
ACTIVEMQ_VERSION=5.14.5

RUN bin/start && \
bin/client -r 10 -d 5 "feature:repo-add mvn:org.apache.camel.karaf/apache-camel/${CAMEL_VERSION}/xml/features" && \
bin/client -r 10 -d 5 "feature:repo-add mvn:org.apache.activemq/activemq-karaf/${ACTIVEMQ_VERSION}/xml/features" && \
bin/client -r 10 -d 5 "feature:install activemq-camel" && \
bin/client -r 10 -d 5 "feature:install camel-http4" && \
bin/client -r 10 -d 5 "feature:install camel-jetty" && \
bin/stop && \
rm -rf instances/*
7 changes: 7 additions & 0 deletions karaf/4.0.9-camel/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## karaf 4.0.9 Dockerfile

This image builds on the [Karaf 4.0.9 docker image](../4.0.9/README.md) by
installing Camel and ActiveMQ features. This is a mechanism that saves
comsiderable space, as Camel and ActiveMQ are larged. To the extent that
images are built off this one, the space consumed by Camel and ActiveMQ will
be shared between all images.
58 changes: 32 additions & 26 deletions karaf/4.0.7/Dockerfile → karaf/4.0.9/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,53 +1,59 @@
FROM openjdk:8u131-jre@sha256:a25ff451426302414f6e77af2c759ed7ee877f5bcaddba8b3bcced87d3db9d72
FROM openjdk:8u131-jre-alpine

MAINTAINER Elliot Metsger <emetsger@jhu.edu>
LABEL description = "Provides a Karaf container configured with a local Maven repository at ${MAVEN_REPO}"

# Location of the Karaf installation in the docker container
ENV KARAF_RUNTIME /opt/karaf

# The version of Karaf to download and install in the container
ENV KARAF_VERSION 4.0.7

ENV MAVEN_REPO /build/repository

# The port Karaf will listen on when debugging is enabled.
#
# Karaf actually pays attention to the value of JAVA_DEBUG_PORT, but in order
# to be consistent with the environment variable (DEBUG_PORT) documented and
# presented in the build/Dockerfile, assign the value of DEBUG_PORT to
# JAVA_DEBUG_PORT
ENV DEBUG_PORT 5007
ENV JAVA_DEBUG_PORT=${DEBUG_PORT}
ENV KARAF_VERSION=4.0.9 \
MAVEN_REPO=/build/repository \
KARAF_RUNTIME=/opt/karaf \
DEBUG_PORT=5007 \
JAVA_DEBUG_PORT=5007

EXPOSE ${DEBUG_PORT}
EXPOSE ${JAVA_DEBUG_PORT}

# Download and install Karaf, then clean up.
#
# Update the Karaf configuration so that the Maven repository under ${MAVEN_REPO}
# is used by Karaf to discover features.
#
# Start Karaf, run a simple command with the client (to verify that Karaf
# started) then stop it. This establishes some kind of state that enables
# commands to be scripted on container initialization
# See https://goo.gl/5VfWsn
RUN export KARAF_DIST=apache-karaf-${KARAF_VERSION}.tar.gz && \
echo "http://dl-3.alpinelinux.org/alpine/v3.6/main/" > /etc/apk/repositories && \
echo "http://dl-3.alpinelinux.org/alpine/v3.6/community/" > /etc/apk/repositories && \
echo "http://dl-4.alpinelinux.org/alpine/v3.6/main/" >> /etc/apk/repositories && \
echo "http://dl-4.alpinelinux.org/alpine/v3.6/community/" >> /etc/apk/repositories && \
echo "http://dl-5.alpinelinux.org/alpine/v3.6/main/" >> /etc/apk/repositories && \
echo "http://dl-5.alpinelinux.org/alpine/v3.6/community/" >> /etc/apk/repositories && \
apk --no-cache add --update curl && \
curl -SL "http://archive.apache.org/dist/karaf/${KARAF_VERSION}/${KARAF_DIST}" \
> /tmp/${KARAF_DIST} && \
mkdir -p ${KARAF_RUNTIME} && \
cd ${KARAF_RUNTIME} && \
tar -xzf /tmp/${KARAF_DIST} && \
rm -rf /tmp/apache-karaf-${KARAF_VERSION}*

WORKDIR ${KARAF_RUNTIME}/apache-karaf-${KARAF_VERSION}

# Update the Karaf configuration so that the Maven repository under ${MAVEN_REPO}
# is used by Karaf to discover features.
RUN sed -e "s:^#org.ops4j.pax.url.mvn.localRepository=:org.ops4j.pax.url.mvn.localRepository=${MAVEN_REPO}:" \
rm -rf /tmp/apache-karaf-${KARAF_VERSION}* && \
cd ${KARAF_RUNTIME}/apache-karaf-${KARAF_VERSION} && \
sed -e "s:^#org.ops4j.pax.url.mvn.localRepository=:org.ops4j.pax.url.mvn.localRepository=${MAVEN_REPO}:" \
-i etc/org.ops4j.pax.url.mvn.cfg && \
sed -e "s:^#\(org.ops4j.pax.url.mvn.defaultLocalRepoAsRemote=\)false:\1true:" \
-i etc/org.ops4j.pax.url.mvn.cfg
-i etc/org.ops4j.pax.url.mvn.cfg && \
bin/start && \
bin/client -r 10 -d 5 system:version && \
bin/stop && \
rm -rf instances/* && \
sed -e "s/osgi:/stdout, osgi:/" -i etc/org.ops4j.pax.logging.cfg

# Start Karaf, run a simple command with the client (to verify that Karaf
# started) then stop it. This establishes some kind of state that enables
# commands to be scripted on container initialization
# See https://goo.gl/5VfWsn

RUN bin/start && \
bin/client -r 10 -d 5 system:version && \
bin/stop
WORKDIR ${KARAF_RUNTIME}/apache-karaf-${KARAF_VERSION}

# Launch Karaf...
ENTRYPOINT [ "bin/karaf" ]
Expand Down
Loading

0 comments on commit 8528c3f

Please sign in to comment.