forked from k8ssandra/management-api-for-apache-cassandra
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile-4_0
81 lines (63 loc) · 3.22 KB
/
Dockerfile-4_0
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
ARG CASSANDRA_VERSION=4.0.1
FROM --platform=$BUILDPLATFORM maven:3.6.3-jdk-8-slim as builder
ARG METRICS_COLLECTOR_VERSION=0.2.0
WORKDIR /build
COPY pom.xml ./
COPY management-api-agent-common/pom.xml ./management-api-agent-common/pom.xml
COPY management-api-agent-3.x/pom.xml ./management-api-agent-3.x/pom.xml
COPY management-api-agent-4.x/pom.xml ./management-api-agent-4.x/pom.xml
COPY management-api-common/pom.xml ./management-api-common/pom.xml
COPY management-api-server/pom.xml ./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 mvn -q -ff -T 1C install && rm -rf target
COPY management-api-agent-common ./management-api-agent-common
COPY management-api-agent-3.x ./management-api-agent-3.x
COPY management-api-agent-4.x ./management-api-agent-4.x
COPY management-api-common ./management-api-common
COPY management-api-server ./management-api-server
RUN mvn -q -ff package -DskipTests
# Download and extract Metrics Collector
ENV MCAC_PATH /opt/metrics-collector
RUN mkdir ${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_VERSION}.tar.gz"; fi && \
tar --directory ${MCAC_PATH} --strip-components 1 --gzip --extract --file datastax-mcac-agent-${METRICS_COLLECTOR_VERSION}.tar.gz
FROM cassandra:${CASSANDRA_VERSION} as oss40
ARG TARGETARCH
ENV CASSANDRA_PATH /opt/cassandra
ENV MAAC_PATH /opt/management-api
ENV MCAC_PATH /opt/metrics-collector
ENV USER_HOME_PATH /home/cassandra
ENV CASSANDRA_HOME ${CASSANDRA_PATH}
ENV CASSANDRA_CONF ${CASSANDRA_PATH}/conf
ENV CASSANDRA_LOGS ${CASSANDRA_PATH}/logs
# Log directory for Management API startup logs to avoid issues:
# https://datastax.jira.com/browse/DB-4627
# https://issues.apache.org/jira/browse/CASSANDRA-16027
ENV MGMT_API_LOG_DIR /var/log/cassandra
ENV MGMT_API_HEAP_SIZE 16m
COPY --from=builder /build/management-api-agent-4.x/target/datastax-mgmtapi-agent-4.x-0.1.0-SNAPSHOT.jar ${MAAC_PATH}/datastax-mgmtapi-agent-0.1.0-SNAPSHOT.jar
COPY --from=builder /build/management-api-server/target/datastax-mgmtapi-server-0.1.0-SNAPSHOT.jar ${MAAC_PATH}/
COPY --from=builder ${MCAC_PATH} ${MCAC_PATH}
# Setup user and fixup permissions
RUN mkdir ${USER_HOME_PATH} && \
chown -R cassandra:root ${CASSANDRA_PATH} ${MAAC_PATH} ${MCAC_PATH} ${USER_HOME_PATH} && \
chmod -R g+w ${CASSANDRA_PATH} ${MAAC_PATH} ${MCAC_PATH}
ENV TINI_VERSION v0.18.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-${TARGETARCH} /tini
RUN chmod +x /tini
RUN set -eux; \
rm -fr /etc/apt/sources.list.d/*; \
rm -rf /var/lib/apt/lists/*; \
apt-get update; \
apt-get install -y --no-install-recommends wget iproute2; \
rm -rf /var/lib/apt/lists/*
# 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
EXPOSE 9103
EXPOSE 8080
USER cassandra
ENTRYPOINT ["/tini", "-g", "--", "/docker-entrypoint.sh"]
CMD ["mgmtapi"]