This repository has been archived by the owner on Feb 21, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
135 lines (119 loc) · 4.68 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#
# Copyright 2017 Apereo Foundation (AF) Licensed under the
# Educational Community License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may
# obtain a copy of the License at
#
# http://opensource.org/licenses/ECL-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an "AS IS"
# BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
# or implied. See the License for the specific language governing
# permissions and limitations under the License.
#
#
# Step 1: Build the image
# $ docker build -f Dockerfile -t oae-cassandra:latest .
# Step 2: Run image
# $ docker run -it --name=cassandra --net=host oae-cassandra:latest
#
FROM openjdk:8-jre-alpine
LABEL Name=OAE-Cassandra
LABEL Author=ApereoFoundation
LABEL [email protected]
#
# Forked and adapted from official cassandra image
# available on https://hub.docker.com/_/cassandra/
# and
# https://hub.docker.com/r/nebo15/alpine-cassandra/~/dockerfile/
#
# Important! Update this no-op ENV variable when this Dockerfile # is updated with the current date. It will force refresh of all # of the base images and things like `apt-get update` won't be using # old cached versions when the Dockerfile is built.
ENV REFRESHED_AT=2016-10-14
ENV LANG=en_US.UTF-8
ENV TERM=xterm
ENV HOME=/
# Install gosu
ENV GOSU_VERSION=1.10
RUN set -x && \
apk add --no-cache --virtual .gosu-deps \
dpkg \
gnupg \
openssl && \
dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')" && \
wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch" && \
wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$dpkgArch.asc" && \
export GNUPGHOME="$(mktemp -d)" && \
gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 && \
gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu && \
rm -r /usr/local/bin/gosu.asc && \
chmod +x /usr/local/bin/gosu && \
gosu nobody true && \
apk --purge del .gosu-deps
# Install Cassandra
ENV CASSANDRA_VERSION=2.1.19
ENV CASSANDRA_HOME=/opt/cassandra \
CASSANDRA_CONFIG=/etc/cassandra \
CASSANDRA_PERSIST_DIR=/var/lib/cassandra \
CASSANDRA_DATA=/var/lib/cassandra/data \
CASSANDRA_COMMITLOG=/var/lib/cassandra/commitlog \
CASSANDRA_LOG=/var/log/cassandra \
CASSANDRA_USER=cassandra
## Create data directories that should be used by Cassandra
RUN mkdir -p ${CASSANDRA_DATA} \
${CASSANDRA_HOME} \
${CASSANDRA_CONFIG} \
${CASSANDRA_LOG} \
${CASSANDRA_COMMITLOG}
### Apache Cassandra
RUN apk --update --no-cache add wget ca-certificates tar && \
wget http://artfiles.org/apache.org/cassandra/${CASSANDRA_VERSION}/apache-cassandra-${CASSANDRA_VERSION}-bin.tar.gz -P /tmp && \
tar -xvzf /tmp/apache-cassandra-${CASSANDRA_VERSION}-bin.tar.gz -C /tmp/ && \
mv /tmp/apache-cassandra-${CASSANDRA_VERSION} ${CASSANDRA_HOME} && \
rm -rf /tmp/apache-cassandra-${CASSANDRA_VERSION}-bin.tar.gz && \
apk --purge del wget ca-certificates tar && \
rm -rf /var/cache/apk/*
# Setup entrypoint and bash to execute it
COPY docker-entrypoint.sh /docker-entrypoint.sh
RUN apk add --update --no-cache bash && \
chmod +x /docker-entrypoint.sh
ENTRYPOINT ["/bin/bash", "/docker-entrypoint.sh"]
# Change CASSANDRA_HOME ENV var to the correct folder
ENV CASSANDRA_HOME=/opt/cassandra/apache-cassandra-${CASSANDRA_VERSION}
# Add default config
RUN mv ${CASSANDRA_HOME}/conf/* ${CASSANDRA_CONFIG}
# COPY ./conf/* ${CASSANDRA_CONFIG}/
RUN chmod +x ${CASSANDRA_CONFIG}/*.sh
# https://issues.apache.org/jira/browse/CASSANDRA-11661
RUN sed -ri 's/^(JVM_PATCH_VERSION)=.*/\1=25/' /etc/cassandra/cassandra-env.sh
# Add cassandra bin to PATH
ENV PATH=$PATH:${CASSANDRA_HOME}/bin \
CASSANDRA_CONF=${CASSANDRA_CONFIG}
# Change directories ownership and access rights
RUN adduser -D -s /bin/sh ${CASSANDRA_USER} && \
chown -R ${CASSANDRA_USER}:${CASSANDRA_USER} ${CASSANDRA_HOME} \
${CASSANDRA_PERSIST_DIR} \
${CASSANDRA_DATA} \
${CASSANDRA_CONFIG} \
${CASSANDRA_LOG} \
${CASSANDRA_COMMITLOG} && \
chmod 777 ${CASSANDRA_HOME} \
${CASSANDRA_PERSIST_DIR} \
${CASSANDRA_DATA} \
${CASSANDRA_CONFIG} \
${CASSANDRA_LOG} \
${CASSANDRA_COMMITLOG}
USER ${CASSANDRA_USER}
WORKDIR ${CASSANDRA_HOME}
# Expose data volume
VOLUME ${CASSANDRA_PERSIST_DIR}
# 7000: intra-node communication
# 7001: TLS intra-node communication
# 7199: JMX
# 9042: CQL
# 9160: thrift service
EXPOSE 7000 7001 7199 9042 9160
# debug
RUN ls -la ${CASSANDRA_HOME}/bin
# RUN echo $PATH
CMD ["cassandra", "-f", "JVM_OPTS='$JVM_OPTS -Dcassandra.unsafesystem=true'"]