Skip to content
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
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@

version: 2
updates:
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "gomod"
directory: "/"
schedule:
Expand Down
40 changes: 24 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ jobs:
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@master
with:
go-version: 1.21.x
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand All @@ -34,23 +32,33 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Prepare
id: prepare
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Fetch latest tag
id: tag
run: echo "tag_name=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT

- name: Release
- name: Build and push
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
push: true
tags: |
mgsousa/json-stats-exporter:${{ steps.tag.outputs.tag_name }}
mgsousa/json-stats-exporter:latest
ghcr.io/mgsousa/json-stats-exporter:${{ steps.tag.outputs.tag_name }}
ghcr.io/mgsousa/json-stats-exporter:latest

- name: Release assets
uses: goreleaser/goreleaser-action@v6
with:
version: latest
args: release --clean --timeout=5m
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ steps.prepare.outputs.tag_name }}

- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile.release
push: true
tags: mgsousa/json-stats-exporter:${{ steps.prepare.outputs.tag_name }},mgsousa/json-stats-exporter:latest
VERSION: ${{ steps.tag.outputs.tag_name }}
1 change: 1 addition & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ builds:
- darwin
goarch:
- amd64
- arm64
ldflags:
- -s -w
archives:
Expand Down
18 changes: 7 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
FROM golang:alpine AS build
FROM public.ecr.aws/docker/library/golang:alpine3.21 AS builder

WORKDIR /app
COPY . .

COPY . ./

SHELL ["/bin/ash", "-eo", "pipefail", "-c"]

RUN apk add --no-cache curl git &&\
curl -sL https://git.io/goreleaser | /bin/sh -s -- build --snapshot --single-target

RUN go build "--ldflags=-s -w" -o ./json-stats-exporter -v main.go

FROM scratch

WORKDIR /app
LABEL org.opencontainers.image.source="https://github.com/MGSousa/json-stats-exporter"

COPY --from=build /app/dist/json-stats-exporter_linux_amd64_v1/* ./json-stats-exporter
WORKDIR /app
COPY --from=builder --chmod=775 /app/json-stats-exporter /bin/

ENTRYPOINT [ "./json-stats-exporter" ]
ENTRYPOINT [ "/bin/json-stats-exporter" ]
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,4 @@ docker_build:
@docker build --no-cache -t $(BINARY) .

goreleaser_build:
@goreleaser build --rm-dir --single-target --clean --auto-snapshot

@goreleaser build --single-target --clean --auto-snapshot
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module main
module github.com/MGSousa/json-stats-exporter

go 1.21.3

Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package main
import (
"flag"
"fmt"
"main/exporter"
"net/http"
"os"
"strings"
"time"

"github.com/MGSousa/json-stats-exporter/exporter"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/collectors/version"
"github.com/prometheus/client_golang/prometheus/promhttp"
Expand Down