Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Puts image on a diet (Alpine+OpenJDK8) #19

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 42 additions & 25 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,46 +1,63 @@
FROM debian:7.8
FROM alpine:3.3
MAINTAINER Mike Babineau [email protected]

ENV \
MAVEN_HOME="/usr/share/maven" \
JAVA_HOME="/usr/lib/jvm/default-jvm" \
JAVA_PREFS="/.java/.userPrefs" \
ZK_HOME="/opt/zookeeper" \
EXBT_HOME="/opt/exhibitor" \
ZK_RELEASE="http://www.apache.org/dist/zookeeper/zookeeper-3.4.6/zookeeper-3.4.6.tar.gz" \
EXHIBITOR_POM="https://raw.githubusercontent.com/Netflix/exhibitor/d911a16d704bbe790d84bbacc655ef050c1f5806/exhibitor-standalone/src/main/resources/buildscripts/standalone/maven/pom.xml" \
# Append "+" to ensure the package doesn't get purged
BUILD_DEPS="curl maven openjdk-7-jdk+" \
DEBIAN_FRONTEND="noninteractive"
BUILD_DEPS="curl openjdk8 bash tar"

ENV PATH=${JAVA_HOME}/bin:${PATH}

# Use one step so we can remove intermediate dependencies and minimize size
RUN \
# Install dependencies
apt-get update \
&& apt-get install -y --allow-unauthenticated --no-install-recommends $BUILD_DEPS \
# Install Java8
apk add --update ${BUILD_DEPS} \

# Default DNS cache TTL is -1. DNS records, like, change, man
&& grep '^networkaddress.cache.ttl=' ${JAVA_HOME}/jre/lib/security/java.security || echo 'networkaddress.cache.ttl=60' >> ${JAVA_HOME}/jre/lib/security/java.security \

# Default DNS cache TTL is -1. DNS records, like, change, man.
&& grep '^networkaddress.cache.ttl=' /etc/java-7-openjdk/security/java.security || echo 'networkaddress.cache.ttl=60' >> /etc/java-7-openjdk/security/java.security \
# Cleanup
&& rm -rf -- /var/cache/apk/* \

# Install Maven
&& MAVEN_VERSION=3.3.3 \
&& cd /usr/share \
&& wget -q http://archive.apache.org/dist/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.tar.gz -O - | tar xzf - \
&& mv /usr/share/apache-maven-${MAVEN_VERSION} /usr/share/maven \
&& ln -s /usr/share/maven/bin/mvn /usr/bin/mvn

RUN \
mkdir -p /opt \

# Install ZK
&& curl -Lo /tmp/zookeeper.tgz $ZK_RELEASE \
&& mkdir -p /opt/zookeeper/transactions /opt/zookeeper/snapshots \
&& tar -xzf /tmp/zookeeper.tgz -C /opt/zookeeper --strip=1 \
&& curl -Lo /tmp/zookeeper.tgz ${ZK_RELEASE} \
&& mkdir -p ${ZK_HOME}/transactions ${ZK_HOME}/snapshots \
&& tar -xzf /tmp/zookeeper.tgz -C ${ZK_HOME} --strip-components=1 \
&& rm /tmp/zookeeper.tgz \

# Install Exhibitor
&& mkdir -p /opt/exhibitor \
&& curl -Lo /opt/exhibitor/pom.xml $EXHIBITOR_POM \
&& mvn -f /opt/exhibitor/pom.xml package \
&& ln -s /opt/exhibitor/target/exhibitor*jar /opt/exhibitor/exhibitor.jar \

# Remove build-time dependencies
&& apt-get purge -y --auto-remove $BUILD_DEPS \
&& rm -rf /var/lib/apt/lists/*
&& mkdir -p ${EXBT_HOME} \
&& curl -Lo ${EXBT_HOME}/pom.xml ${EXHIBITOR_POM} \
&& mvn -f ${EXBT_HOME}/pom.xml package \
&& ln -s ${EXBT_HOME}/target/exhibitor*jar ${EXBT_HOME}/exhibitor.jar \
&& chown -R nobody.nobody ${ZK_HOME} ${EXBT_HOME}

# Add the wrapper script to setup configs and exec exhibitor
ADD include/wrapper.sh /opt/exhibitor/wrapper.sh
ADD include/wrapper.sh ${EXBT_HOME}/wrapper.sh

# Add the optional web.xml for authentication
ADD include/web.xml /opt/exhibitor/web.xml
ADD include/web.xml ${EXBT_HOME}/web.xml

# To store Java preferences
RUN mkdir -p ${JAVA_PREFS}
RUN chown -R nobody.nobody ${JAVA_PREFS}

USER root
USER nobody
WORKDIR /opt/exhibitor
EXPOSE 2181 2888 3888 8181

ENTRYPOINT ["bash", "-ex", "/opt/exhibitor/wrapper.sh"]
ENTRYPOINT ["bash", "-ex", "/opt/exhibitor/wrapper.sh"]
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
THE SOFTWARE.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ Available on the Docker Index as [mbabineau/zookeeper-exhibitor](https://index.d

docker pull mbabineau/zookeeper-exhibitor

The image is based on Alpine Linux and is ~272MB.

### Versions
* Exhibitor 1.5.5
* ZooKeeper 3.4.6
* Java 1.8

### Usage
The container expects the following environment variables to be passed in:
Expand Down