Skip to content

Commit

Permalink
upd() goreleaser, dockerfile, demo
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalyu committed Aug 7, 2024
1 parent 7edb7b3 commit d54b420
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 25 deletions.
13 changes: 6 additions & 7 deletions .devcontainer/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: "3.8"
services:
vscode:
image: mcr.microsoft.com/devcontainers/go:1-1.22-bookworm
Expand Down Expand Up @@ -28,9 +27,9 @@ services:
- "./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml"
ports:
- "9090:9090"
grafana:
image: grafana/grafana:master
volumes:
- "./grafana-data:/var/lib/grafana"
ports:
- "3000:3000"
# grafana:
# image: grafana/grafana:master
# volumes:
# - "./grafana-data:/var/lib/grafana"
# ports:
# - "3000:3000"
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ go.work.sum
.env

# others
bin/
dist/
.devcontainer/grafana-data/
5 changes: 5 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
version: 2
project_name: prometheus-fake-remote-read

release:
Expand Down Expand Up @@ -36,6 +37,8 @@ dockers:
use: buildx
build_flag_templates:
- --platform=linux/amd64
extra_files:
- configs/example.config.json

- image_templates:
- "ghcr.io/vitalyu/{{ .ProjectName }}:{{ .Version }}-arm64"
Expand All @@ -44,6 +47,8 @@ dockers:
use: buildx
build_flag_templates:
- --platform=linux/arm64/v8
extra_files:
- configs/example.config.json

docker_manifests:
- name_template: "ghcr.io/vitalyu/{{ .ProjectName }}:{{ .Version }}"
Expand Down
14 changes: 4 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
ARG TARGETOS
ARG TARGETARCH

FROM --platform=$BUILDPLATFORM golang:1.22-alpine AS builder
WORKDIR /app
COPY . .
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH CGO_ENABLED=0 go build -o prometheus-fake-remote-read ./cmd/prometheus-fake-remote-read

FROM alpine:latest
WORKDIR /root/

COPY --from=builder /app/prometheus-fake-remote-read .
COPY --from=builder /app/configs/example.config.json .
COPY prometheus-fake-remote-read .
COPY configs/example.config.json .

RUN ls -lh

ENTRYPOINT ["./prometheus-fake-remote-read"]
CMD ["--config", "./example.config.json"]
16 changes: 9 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,18 @@ test: ## Run tests
run: ## Run for current platform
CGO_ENABLED=0 go run ./cmd/prometheus-fake-remote-read --config configs/example.config.json

.PHONY: demo
demo: ## Run docker compose and checkout http://127.0.0.1:9090
docker compose --project-directory ./demo/ up
docker compose --project-directory ./demo/ rm --stop --volumes --force

##@ Build

.PHONY: build
build: ## Build for current platform
mkdir ./bin/ || true
CGO_ENABLED=0 go build -o ./bin/ ./cmd/prometheus-fake-remote-read

.PHONY: docker-build
docker-build: ## Test building dockerfile for multiplatforms. Using buildx
docker buildx create --use
docker buildx build --platform linux/amd64 -t prometheus-fake-remote-read:amd64 .
docker buildx build --platform linux/arm64 -t prometheus-fake-remote-read:arm64 .
CGO_ENABLED=0 go build -o ./dist/ ./cmd/prometheus-fake-remote-read

.PHONY: goreleaser
goreleaser: ## Build via goreleaser
goreleaser release --snapshot --clean
9 changes: 9 additions & 0 deletions demo/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
services:
remotestorage:
image: ghcr.io/vitalyu/prometheus-fake-remote-read:latest
prom:
image: prom/prometheus:v2.53.1
volumes:
- "./prometheus-config.yml:/etc/prometheus/prometheus.yml"
ports:
- "9090:9090"
11 changes: 11 additions & 0 deletions demo/prometheus-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.

scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']

remote_read:
- url: "http://remotestorage:9999/read"

0 comments on commit d54b420

Please sign in to comment.