From c29a939652304ea24bcbb921b443e9919e656ac2 Mon Sep 17 00:00:00 2001 From: George Hickman Date: Tue, 21 Nov 2023 13:20:41 +0000 Subject: [PATCH 1/2] Configure the timescaledb image with our grafanareader user by default --- docker-compose.yaml | 3 ++- timescaledb/Dockerfile | 3 +++ timescaledb/init.sql | 6 ++++++ 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 timescaledb/Dockerfile create mode 100644 timescaledb/init.sql diff --git a/docker-compose.yaml b/docker-compose.yaml index 073c831c..9a3d8751 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -30,7 +30,8 @@ services: - grafana:/var/lib/grafana timescaledb: - image: timescale/timescaledb-ha:pg14-latest + build: + dockerfile: timescaledb/Dockerfile environment: POSTGRES_DB: metrics POSTGRES_PASSWORD: pass diff --git a/timescaledb/Dockerfile b/timescaledb/Dockerfile new file mode 100644 index 00000000..6674caed --- /dev/null +++ b/timescaledb/Dockerfile @@ -0,0 +1,3 @@ +FROM timescale/timescaledb-ha:pg14-latest@sha256:19eb9276ee367411728e768217120e55300ac9c3bb5eadcf47aa5ded627f6db1 + +COPY timescaledb/init.sql /docker-entrypoint-initdb.d/ diff --git a/timescaledb/init.sql b/timescaledb/init.sql new file mode 100644 index 00000000..9f09aea7 --- /dev/null +++ b/timescaledb/init.sql @@ -0,0 +1,6 @@ +-- set up the grafanareader role with select permissions by default +CREATE ROLE grafanareader; +ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO grafanareader; +ALTER USER grafanareader WITH PASSWORD 'grafana'; +GRANT CONNECT ON DATABASE metrics TO grafanareader; +GRANT USAGE ON SCHEMA public TO grafanareader; From 6e6f445bdc2e60d3da0ebf67c929fef91e083820 Mon Sep 17 00:00:00 2001 From: George Hickman Date: Tue, 21 Nov 2023 14:12:29 +0000 Subject: [PATCH 2/2] Correctly use the timescaledb image instead of timescaledb-ha timescaledb-ha is the image built for use with kubernetes and was mistakenly used when timescaledb was added to the project in 3f4892e. This reduces the resulting image from ~3GB to ~700MB. --- timescaledb/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/timescaledb/Dockerfile b/timescaledb/Dockerfile index 6674caed..e16cd085 100644 --- a/timescaledb/Dockerfile +++ b/timescaledb/Dockerfile @@ -1,3 +1,3 @@ -FROM timescale/timescaledb-ha:pg14-latest@sha256:19eb9276ee367411728e768217120e55300ac9c3bb5eadcf47aa5ded627f6db1 +FROM timescale/timescaledb:pg14-latest@sha256:c453fa2d290d578a5983b5823e9ffbf16f478735d8c121620436c4a9c6e55df5 COPY timescaledb/init.sql /docker-entrypoint-initdb.d/