Skip to content

Commit db3e408

Browse files
committed
(feat) Added ghcr registry, minor improvements
1 parent a5581d3 commit db3e408

File tree

6 files changed

+38
-31
lines changed

6 files changed

+38
-31
lines changed

.github/dependabot.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515

1616
version: 2
1717
updates:
18+
- package-ecosystem: "docker"
19+
directory: "/"
20+
schedule:
21+
interval: "daily"
1822
- package-ecosystem: "gomod"
1923
directory: "/"
2024
schedule:

.github/workflows/release.yml

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@ jobs:
2020
with:
2121
fetch-depth: 0
2222

23-
- name: Set up Go
24-
uses: actions/setup-go@master
25-
with:
26-
go-version: 1.21.x
23+
- name: Set up QEMU
24+
uses: docker/setup-qemu-action@v3
2725

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

37-
- name: Prepare
38-
id: prepare
35+
- name: Login to GitHub Container Registry
36+
uses: docker/login-action@v3
37+
with:
38+
registry: ghcr.io
39+
username: ${{ github.repository_owner }}
40+
password: ${{ secrets.GITHUB_TOKEN }}
41+
42+
- name: Fetch latest tag
43+
id: tag
3944
run: echo "tag_name=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
4045

41-
- name: Release
46+
- name: Build and push
47+
uses: docker/build-push-action@v6
48+
with:
49+
platforms: linux/amd64,linux/arm64
50+
push: true
51+
tags: |
52+
mgsousa/json-stats-exporter:${{ steps.tag.outputs.tag_name }}
53+
mgsousa/json-stats-exporter:latest
54+
ghcr.io/mgsousa/json-stats-exporter:${{ steps.tag.outputs.tag_name }}
55+
ghcr.io/mgsousa/json-stats-exporter:latest
56+
57+
- name: Release assets
4258
uses: goreleaser/goreleaser-action@v6
4359
with:
4460
version: latest
4561
args: release --clean --timeout=5m
4662
env:
4763
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48-
VERSION: ${{ steps.prepare.outputs.tag_name }}
49-
50-
- name: Build and push
51-
uses: docker/build-push-action@v6
52-
with:
53-
context: .
54-
file: Dockerfile.release
55-
push: true
56-
tags: mgsousa/json-stats-exporter:${{ steps.prepare.outputs.tag_name }},mgsousa/json-stats-exporter:latest
64+
VERSION: ${{ steps.tag.outputs.tag_name }}

Dockerfile

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
1-
FROM golang:alpine AS build
1+
FROM public.ecr.aws/docker/library/golang:alpine3.21 AS builder
22

33
WORKDIR /app
4+
COPY . .
45

5-
COPY . ./
6-
7-
SHELL ["/bin/ash", "-eo", "pipefail", "-c"]
8-
9-
RUN apk add --no-cache curl git &&\
10-
curl -sL https://git.io/goreleaser | /bin/sh -s -- build --snapshot --single-target
11-
6+
RUN go build "--ldflags=-s -w" -o ./json-stats-exporter -v main.go
127

138
FROM scratch
149

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

17-
COPY --from=build /app/dist/json-stats-exporter_linux_amd64_v1/* ./json-stats-exporter
12+
WORKDIR /app
13+
COPY --from=builder --chmod=775 /app/json-stats-exporter /bin/
1814

19-
ENTRYPOINT [ "./json-stats-exporter" ]
15+
ENTRYPOINT [ "/bin/json-stats-exporter" ]

Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,4 @@ docker_build:
2323
@docker build --no-cache -t $(BINARY) .
2424

2525
goreleaser_build:
26-
@goreleaser build --rm-dir --single-target --clean --auto-snapshot
27-
26+
@goreleaser build --single-target --clean --auto-snapshot

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module main
1+
module github.com/MGSousa/json-stats-exporter
22

33
go 1.21.3
44

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ package main
33
import (
44
"flag"
55
"fmt"
6-
"main/exporter"
76
"net/http"
87
"os"
98
"strings"
109
"time"
1110

11+
"github.com/MGSousa/json-stats-exporter/exporter"
1212
"github.com/prometheus/client_golang/prometheus"
1313
"github.com/prometheus/client_golang/prometheus/collectors/version"
1414
"github.com/prometheus/client_golang/prometheus/promhttp"

0 commit comments

Comments
 (0)