diff --git a/2.1/Dockerfile b/2.1/Dockerfile index 0d9df8b..f1e06b5 100644 --- a/2.1/Dockerfile +++ b/2.1/Dockerfile @@ -1,5 +1,19 @@ +# vim:set ft=dockerfile: FROM debian:jessie-backports +# explicitly set user/group IDs +RUN groupadd -r cassandra --gid=999 && useradd -r -g cassandra --uid=999 cassandra + +# grab gosu for easy step-down from root +RUN gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 +RUN 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/1.2/gosu-$(dpkg --print-architecture)" \ + && wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/1.2/gosu-$(dpkg --print-architecture).asc" \ + && gpg --verify /usr/local/bin/gosu.asc \ + && rm /usr/local/bin/gosu.asc \ + && chmod +x /usr/local/bin/gosu \ + && apt-get purge -y --auto-remove ca-certificates wget + RUN apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys 514A2AD631A57A16DD0047EC749D6EEC0353B12C RUN echo 'deb http://www.apache.org/dist/cassandra/debian 21x main' >> /etc/apt/sources.list.d/cassandra.list @@ -15,6 +29,9 @@ ENV CASSANDRA_CONFIG /etc/cassandra COPY docker-entrypoint.sh /docker-entrypoint.sh 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 diff --git a/2.1/docker-entrypoint.sh b/2.1/docker-entrypoint.sh index 31fd2a0..c34d728 100755 --- a/2.1/docker-entrypoint.sh +++ b/2.1/docker-entrypoint.sh @@ -6,6 +6,12 @@ if [ "${1:0:1}" = '-' ]; then set -- cassandra -f "$@" fi +# allow the container to be started with `--user` +if [ "$1" = 'cassandra' -a "$(id -u)" = '0' ]; then + chown -R cassandra /var/lib/cassandra "$CASSANDRA_CONFIG" + exec gosu cassandra "$BASH_SOURCE" "$@" +fi + if [ "$1" = 'cassandra' ]; then : ${CASSANDRA_RPC_ADDRESS='0.0.0.0'} diff --git a/2.2/Dockerfile b/2.2/Dockerfile index 21c02fc..999f8d9 100644 --- a/2.2/Dockerfile +++ b/2.2/Dockerfile @@ -1,5 +1,19 @@ +# vim:set ft=dockerfile: FROM debian:jessie-backports +# explicitly set user/group IDs +RUN groupadd -r cassandra --gid=999 && useradd -r -g cassandra --uid=999 cassandra + +# grab gosu for easy step-down from root +RUN gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 +RUN 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/1.2/gosu-$(dpkg --print-architecture)" \ + && wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/1.2/gosu-$(dpkg --print-architecture).asc" \ + && gpg --verify /usr/local/bin/gosu.asc \ + && rm /usr/local/bin/gosu.asc \ + && chmod +x /usr/local/bin/gosu \ + && apt-get purge -y --auto-remove ca-certificates wget + RUN apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys 514A2AD631A57A16DD0047EC749D6EEC0353B12C RUN echo 'deb http://www.apache.org/dist/cassandra/debian 22x main' >> /etc/apt/sources.list.d/cassandra.list @@ -15,6 +29,9 @@ ENV CASSANDRA_CONFIG /etc/cassandra COPY docker-entrypoint.sh /docker-entrypoint.sh 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 diff --git a/2.2/docker-entrypoint.sh b/2.2/docker-entrypoint.sh index 31fd2a0..c34d728 100755 --- a/2.2/docker-entrypoint.sh +++ b/2.2/docker-entrypoint.sh @@ -6,6 +6,12 @@ if [ "${1:0:1}" = '-' ]; then set -- cassandra -f "$@" fi +# allow the container to be started with `--user` +if [ "$1" = 'cassandra' -a "$(id -u)" = '0' ]; then + chown -R cassandra /var/lib/cassandra "$CASSANDRA_CONFIG" + exec gosu cassandra "$BASH_SOURCE" "$@" +fi + if [ "$1" = 'cassandra' ]; then : ${CASSANDRA_RPC_ADDRESS='0.0.0.0'} diff --git a/3.0/Dockerfile b/3.0/Dockerfile index 61fcc79..0d67e5e 100644 --- a/3.0/Dockerfile +++ b/3.0/Dockerfile @@ -1,5 +1,19 @@ +# vim:set ft=dockerfile: FROM debian:jessie-backports +# explicitly set user/group IDs +RUN groupadd -r cassandra --gid=999 && useradd -r -g cassandra --uid=999 cassandra + +# grab gosu for easy step-down from root +RUN gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 +RUN 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/1.2/gosu-$(dpkg --print-architecture)" \ + && wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/1.2/gosu-$(dpkg --print-architecture).asc" \ + && gpg --verify /usr/local/bin/gosu.asc \ + && rm /usr/local/bin/gosu.asc \ + && chmod +x /usr/local/bin/gosu \ + && apt-get purge -y --auto-remove ca-certificates wget + RUN apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys 514A2AD631A57A16DD0047EC749D6EEC0353B12C RUN echo 'deb http://www.apache.org/dist/cassandra/debian 30x main' >> /etc/apt/sources.list.d/cassandra.list @@ -15,6 +29,9 @@ ENV CASSANDRA_CONFIG /etc/cassandra COPY docker-entrypoint.sh /docker-entrypoint.sh 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 diff --git a/3.0/docker-entrypoint.sh b/3.0/docker-entrypoint.sh index 31fd2a0..c34d728 100755 --- a/3.0/docker-entrypoint.sh +++ b/3.0/docker-entrypoint.sh @@ -6,6 +6,12 @@ if [ "${1:0:1}" = '-' ]; then set -- cassandra -f "$@" fi +# allow the container to be started with `--user` +if [ "$1" = 'cassandra' -a "$(id -u)" = '0' ]; then + chown -R cassandra /var/lib/cassandra "$CASSANDRA_CONFIG" + exec gosu cassandra "$BASH_SOURCE" "$@" +fi + if [ "$1" = 'cassandra' ]; then : ${CASSANDRA_RPC_ADDRESS='0.0.0.0'} diff --git a/3.1/Dockerfile b/3.1/Dockerfile index 6779a54..7dc81c6 100644 --- a/3.1/Dockerfile +++ b/3.1/Dockerfile @@ -1,5 +1,19 @@ +# vim:set ft=dockerfile: FROM debian:jessie-backports +# explicitly set user/group IDs +RUN groupadd -r cassandra --gid=999 && useradd -r -g cassandra --uid=999 cassandra + +# grab gosu for easy step-down from root +RUN gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 +RUN 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/1.2/gosu-$(dpkg --print-architecture)" \ + && wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/1.2/gosu-$(dpkg --print-architecture).asc" \ + && gpg --verify /usr/local/bin/gosu.asc \ + && rm /usr/local/bin/gosu.asc \ + && chmod +x /usr/local/bin/gosu \ + && apt-get purge -y --auto-remove ca-certificates wget + RUN apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys 514A2AD631A57A16DD0047EC749D6EEC0353B12C RUN echo 'deb http://www.apache.org/dist/cassandra/debian 31x main' >> /etc/apt/sources.list.d/cassandra.list @@ -15,6 +29,9 @@ ENV CASSANDRA_CONFIG /etc/cassandra COPY docker-entrypoint.sh /docker-entrypoint.sh 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 diff --git a/3.1/docker-entrypoint.sh b/3.1/docker-entrypoint.sh index 31fd2a0..c34d728 100755 --- a/3.1/docker-entrypoint.sh +++ b/3.1/docker-entrypoint.sh @@ -6,6 +6,12 @@ if [ "${1:0:1}" = '-' ]; then set -- cassandra -f "$@" fi +# allow the container to be started with `--user` +if [ "$1" = 'cassandra' -a "$(id -u)" = '0' ]; then + chown -R cassandra /var/lib/cassandra "$CASSANDRA_CONFIG" + exec gosu cassandra "$BASH_SOURCE" "$@" +fi + if [ "$1" = 'cassandra' ]; then : ${CASSANDRA_RPC_ADDRESS='0.0.0.0'} diff --git a/3.2/Dockerfile b/3.2/Dockerfile index f09c8cb..ddfc997 100644 --- a/3.2/Dockerfile +++ b/3.2/Dockerfile @@ -1,5 +1,19 @@ +# vim:set ft=dockerfile: FROM debian:jessie-backports +# explicitly set user/group IDs +RUN groupadd -r cassandra --gid=999 && useradd -r -g cassandra --uid=999 cassandra + +# grab gosu for easy step-down from root +RUN gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 +RUN 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/1.2/gosu-$(dpkg --print-architecture)" \ + && wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/1.2/gosu-$(dpkg --print-architecture).asc" \ + && gpg --verify /usr/local/bin/gosu.asc \ + && rm /usr/local/bin/gosu.asc \ + && chmod +x /usr/local/bin/gosu \ + && apt-get purge -y --auto-remove ca-certificates wget + RUN apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys 514A2AD631A57A16DD0047EC749D6EEC0353B12C RUN echo 'deb http://www.apache.org/dist/cassandra/debian 32x main' >> /etc/apt/sources.list.d/cassandra.list @@ -15,6 +29,9 @@ ENV CASSANDRA_CONFIG /etc/cassandra COPY docker-entrypoint.sh /docker-entrypoint.sh 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 diff --git a/3.2/docker-entrypoint.sh b/3.2/docker-entrypoint.sh index 31fd2a0..c34d728 100755 --- a/3.2/docker-entrypoint.sh +++ b/3.2/docker-entrypoint.sh @@ -6,6 +6,12 @@ if [ "${1:0:1}" = '-' ]; then set -- cassandra -f "$@" fi +# allow the container to be started with `--user` +if [ "$1" = 'cassandra' -a "$(id -u)" = '0' ]; then + chown -R cassandra /var/lib/cassandra "$CASSANDRA_CONFIG" + exec gosu cassandra "$BASH_SOURCE" "$@" +fi + if [ "$1" = 'cassandra' ]; then : ${CASSANDRA_RPC_ADDRESS='0.0.0.0'} diff --git a/Dockerfile.template b/Dockerfile.template index f9f4686..526d61d 100644 --- a/Dockerfile.template +++ b/Dockerfile.template @@ -1,5 +1,19 @@ +# vim:set ft=dockerfile: FROM debian:jessie-backports +# explicitly set user/group IDs +RUN groupadd -r cassandra --gid=999 && useradd -r -g cassandra --uid=999 cassandra + +# grab gosu for easy step-down from root +RUN gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 +RUN 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/1.2/gosu-$(dpkg --print-architecture)" \ + && wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/1.2/gosu-$(dpkg --print-architecture).asc" \ + && gpg --verify /usr/local/bin/gosu.asc \ + && rm /usr/local/bin/gosu.asc \ + && chmod +x /usr/local/bin/gosu \ + && apt-get purge -y --auto-remove ca-certificates wget + RUN apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys 514A2AD631A57A16DD0047EC749D6EEC0353B12C RUN echo 'deb http://www.apache.org/dist/cassandra/debian %%CASSANDRA_DIST%%x main' >> /etc/apt/sources.list.d/cassandra.list @@ -15,6 +29,9 @@ ENV CASSANDRA_CONFIG /etc/cassandra COPY docker-entrypoint.sh /docker-entrypoint.sh 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 diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 31fd2a0..c34d728 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -6,6 +6,12 @@ if [ "${1:0:1}" = '-' ]; then set -- cassandra -f "$@" fi +# allow the container to be started with `--user` +if [ "$1" = 'cassandra' -a "$(id -u)" = '0' ]; then + chown -R cassandra /var/lib/cassandra "$CASSANDRA_CONFIG" + exec gosu cassandra "$BASH_SOURCE" "$@" +fi + if [ "$1" = 'cassandra' ]; then : ${CASSANDRA_RPC_ADDRESS='0.0.0.0'}