Skip to content

Commit

Permalink
Merge pull request #3 from NicoWK/master
Browse files Browse the repository at this point in the history
Add docker image to the exporter
  • Loading branch information
frittentheke authored Oct 11, 2023
2 parents 6fd05ec + 4714f85 commit 174be23
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 3 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: Build, Test and Release Binaries
on:
push:
push
permissions:
contents: write
packages: write

jobs:
build:
Expand All @@ -23,7 +26,12 @@ jobs:
steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Go
uses: actions/setup-go@v3
with:
Expand Down
11 changes: 10 additions & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,16 @@ builds:
- linux
goarch:
- amd64

dockers:
- ids:
- prometheus-libvirt-exporter
image_templates:
- ghcr.io/inovex/{{ .ProjectName }}:{{ .Version }}
goos: linux
goarch: amd64
dockerfile: goreleaser.dockerfile
build_flag_templates:
- "--build-arg=BINARY_NAME={{ .ProjectName }}"
#Configuration for building packages for apk, deb and rpm package managers
nfpms:
- id: "prometheus-libvirt-exporter"
Expand Down
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM golang:1.21 as builder
WORKDIR /app

# Requirements/Dependencies
COPY go.mod go.sum ./
RUN go mod download

# Build
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -o prometheus-libvirt-exporter

FROM scratch
COPY --from=builder app/prometheus-libvirt-exporter usr/bin/prometheus-libvirt-exporter
# Default listen on port 9177
EXPOSE 9177
# Start
CMD ["usr/bin/prometheus-libvirt-exporter"]
3 changes: 3 additions & 0 deletions goreleaser.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM scratch
COPY prometheus-libvirt-exporter /prometheus-libvirt-exporter
ENTRYPOINT ["/prometheus-libvirt-exporter"]

0 comments on commit 174be23

Please sign in to comment.