dockerizing_cassandra/Dockerfile

38 lines
1.3 KiB
Docker
Raw Normal View History

2024-07-24 15:03:39 +02:00
# Use the official Cassandra 4.1.3 image
FROM cassandra:4.1.3
# Install gettext to use envsubst
RUN apt-get update && apt-get install -y iputils-ping less locate gettext-base
2024-07-24 15:41:02 +02:00
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
# Copy cassandra.yaml and cassandra-rackdc.properties
2024-07-24 15:41:02 +02:00
COPY cassandra.yaml /etc/cassandra/
COPY cassandra-rackdc.properties /etc/cassandra/
# Substitute environment variables in cassandra.yaml
RUN envsubst < /etc/cassandra/cassandra.yaml > /etc/cassandra/cassandra.yaml.tmp && mv /etc/cassandra/cassandra.yaml.tmp /etc/cassandra/cassandra.yaml
# Substitute environment variables in cassandra-rackdc.properties
RUN envsubst < /etc/cassandra/cassandra-rackdc.properties > /etc/cassandra/cassandra-rackdc.properties.tmp && mv /etc/cassandra/cassandra-rackdc.properties.tmp /etc/cassandra/cassandra-rackdc.properties
2024-07-24 15:41:02 +02:00
2024-07-24 15:03:39 +02:00
# Set the entrypoint
ENTRYPOINT ["/setup.sh"]
# Expose Cassandra ports
EXPOSE 7000 7001 7199 9042 9160