From 8dd5be715583a2a0741def85f2e352832b29105a Mon Sep 17 00:00:00 2001 From: Draco Date: Fri, 10 May 2024 11:40:32 +0000 Subject: [PATCH 1/4] chore: add mysql-client and grafana in docker image --- Dockerfile | 11 ++++++++++- docker/datasource.yml | 25 +++++++++++++++++++++++++ docker/entrypoint.sh | 3 +++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 docker/datasource.yml diff --git a/Dockerfile b/Dockerfile index 6e94e51a70..1229e4a25d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,9 +35,18 @@ FROM ubuntu:20.04 RUN useradd -m -s /bin/bash horae RUN apt update && \ - apt install --yes curl gdb iotop cron vim less net-tools && \ + apt install --yes curl gdb iotop cron vim less net-tools mysql-client apt-transport-https software-properties-common wget && \ apt clean +# install grafana +RUN mkdir -p /etc/apt/keyrings/ && \ + wget -q -O - https://apt.grafana.com/gpg.key | gpg --dearmor | tee /etc/apt/keyrings/grafana.gpg > /dev/null && \ + echo "deb [signed-by=/etc/apt/keyrings/grafana.gpg] https://apt.grafana.com stable main" | tee -a /etc/apt/sources.list.d/grafana.list && \ + apt update && \ + apt install --yes grafana && \ + apt clean +COPY ./docker/datasource.yml /usr/share/grafana/conf/provisioning/datasources + ENV RUST_BACKTRACE 1 COPY --from=build /horaedb/target/release/horaedb-server /usr/bin/horaedb-server diff --git a/docker/datasource.yml b/docker/datasource.yml new file mode 100644 index 0000000000..708a3cc921 --- /dev/null +++ b/docker/datasource.yml @@ -0,0 +1,25 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +apiVersion: 1 + +datasources: +- name: HoraeDB + type: influxdb + access: proxy + url: http://localhost:5440/influxdb/v1/ + isDefault: true \ No newline at end of file diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index abb588173d..19523793d8 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -33,4 +33,7 @@ mkdir -p ${DATA_DIR} chmod +777 -R ${DATA_DIR} chown -R ${USER}.${USER} ${DATA_DIR} +# start grafana server +nohup /usr/share/grafana/bin/grafana server --homepath /usr/share/grafana/ & + exec /usr/bin/horaedb-server --config ${CONFIG_FILE} From dcb0beb2383d05be8a3848c1ae557dc119c771c5 Mon Sep 17 00:00:00 2001 From: draco Date: Fri, 10 May 2024 23:20:38 +0800 Subject: [PATCH 2/4] chore: set default grafana datasource to mysql --- docker/datasource.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docker/datasource.yml b/docker/datasource.yml index 708a3cc921..a7129d017f 100644 --- a/docker/datasource.yml +++ b/docker/datasource.yml @@ -18,8 +18,8 @@ apiVersion: 1 datasources: -- name: HoraeDB - type: influxdb - access: proxy - url: http://localhost:5440/influxdb/v1/ - isDefault: true \ No newline at end of file + - name: HoraeDB + type: mysql + access: proxy + url: localhost:3307 + isDefault: true \ No newline at end of file From 7f1af96e34625ba115c6497cf8f20fc2ff6c7195 Mon Sep 17 00:00:00 2001 From: draco Date: Fri, 10 May 2024 23:22:10 +0800 Subject: [PATCH 3/4] chore: update datasource.yml --- docker/datasource.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docker/datasource.yml b/docker/datasource.yml index a7129d017f..4ca72bf9ea 100644 --- a/docker/datasource.yml +++ b/docker/datasource.yml @@ -18,8 +18,14 @@ apiVersion: 1 datasources: - - name: HoraeDB + - name: HoraeDB-mysql type: mysql access: proxy url: localhost:3307 + isDefault: true + + - name: HoraeDB-influxdb + type: influxdb + access: proxy + url: http://localhost:5440/influxdb/v1/ isDefault: true \ No newline at end of file From a17165c26d4afe8c23498cfbc23a5b9d46a078d9 Mon Sep 17 00:00:00 2001 From: draco Date: Fri, 10 May 2024 23:23:03 +0800 Subject: [PATCH 4/4] chore: update datasource.yml --- docker/datasource.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/datasource.yml b/docker/datasource.yml index 4ca72bf9ea..acdeadc546 100644 --- a/docker/datasource.yml +++ b/docker/datasource.yml @@ -28,4 +28,4 @@ datasources: type: influxdb access: proxy url: http://localhost:5440/influxdb/v1/ - isDefault: true \ No newline at end of file + isDefault: false \ No newline at end of file