|
FROM cassandra-build-deb AS build-stage |
|
LABEL Author="Yuki Morishita <[email protected]>" |
|
|
|
ENV DEB_DIST_DIR="/home/build/dist" |
|
WORKDIR /home/build/cassandra |
|
RUN sed -i -e "s/4\.0/4\.0-SNAPSHOT/" debian/changelog \ |
|
# Copy fqltool.jar |
|
&& sed -i '/Copy stress jars/ i \\tdh_install build/tools/lib/fqltool.jar usr/share/cassandra' debian/rules \ |
|
# Add auditlogviewer & fqltool to cassandra-tools |
|
&& echo "tools/bin/auditlogviewer usr/bin\ntools/bin/fqltool usr/bin" >> debian/cassandra-tools.install \ |
|
&& mkdir -p ${DEB_DIST_DIR} \ |
|
&& /home/build/build-debs.sh trunk |
|
|
|
# |
|
# Final image based on https://github.com/docker-library/cassandra/blob/master/3.11/Dockerfile |
|
# |
|
FROM ubuntu:bionic |
|
|
|
RUN set -ex; \ |
|
apt-get update; \ |
|
apt-get install -y --no-install-recommends \ |
|
# solves warning: "jemalloc shared library could not be preloaded to speed up memory allocations" |
|
libjemalloc1 \ |
|
# free is used by cassandra-env.sh |
|
procps \ |
|
# "ip" is not required by Cassandra itself, but is commonly used in scripting Cassandra's configuration (since it is so fixated on explicit IP addresses) |
|
iproute2 \ |
|
; \ |
|
if ! command -v gpg > /dev/null; then \ |
|
apt-get install -y --no-install-recommends \ |
|
dirmngr \ |
|
gnupg \ |
|
; \ |
|
fi; \ |
|
rm -rf /var/lib/apt/lists/* |
|
|
|
# grab gosu for easy step-down from root |
|
ENV GOSU_VERSION 1.10 |
|
RUN set -x \ |
|
&& apt-get update && apt-get install -y --no-install-recommends ca-certificates wget && rm -rf /var/lib/apt/lists/* \ |
|
&& wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture)" \ |
|
&& wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture).asc" \ |
|
&& export GNUPGHOME="$(mktemp -d)" \ |
|
&& gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \ |
|
&& gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu \ |
|
&& { command -v gpgconf && gpgconf --kill all || :; } \ |
|
&& rm -rf "$GNUPGHOME" /usr/local/bin/gosu.asc \ |
|
&& chmod +x /usr/local/bin/gosu \ |
|
&& gosu nobody true \ |
|
&& apt-get purge -y --auto-remove ca-certificates wget |
|
|
|
COPY --from=build-stage "/home/build/dist/*.deb" /tmp/cassandra/ |
|
|
|
RUN set -ex; \ |
|
\ |
|
# https://bugs.debian.org/877677 |
|
# update-alternatives: error: error creating symbolic link '/usr/share/man/man1/rmid.1.gz.dpkg-tmp': No such file or directory |
|
mkdir -p /usr/share/man/man1/; \ |
|
\ |
|
# save a list of installed packages so build deps can be removed cleanly |
|
savedAptMark="$(apt-mark showmanual)"; \ |
|
\ |
|
# fetch a few build dependencies |
|
apt-get update; \ |
|
apt-get install -y --no-install-recommends dpkg-dev; \ |
|
# we don't remove APT lists here because they get re-downloaded and removed later |
|
\ |
|
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies |
|
# (which is done after we install the built packages so we don't have to redownload any overlapping dependencies) |
|
apt-mark showmanual | xargs apt-mark auto > /dev/null; \ |
|
apt-mark manual $savedAptMark; \ |
|
\ |
|
# create a temporary local APT repo to install from (so that dependency resolution can be handled by APT, as it should be) |
|
ls -lAFh /tmp/cassandra/; \ |
|
( cd /tmp/cassandra/ && dpkg-scanpackages . > Packages ); \ |
|
grep '^Package: ' /tmp/cassandra/Packages; \ |
|
echo "deb [ trusted=yes ] file:///tmp/cassandra ./" > /etc/apt/sources.list.d/temp.list; \ |
|
# work around the following APT issue by using "Acquire::GzipIndexes=false" (overriding "/etc/apt/apt.conf.d/docker-gzip-indexes") |
|
# Could not open file /var/lib/apt/lists/partial/_tmp_tmp.ODWljpQfkE_._Packages - open (13: Permission denied) |
|
# ... |
|
# E: Failed to fetch store:/var/lib/apt/lists/partial/_tmp_tmp.ODWljpQfkE_._Packages Could not open file /var/lib/apt/lists/partial/_tmp_tmp.ODWljpQfkE_._Packages - open (13: Permission denied) |
|
apt-get -o Acquire::GzipIndexes=false update; \ |
|
\ |
|
DEBIAN_FRONTEND=noninteractive apt-get install -y \ |
|
cassandra="4.0-SNAPSHOT" \ |
|
cassandra-tools="4.0-SNAPSHOT" \ |
|
; \ |
|
\ |
|
rm -rf /var/lib/apt/lists/*; \ |
|
\ |
|
if [ -n /tmp/cassandra ]; then \ |
|
# if we have leftovers from building, let's purge them (including extra, unnecessary build deps) |
|
apt-get purge -y --auto-remove; \ |
|
rm -rf /tmp/cassandra /etc/apt/sources.list.d/temp.list; \ |
|
fi |
|
|
|
ENV CASSANDRA_CONFIG /etc/cassandra |
|
|
|
RUN set -ex; \ |
|
\ |
|
dpkgArch="$(dpkg --print-architecture)"; \ |
|
case "$dpkgArch" in \ |
|
ppc64el) \ |
|
# https://issues.apache.org/jira/browse/CASSANDRA-13345 |
|
# "The stack size specified is too small, Specify at least 328k" |
|
if grep -q -- '^-Xss' "$CASSANDRA_CONFIG/jvm.options"; then \ |
|
# 3.11+ (jvm.options) |
|
grep -- '^-Xss256k$' "$CASSANDRA_CONFIG/jvm.options"; \ |
|
sed -ri 's/^-Xss256k$/-Xss512k/' "$CASSANDRA_CONFIG/jvm.options"; \ |
|
grep -- '^-Xss512k$' "$CASSANDRA_CONFIG/jvm.options"; \ |
|
elif grep -q -- '-Xss256k' "$CASSANDRA_CONFIG/cassandra-env.sh"; then \ |
|
# 3.0 (cassandra-env.sh) |
|
sed -ri 's/-Xss256k/-Xss512k/g' "$CASSANDRA_CONFIG/cassandra-env.sh"; \ |
|
grep -- '-Xss512k' "$CASSANDRA_CONFIG/cassandra-env.sh"; \ |
|
fi; \ |
|
;; \ |
|
esac; \ |
|
\ |
|
# https://issues.apache.org/jira/browse/CASSANDRA-11661 |
|
sed -ri 's/^(JVM_PATCH_VERSION)=.*/\1=25/' "$CASSANDRA_CONFIG/cassandra-env.sh" |
|
|
|
ADD https://raw.githubusercontent.com/docker-library/cassandra/master/docker-entrypoint.sh /usr/local/bin/ |
|
RUN chmod 755 usr/local/bin/docker-entrypoint.sh \ |
|
&& ln -s usr/local/bin/docker-entrypoint.sh /docker-entrypoint.sh # backwards compat |
|
ENTRYPOINT ["docker-entrypoint.sh"] |
|
|
|
RUN mkdir -p /var/lib/cassandra "$CASSANDRA_CONFIG" \ |
|
&& chown -R cassandra:cassandra /var/lib/cassandra "$CASSANDRA_CONFIG" \ |
|
&& chmod 777 /var/lib/cassandra "$CASSANDRA_CONFIG" |
|
VOLUME /var/lib/cassandra |
|
|
|
# 7000: intra-node communication |
|
# 7001: TLS intra-node communication |
|
# 7199: JMX |
|
# 9042: CQL |
|
EXPOSE 7000 7001 7199 9042 |
|
CMD ["cassandra", "-f"] |