Skip to content

Put "docker-entrypoint.sh" into PATH and allow it to run Cassandra when given no arguments #130

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

Merged
merged 1 commit into from
Jan 3, 2018
Merged
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
5 changes: 3 additions & 2 deletions 2.1/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,9 @@ RUN set -ex; \
# https://issues.apache.org/jira/browse/CASSANDRA-11661
sed -ri 's/^(JVM_PATCH_VERSION)=.*/\1=25/' "$CASSANDRA_CONFIG/cassandra-env.sh"

COPY docker-entrypoint.sh /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]
COPY docker-entrypoint.sh /usr/local/bin/
RUN 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" \
Expand Down
3 changes: 2 additions & 1 deletion 2.1/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
set -e

# first arg is `-f` or `--some-option`
if [ "${1:0:1}" = '-' ]; then
# or there are no args
if [ "$#" -eq 0 ] || [ "${1#-}" != "$1" ]; then
set -- cassandra -f "$@"
fi

Expand Down
5 changes: 3 additions & 2 deletions 2.2/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,9 @@ RUN set -ex; \
# https://issues.apache.org/jira/browse/CASSANDRA-11661
sed -ri 's/^(JVM_PATCH_VERSION)=.*/\1=25/' "$CASSANDRA_CONFIG/cassandra-env.sh"

COPY docker-entrypoint.sh /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]
COPY docker-entrypoint.sh /usr/local/bin/
RUN 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" \
Expand Down
3 changes: 2 additions & 1 deletion 2.2/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
set -e

# first arg is `-f` or `--some-option`
if [ "${1:0:1}" = '-' ]; then
# or there are no args
if [ "$#" -eq 0 ] || [ "${1#-}" != "$1" ]; then
set -- cassandra -f "$@"
fi

Expand Down
5 changes: 3 additions & 2 deletions 3.0/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,9 @@ RUN set -ex; \
# https://issues.apache.org/jira/browse/CASSANDRA-11661
sed -ri 's/^(JVM_PATCH_VERSION)=.*/\1=25/' "$CASSANDRA_CONFIG/cassandra-env.sh"

COPY docker-entrypoint.sh /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]
COPY docker-entrypoint.sh /usr/local/bin/
RUN 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" \
Expand Down
3 changes: 2 additions & 1 deletion 3.0/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
set -e

# first arg is `-f` or `--some-option`
if [ "${1:0:1}" = '-' ]; then
# or there are no args
if [ "$#" -eq 0 ] || [ "${1#-}" != "$1" ]; then
set -- cassandra -f "$@"
fi

Expand Down
5 changes: 3 additions & 2 deletions 3.11/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,9 @@ RUN set -ex; \
# https://issues.apache.org/jira/browse/CASSANDRA-11661
sed -ri 's/^(JVM_PATCH_VERSION)=.*/\1=25/' "$CASSANDRA_CONFIG/cassandra-env.sh"

COPY docker-entrypoint.sh /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]
COPY docker-entrypoint.sh /usr/local/bin/
RUN 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" \
Expand Down
3 changes: 2 additions & 1 deletion 3.11/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
set -e

# first arg is `-f` or `--some-option`
if [ "${1:0:1}" = '-' ]; then
# or there are no args
if [ "$#" -eq 0 ] || [ "${1#-}" != "$1" ]; then
set -- cassandra -f "$@"
fi

Expand Down
5 changes: 3 additions & 2 deletions Dockerfile.template
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,9 @@ RUN set -ex; \
# https://issues.apache.org/jira/browse/CASSANDRA-11661
sed -ri 's/^(JVM_PATCH_VERSION)=.*/\1=25/' "$CASSANDRA_CONFIG/cassandra-env.sh"

COPY docker-entrypoint.sh /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]
COPY docker-entrypoint.sh /usr/local/bin/
RUN 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" \
Expand Down
3 changes: 2 additions & 1 deletion docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
set -e

# first arg is `-f` or `--some-option`
if [ "${1:0:1}" = '-' ]; then
# or there are no args
if [ "$#" -eq 0 ] || [ "${1#-}" != "$1" ]; then
set -- cassandra -f "$@"
fi

Expand Down
33 changes: 23 additions & 10 deletions update.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
set -eo pipefail
#!/usr/bin/env bash
set -Eeuo pipefail

cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"

Expand All @@ -13,14 +13,27 @@ travisEnv=
for version in "${versions[@]}"; do
dist="${version//./}"
packagesUrl="http://www.apache.org/dist/cassandra/debian/dists/${dist}x/main/binary-amd64/Packages.gz"
fullVersion="$(curl -fsSL "$packagesUrl" | gunzip | awk -F ': ' '$1 == "Package" { pkg = $2 } pkg == "cassandra" && $1 == "Version" { print $2 }')"

(
set -x
cp docker-entrypoint.sh "$version/"
sed 's/%%CASSANDRA_DIST%%/'$dist'/g; s/%%CASSANDRA_VERSION%%/'$fullVersion'/g' Dockerfile.template > "$version/Dockerfile"
)

fullVersion="$(
curl -fsSL "$packagesUrl" \
| gunzip \
| awk -F ': ' '
$1 == "Package" { pkg = $2 }
pkg == "cassandra" && $1 == "Version" { print $2 }
'
)"

echo "$version: $fullVersion"

cp -a docker-entrypoint.sh "$version/"
sed 's/%%CASSANDRA_DIST%%/'$dist'/g; s/%%CASSANDRA_VERSION%%/'$fullVersion'/g' Dockerfile.template > "$version/Dockerfile"

# remove the "/docker-entrypoint.sh" backwards-compatibility symlink in Cassandra 3.12+
case "$version" in
2.*|3.0|3.11) ;;
*) sed -i '/^RUN .* \/docker-entrypoint.sh # backwards compat$/d' "$version/Dockerfile" ;;
esac
# TODO once Cassandra 2.x and 3.x are deprecated, we should remove this from the template itself (and remove this code too)

travisEnv='\n - VERSION='"$version ARCH=i386$travisEnv"
travisEnv='\n - VERSION='"$version$travisEnv"
done
Expand Down