Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add mariadb image #285

Merged
merged 1 commit into from
Aug 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions tfgrid3/monitored_mariadb/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM ubuntu

Check failure

Code scanning / Trivy

Image user should not be 'root' High

Artifact: tfgrid3/monitored_mariadb/Dockerfile
Type: dockerfile
Vulnerability DS002
Severity: HIGH
Message: Specify at least 1 USER command in Dockerfile with non-root user as argument
Link: DS002

ENV DEBIAN_FRONTEND=noninteractive

RUN apt update && \
apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
Comment on lines +5 to +10

Check failure

Code scanning / Trivy

'apt-get' missing '--no-install-recommends' High

Artifact: tfgrid3/monitored_mariadb/Dockerfile
Type: dockerfile
Vulnerability DS029
Severity: HIGH
Message: '--no-install-recommends' flag is missed: 'apt update && apt-get install -y apt-transport-https ca-certificates curl software-properties-common'
Link: DS029

RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - &&\
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"

RUN apt-get update && apt-get install -y docker-ce

Check failure

Code scanning / Trivy

'apt-get' missing '--no-install-recommends' High

Artifact: tfgrid3/monitored_mariadb/Dockerfile
Type: dockerfile
Vulnerability DS029
Severity: HIGH
Message: '--no-install-recommends' flag is missed: 'apt-get update && apt-get install -y docker-ce'
Link: DS029

RUN apt install -y wget openssh-server

COPY . .

RUN wget -O /sbin/zinit https://github.com/threefoldtech/zinit/releases/download/v0.2.5/zinit && \
chmod +x /sbin/zinit


ENTRYPOINT [ "/sbin/zinit", "init" ]
70 changes: 70 additions & 0 deletions tfgrid3/monitored_mariadb/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
services:
mariadb-master:
image: mariadb:latest
container_name: mariadb-master
environment:
MYSQL_ROOT_PASSWORD: rootpassword
MYSQL_DATABASE: mydb
MYSQL_USER: user
MYSQL_PASSWORD: password
volumes:
- master-data:/var/lib/mysql
networks:
- monitoring

mariadb-slave:
image: mariadb:latest
container_name: mariadb-slave
environment:
MYSQL_ROOT_PASSWORD: rootpassword
MYSQL_REPLICATION_MODE: slave
MYSQL_MASTER_HOST: mariadb-master
MYSQL_MASTER_USER: root
MYSQL_MASTER_PASSWORD: password
MYSQL_DATABASE: mydb
depends_on:
- mariadb-master
networks:
- monitoring

mariadb_exporter:
image: prom/mysqld-exporter:latest
container_name: mariadb_exporter
command:
- "--mysqld.username=user:password"
- "--mysqld.address=mariadb-master:3306"
ports:
- "9104:9104"
depends_on:
- mariadb-master

prometheus:
image: prom/prometheus
container_name: prometheus
command:
- "--config.file=/etc/prometheus/prometheus.yml"
ports:
- 9090:9090
restart: unless-stopped
volumes:
- ./prometheus:/etc/prometheus

grafana:
image: grafana/grafana
container_name: grafana
ports:
- 3000:3000
restart: unless-stopped
environment:
- GF_SECURITY_ADMIN_USER=admin
- GF_SECURITY_ADMIN_PASSWORD=grafana
volumes:
- ./provisioning:/etc/grafana/provisioning
- ./provisioning/dashboards:/var/lib/grafana/dashboards

volumes:
master-data:

networks:
monitoring:
driver: bridge
2 changes: 2 additions & 0 deletions tfgrid3/monitored_mariadb/etc/zinit/dockerd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
exec: dockerd -D
test: docker ps
2 changes: 2 additions & 0 deletions tfgrid3/monitored_mariadb/etc/zinit/maria-cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
exec: docker compose -p monitored-mariadb up
oneshot: true
1 change: 1 addition & 0 deletions tfgrid3/monitored_mariadb/etc/zinit/sshd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
exec: /usr/sbin/sshd -D
14 changes: 14 additions & 0 deletions tfgrid3/monitored_mariadb/etc/zinit/sshkey.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
exec: |
bash -c '
if [ ! -z "$SSH_KEY" ]; then
mkdir -p /var/run/sshd
mkdir -p /root/.ssh
touch /root/.ssh/authorized_keys

chmod 700 /root/.ssh
chmod 600 /root/.ssh/authorized_keys

echo "$SSH_KEY" >> /root/.ssh/authorized_keys
fi
'
oneshot: true
7 changes: 7 additions & 0 deletions tfgrid3/monitored_mariadb/prometheus/prometheus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
global:
scrape_interval: 15s

scrape_configs:
- job_name: 'mariadb-exporter'
static_configs:
- targets: ['mariadb_exporter:9104']
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: 1

providers:
- name: Default # A uniquely identifiable name for the provider
folder: Services # The folder where to place the dashboards
type: file
options:
path: /var/lib/grafana/dashboards
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"annotations": {
"list": []
},
"editable": true,
"gnetId": null,
"graphTooltip": 0,
"id": null,
"links": [],
"panels": [
{
"datasource": "Prometheus",
"fieldConfig": {
"defaults": {},
"overrides": []
},
"gridPos": {
"h": 9,
"w": 12,
"x": 0,
"y": 0
},
"id": 1,
"targets": [
{
"expr": "up",
"interval": "",
"legendFormat": "{{instance}}",
"refId": "A"
}
],
"title": "Service Status",
"type": "graph"
}
],
"refresh": "5s",
"schemaVersion": 30,
"style": "dark",
"tags": [],
"templating": {
"list": []
},
"time": {
"from": "now-5m",
"to": "now"
},
"timepicker": {},
"timezone": "",
"title": "Simple Dashboard",
"uid": "simple-dashboard",
"version": 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: 1

datasources:
- name: Prometheus
type: prometheus
url: http://prometheus:9090
isDefault: true
access: proxy
editable: true
Loading