dockerizing_cassandra/Dockerfile

38 lines
1.1 KiB
Docker

# Use the official Cassandra 4.1.3 image
FROM cassandra:4.1.3
RUN apt-get update && apt-get install -y iputils-ping less locate
# 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
# 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
# Set the entrypoint
ENTRYPOINT ["/setup.sh"]
# Expose Cassandra ports
EXPOSE 7000 7001 7199 9042 9160
# Add health check
# HEALTHCHECK --interval=30s --timeout=10s --retries=5 CMD cqlsh -e "DESCRIBE KEYSPACES" || exit 1