diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3cf69f7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +FROM golang:1.25 AS build +WORKDIR /build/src +COPY . . +RUN CGO_ENABLED=0 go build -trimpath -ldflags=-s -o bin/mokv . +FROM scratch +COPY --from=build /build/src/bin/mokv /usr/bin/mokv +ENTRYPOINT [ "/usr/bin/mokv" ] + diff --git a/Makefile b/Makefile index f1df43b..059a1f4 100644 --- a/Makefile +++ b/Makefile @@ -17,8 +17,12 @@ start: .PHONY: build build: - go build -o bin/mokv main.go + go build -o bin/mokv . .PHONY: perf perf: - -go test -bench=. -benchtime=5s ./mokv -benchmem -run=^# \ No newline at end of file + -go test -bench=. -benchtime=5s ./mokv -benchmem -run=^# + +.PHONY: perf-long +perf-long: + -go test -bench=. -benchtime=60s ./mokv -benchmem -run=^# \ No newline at end of file diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..94ca956 --- /dev/null +++ b/compose.yaml @@ -0,0 +1,54 @@ +services: + mokv: + build: . + command: + - "--bootstrap" + + ports: + - "8400:8400" + - "8401:8401" + - "4000:4000" + networks: + - mokv-net + + prometheus: + image: prom/prometheus:latest + ports: + - "9090:9090" + volumes: + - ./prometheus.yaml:/etc/prometheus/prometheus.yml + - prometheus-data:/prometheus + command: + - "--config.file=/etc/prometheus/prometheus.yml" + - "--storage.tsdb.path=/prometheus" + - "--web.console.libraries=/usr/share/prometheus/console_libraries" + - "--web.console.templates=/usr/share/prometheus/consoles" + networks: + - mokv-net + depends_on: + - mokv + + grafana: + image: grafana/grafana:latest + ports: + - "3000:3000" + environment: + - GF_SECURITY_ADMIN_USER=admin + - GF_SECURITY_ADMIN_PASSWORD=admin + - GF_USERS_ALLOW_SIGN_UP=false + volumes: + - grafana-data:/var/lib/grafana + - ./grafana/provisioning:/etc/grafana/provisioning + networks: + - mokv-net + depends_on: + - prometheus + - mokv + +networks: + mokv-net: + driver: bridge + +volumes: + prometheus-data: + grafana-data: diff --git a/prometheus.yaml b/prometheus.yaml new file mode 100644 index 0000000..ca77ed1 --- /dev/null +++ b/prometheus.yaml @@ -0,0 +1,10 @@ +global: + scrape_interval: 15s + evaluation_interval: 15s + +scrape_configs: + - job_name: "mokv" + static_configs: + - targets: ["mokv:4000"] + labels: + service: "mokv"