2024-07-24 15:03:39 +02:00
|
|
|
# Use the official Cassandra 4.1.3 image
|
|
|
|
FROM cassandra:4.1.3
|
|
|
|
|
2024-07-24 15:41:02 +02:00
|
|
|
RUN apt-get update && apt-get install -y iputils-ping less locate
|
|
|
|
|
|
|
|
|
2024-07-24 15:03:39 +02:00
|
|
|
# Environment variables to configure Cassandra
|
|
|
|
ENV CASSANDRA_CLUSTER_NAME=TestCluster
|
|
|
|
ENV CASSANDRA_NUM_TOKENS=256
|
|
|
|
ENV CASSANDRA_DC=DC1
|
|
|
|
ENV CASSANDRA_RACK=RAC1
|
|
|
|
|
|
|
|
# Create directory for dump files
|
|
|
|
RUN mkdir -p /dump
|
|
|
|
|
|
|
|
# Copy the CQL script to create the keyspace and tables
|
|
|
|
COPY data/dev_keyspace_schema.cql /docker-entrypoint-initdb.d/dev_keyspace_schema.cql
|
|
|
|
|
|
|
|
# Copy the setup script
|
|
|
|
COPY scripts/setup.sh /setup.sh
|
|
|
|
RUN chmod +x /setup.sh
|
|
|
|
|
2024-07-24 15:41:02 +02:00
|
|
|
# Copy cassandra.yaml
|
|
|
|
COPY cassandra.yaml /etc/cassandra/
|
|
|
|
|
|
|
|
# Copy cassandra-rackdc.properties and substitute environment variables
|
|
|
|
COPY cassandra-rackdc.properties /etc/cassandra/
|
|
|
|
RUN envsubst < /etc/cassandra/cassandra-rackdc.properties > /etc/cassandra/cassandra-rackdc.properties
|
|
|
|
|
2024-07-24 15:03:39 +02:00
|
|
|
# Set the entrypoint
|
|
|
|
ENTRYPOINT ["/setup.sh"]
|
|
|
|
|
|
|
|
# Expose Cassandra ports
|
|
|
|
EXPOSE 7000 7001 7199 9042 9160
|
|
|
|
|
|
|
|
# Add health check
|
2024-07-24 15:41:02 +02:00
|
|
|
# HEALTHCHECK --interval=30s --timeout=10s --retries=5 CMD cqlsh -e "DESCRIBE KEYSPACES" || exit 1
|