forked from k8ssandra/management-api-for-apache-cassandra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile-4_1.ubi8
169 lines (142 loc) · 7.8 KB
/
Dockerfile-4_1.ubi8
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
ARG UBI_MAJOR=8
ARG UBI_BASETAG=latest
ARG CASSANDRA_VERSION=4.1.2
FROM registry.access.redhat.com/ubi${UBI_MAJOR}/ubi-minimal:${UBI_BASETAG} AS builder
ARG URL_PREFIX=https://dlcdn.apache.org/cassandra
ARG METRICS_COLLECTOR_VERSION=0.3.4
ARG METRICS_COLLECTOR_BUNDLE=${METRICS_COLLECTOR_VERSION}-4.1-beta1
ARG CASSANDRA_VERSION
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8'
# Update base layer
RUN microdnf update && rm -rf /var/cache/yum \
# Install packages needed during install process
&& microdnf install shadow-utils tar gzip unzip && microdnf clean all
# COPY in files if they are available locally
COPY * /
WORKDIR /
###
# Download and extract Metrics Collector
###
ENV MCAC_PATH /opt/metrics-collector
RUN mkdir -m 775 ${MCAC_PATH} && \
if test ! -e datastax-mcac-agent-${METRICS_COLLECTOR_VERSION}.tar.gz; then curl -L -O "https://github.com/datastax/metric-collector-for-apache-cassandra/releases/download/v${METRICS_COLLECTOR_VERSION}/datastax-mcac-agent-${METRICS_COLLECTOR_BUNDLE}.tar.gz"; fi && \
tar --directory ${MCAC_PATH} --strip-components 1 --gzip --extract --file datastax-mcac-agent-${METRICS_COLLECTOR_BUNDLE}.tar.gz && \
chmod -R g+w ${MCAC_PATH}
###
# Download CDC Agent jarfile
###
ARG CDC_AGENT_VERSION=2.2.9
ARG CDC_AGENT_EDITION=agent-c4
ENV CDC_AGENT_PATH=/opt/cdc_agent
RUN mkdir -m 775 ${CDC_AGENT_PATH} && \
curl -L -O "https://github.com/datastax/cdc-apache-cassandra/releases/download/v${CDC_AGENT_VERSION}/${CDC_AGENT_EDITION}-${CDC_AGENT_VERSION}-all.jar" && \
ln -s ${CDC_AGENT_EDITION}-${CDC_AGENT_VERSION}-all.jar ${CDC_AGENT_PATH}/cdc-agent.jar && \
chmod -R g+w ${CDC_AGENT_PATH}
###
# Download Cassandra archive
###
ENV CASSANDRA_HOME /opt/cassandra
# Add Cassandra user
RUN groupadd -r cassandra --gid=999 && \
useradd -m -d "$CASSANDRA_HOME" -r -g cassandra -G root --uid=999 cassandra && \
if test ! -e apache-cassandra-${CASSANDRA_VERSION}-bin.tar.gz; then curl -L -O "https://archive.apache.org/dist/cassandra/${CASSANDRA_VERSION}/apache-cassandra-${CASSANDRA_VERSION}-bin.tar.gz"; fi && \
tar --directory ${CASSANDRA_HOME} --strip-components 1 --extract --gzip --file apache-cassandra-${CASSANDRA_VERSION}-bin.tar.gz && \
chown -R cassandra:root ${CASSANDRA_HOME} && \
chmod -R a+rwX ${CASSANDRA_HOME}
#############################################################
# Build the Management API
FROM --platform=$BUILDPLATFORM maven:3.8.6-openjdk-11-slim as mgmtapi-setup
WORKDIR /
ENV MAAC_PATH /opt/management-api
ENV DSE_HOME /opt/dse
COPY pom.xml /tmp/pom.xml
COPY management-api-agent-common/pom.xml /tmp/management-api-agent-common/pom.xml
COPY management-api-agent-3.x/pom.xml /tmp/management-api-agent-3.x/pom.xml
COPY management-api-agent-4.x/pom.xml /tmp/management-api-agent-4.x/pom.xml
COPY management-api-agent-4.1.x/pom.xml /tmp/management-api-agent-4.1.x/pom.xml
COPY management-api-common/pom.xml /tmp/management-api-common/pom.xml
COPY management-api-server/pom.xml /tmp/management-api-server/pom.xml
# this duplicates work done in the next steps, but this should provide
# a solid cache layer that only gets reset on pom.xml changes
RUN cd /tmp && mvn -q -ff -T 1C install -DskipOpenApi && rm -rf target
COPY management-api-agent-common /tmp/management-api-agent-common
COPY management-api-agent-3.x /tmp/management-api-agent-3.x
COPY management-api-agent-4.x /tmp/management-api-agent-4.x
COPY management-api-agent-4.1.x /tmp/management-api-agent-4.1.x
COPY management-api-common /tmp/management-api-common
COPY management-api-server /tmp/management-api-server
RUN mkdir -m 775 ${MAAC_PATH} \
&& cd /tmp \
&& mvn -q -ff package -DskipTests -DskipOpenApi \
&& find /tmp -type f -name "datastax-*.jar" -exec mv -t ${MAAC_PATH} -i '{}' + \
&& rm ${MAAC_PATH}/datastax-mgmtapi-agent-3.x* \
&& rm ${MAAC_PATH}/datastax-mgmtapi-agent-4.x* \
&& rm ${MAAC_PATH}/datastax-mgmtapi-*common* \
&& cd ${MAAC_PATH} \
&& ln -s datastax-mgmtapi-agent-4.1.x-0.1.0-SNAPSHOT.jar datastax-mgmtapi-agent-0.1.0-SNAPSHOT.jar \
&& ln -s datastax-mgmtapi-agent-0.1.0-SNAPSHOT.jar datastax-mgmtapi-agent.jar \
&& ln -s datastax-mgmtapi-server-0.1.0-SNAPSHOT.jar datastax-mgmtapi-server.jar && \
chmod -R g+w ${MAAC_PATH}
############################################################
FROM registry.access.redhat.com/ubi${UBI_MAJOR}/ubi-minimal:${UBI_BASETAG} AS oss41
ARG CASSANDRA_VERSION
ENV CASSANDRA_VERSION=${CASSANDRA_VERSION}
LABEL maintainer="DataStax, Inc <[email protected]>"
LABEL name="Apache Cassandra"
LABEL vendor="DataStax, Inc"
LABEL release="${CASSANDRA_VERSION}"
LABEL summary="Apache Cassandra is an open source distributed database management system designed to handle large amounts of data across many commodity servers, providing high availability with no single point of failure. Cassandra offers robust support for clusters spanning multiple datacenters, with asynchronous masterless replication allowing low latency operations for all clients."
LABEL description="Apache Cassandra is an open source distributed database management system designed to handle large amounts of data across many commodity servers, providing high availability with no single point of failure. Cassandra offers robust support for clusters spanning multiple datacenters, with asynchronous masterless replication allowing low latency operations for all clients."
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8'
ENV CASSANDRA_PATH /opt/cassandra
ENV MAAC_PATH /opt/management-api
ENV MCAC_PATH /opt/metrics-collector
ENV CDC_AGENT_PATH=/opt/cdc_agent
ENV PATH ${CASSANDRA_PATH}/bin:${PATH}
ENV CASSANDRA_HOME ${CASSANDRA_PATH}
ENV CASSANDRA_CONF ${CASSANDRA_PATH}/conf
ENV CASSANDRA_LOG_DIR /var/log/cassandra
ENV CASSANDRA_DATA_DIR /var/lib/cassandra
# Update base layer
RUN microdnf update && rm -rf /var/cache/yum \
# Install packages needed during install process
&& microdnf install --nodocs java-11-openjdk-headless tzdata-java python3 zlib findutils which hostname iproute shadow-utils procps util-linux glibc-langpack-en \
&& microdnf clean all \
# Add Cassandra user
&& groupadd -r cassandra --gid=999 \
&& useradd -m -d "$CASSANDRA_HOME" -r -g cassandra -G root --uid=999 cassandra
# Copy trimmed installation
COPY --from=builder --chown=cassandra:root ${CASSANDRA_PATH} ${CASSANDRA_PATH}
COPY --from=builder --chown=cassandra:root ${CASSANDRA_PATH}/LICENSE.txt /licenses/
COPY --from=builder --chown=cassandra:root ${MCAC_PATH} ${MCAC_PATH}
COPY --from=builder --chown=cassandra:root ${CDC_AGENT_PATH} ${CDC_AGENT_PATH}
COPY --from=mgmtapi-setup --chown=cassandra:root ${MAAC_PATH} ${MAAC_PATH}
# Create directories
RUN (for dir in ${CASSANDRA_DATA_DIR} \
${CASSANDRA_LOG_DIR} ; do \
mkdir -p $dir && chown -R cassandra:root $dir && chmod 775 $dir ; \
done ) && \
ln -sT ${CASSANDRA_DATA_DIR} ${CASSANDRA_HOME}/data && \
ln -sT ${CASSANDRA_LOG_DIR} ${CASSANDRA_HOME}/logs && \
# setup conf directory
[ ! -e "/etc/cassandra" ]; \
mv ${CASSANDRA_CONF} /etc/cassandra && \
ln -sT /etc/cassandra ${CASSANDRA_CONF} && \
# change mode of directories
chmod a+rwX ${MAAC_PATH} ${MCAC_PATH} ${CASSANDRA_PATH} ${CDC_AGENT_PATH} /etc/cassandra
# backwards compat with upstream ENTRYPOINT
COPY scripts/docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh && \
ln -sf /usr/local/bin/docker-entrypoint.sh /docker-entrypoint.sh && \
# fix for the missing mtab in the containerd
ln -sf /proc/mounts /etc/mtab
# Set user to run as
USER cassandra
# Expose CASSANDRA folders
VOLUME ["/var/lib/cassandra", "/var/log/cassandra"]
# MANAGEMENT API, MCAC METRICS, NON-MCAC METRICS
EXPOSE 8080 9103 9000
# CASSANDRA PORTS (INTRA-NODE, TLS INTRA-NODE, JMX, CQL, THRIFT, DSEFS INTRA-NODE, INTRA-NODE MESSAGING SERVICE)
EXPOSE 7000 7001 7199 8609 9042 9160
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["mgmtapi"]