diff --git a/docker/cassandra-setup/Dockerfile b/docker/cassandra-setup/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..719ae38ee53121bd9d2f4165844800a2866a042b --- /dev/null +++ b/docker/cassandra-setup/Dockerfile @@ -0,0 +1,5 @@ +FROM debian:12.5-slim +RUN apt update -y +RUN apt install -y python3 python3-pip python3-venv +RUN mkdir /startup +CMD ["/scripts/startup.sh"] \ No newline at end of file diff --git a/docker/cassandra-setup/entry.sql b/docker/cassandra-setup/entry.sql new file mode 100644 index 0000000000000000000000000000000000000000..cfbb583047ceb87529ac88f7ec6543b3ce5268a3 --- /dev/null +++ b/docker/cassandra-setup/entry.sql @@ -0,0 +1,51 @@ +CREATE TYPE smartdata_v1.v1_1_digital ( + value blob, + error tinyint, + confidence tinyint, + gw bigint +); + +CREATE TYPE smartdata_v1.v1_1_si ( + value double, + error tinyint, + confidence tinyint, + gw bigint +); + +CREATE TYPE smartdata_v1.v1_1_si_blob ( + period int, + gateway bigint, + uncertainty int, + data blob +); + + +CREATE TYPE smartdata_v1.v1_2_digital ( + value blob, + error tinyint, + confidence tinyint, + x int, + y int, + z int, + gw bigint +); + +CREATE TYPE smartdata_v1.v1_2_si ( + value double, + error tinyint, + confidence tinyint, + x int, + y int, + z int, + gw bigint +); + +CREATE TYPE smartdata_v1.v1_2_si_blob ( + x int, + y int, + z int, + period int, + gateway bigint, + uncertainty int, + data blob +); \ No newline at end of file diff --git a/docker/cassandra-setup/keyspace.sql b/docker/cassandra-setup/keyspace.sql new file mode 100644 index 0000000000000000000000000000000000000000..483e36e86d1180374a272d12f7b78dee55248150 --- /dev/null +++ b/docker/cassandra-setup/keyspace.sql @@ -0,0 +1,5 @@ +DROP KEYSPACE IF EXISTS smartdata_v1; + +CREATE KEYSPACE smartdata_v1 WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'} AND durable_writes = true; + +USE smartdata_v1; \ No newline at end of file diff --git a/docker/cassandra-setup/startup.sh b/docker/cassandra-setup/startup.sh new file mode 100755 index 0000000000000000000000000000000000000000..777cafbc5d495422d8c52de32e35fcc30dc75a62 --- /dev/null +++ b/docker/cassandra-setup/startup.sh @@ -0,0 +1,13 @@ +#!/bin/bash +cd /startup +python3 -m venv venv +source ./venv/bin/activate +pip3 install cqlsh + +while ! cqlsh -e 'describe cluster' cassandra ; do + echo Waiting for cassandra to startup... + sleep 1 +done + +cqlsh -f /scripts/keyspace.sql cassandra +cqlsh -f /scripts/entry.sql cassandra \ No newline at end of file