Skip to content

Commit ed66dc6

Browse files
committed
Update Docker build
* Update Dockerfile for external builds. * Remove Docker from dependabot, not necessary with external build. * Rework CI to match Prometheus Community setup. * Update gitignore for new build. Signed-off-by: SuperQ <superq@gmail.com>
1 parent 4a2396c commit ed66dc6

File tree

8 files changed

+108
-127
lines changed

8 files changed

+108
-127
lines changed

.github/dependabot.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,3 @@ updates:
1414
schedule:
1515
interval: weekly
1616
open-pull-requests-limit: 10
17-
- package-ecosystem: docker
18-
directory: /
19-
schedule:
20-
interval: weekly
21-
open-pull-requests-limit: 10

.github/workflows/ci.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Go
2+
3+
on:
4+
pull_request:
5+
workflow_call:
6+
7+
jobs:
8+
build:
9+
name: Build
10+
runs-on: ubuntu-latest
11+
container:
12+
image: quay.io/prometheus/golang-builder:1.23-base
13+
steps:
14+
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
15+
- uses: prometheus/promci@52c7012f5f0070d7281b8db4a119e21341d43c91 # v0.4.5
16+
- uses: ./.github/promci/actions/setup_environment
17+
- run: make
18+
- run: git diff --exit-code
19+
20+
verify-example-configs:
21+
name: verify
22+
runs-on: ubuntu-latest
23+
container:
24+
image: quay.io/prometheus/golang-builder:1.23-base
25+
steps:
26+
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
27+
- run: make build
28+
- name: Verify example configs
29+
run: find ./examples -name "*.yml" -print0 | xargs -0 -I % ./yace verify-config -config.file %

.github/workflows/go.yml

Lines changed: 0 additions & 61 deletions
This file was deleted.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
# This action is synced from https://github.com/prometheus/prometheus
3+
name: golangci-lint
4+
on:
5+
push:
6+
paths:
7+
- "go.sum"
8+
- "go.mod"
9+
- "**.go"
10+
- "scripts/errcheck_excludes.txt"
11+
- ".github/workflows/golangci-lint.yml"
12+
- ".golangci.yml"
13+
pull_request:
14+
15+
permissions: # added using https://github.com/step-security/secure-repo
16+
contents: read
17+
18+
jobs:
19+
golangci:
20+
permissions:
21+
contents: read # for actions/checkout to fetch code
22+
pull-requests: read # for golangci/golangci-lint-action to fetch pull requests
23+
name: lint
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
28+
- name: Install Go
29+
uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
30+
with:
31+
go-version: 1.23.x
32+
- name: Install snmp_exporter/generator dependencies
33+
run: sudo apt-get update && sudo apt-get -y install libsnmp-dev
34+
if: github.repository == 'prometheus/snmp_exporter'
35+
- name: Lint
36+
uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6.1.1
37+
with:
38+
args: --verbose
39+
version: v1.61.0

.github/workflows/push.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,16 @@ on: push
33
name: Build and test
44
jobs:
55
buildDockerImage:
6-
name: Build docker image
6+
name: Publish master branch artifacts
77
runs-on: ubuntu-latest
8+
needs: [test_ui, test_go, test_go_more, test_go_oldest, test_windows, golangci, codeql, build_all]
9+
if: github.event_name == 'push' && github.event.ref == 'refs/heads/master'
810
steps:
9-
- uses: actions/checkout@v4
10-
- name: Build docker image
11-
run: docker build -t yace --build-arg VERSION=${{github.event.release.tag_name}} .
11+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
12+
- uses: prometheus/promci@52c7012f5f0070d7281b8db4a119e21341d43c91 # v0.4.5
13+
- uses: ./.github/promci/actions/publish_master
14+
with:
15+
docker_hub_login: ${{ secrets.docker_hub_login }}
16+
docker_hub_password: ${{ secrets.docker_hub_password }}
17+
quay_io_login: ${{ secrets.quay_io_login }}
18+
quay_io_password: ${{ secrets.quay_io_password }}

.github/workflows/release.yml

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,20 @@ on:
77

88
jobs:
99
buildDockerImage:
10-
if: github.repository == 'nerdswords/yet-another-cloudwatch-exporter'
11-
name: Build docker image
10+
name: Publish release artefacts
1211
runs-on: ubuntu-latest
12+
needs: [test_ui, test_go, test_go_more, test_go_oldest, test_windows, golangci, codeql, build_all]
13+
if: |
14+
(*github.repository == 'prometheus-community/yet-another-cloudwatch-exporter')
15+
&&
16+
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v.'))
1317
steps:
14-
- uses: actions/checkout@v4
15-
16-
- uses: actions/setup-go@v5
17-
with:
18-
go-version: ^1.23
19-
20-
- name: Set up QEMU
21-
uses: docker/setup-qemu-action@v3
22-
23-
- name: Set up Docker Buildx
24-
uses: docker/setup-buildx-action@v3
25-
26-
- name: Log into docker
27-
env:
28-
DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
29-
DOCKER_REGISTRY_URL: ghcr.io
30-
DOCKER_USERNAME: ${{ github.actor }}
31-
run: docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD $DOCKER_REGISTRY_URL
32-
33-
- name: Build and Publish docker image
34-
run: docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t ghcr.io/nerdswords/yet-another-cloudwatch-exporter:${{github.ref_name}} --build-arg VERSION=${{github.ref_name}} --push .
35-
36-
- name: Build && release binaries
37-
uses: goreleaser/goreleaser-action@v6
38-
env:
39-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40-
with:
41-
args: release --clean
18+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
19+
- uses: prometheus/promci@52c7012f5f0070d7281b8db4a119e21341d43c91 # v0.4.5
20+
- uses: ./.github/promci/actions/publish_release
21+
with:
22+
docker_hub_login: ${{ secrets.docker_hub_login }}
23+
docker_hub_password: ${{ secrets.docker_hub_password }}
24+
quay_io_login: ${{ secrets.quay_io_login }}
25+
quay_io_password: ${{ secrets.quay_io_password }}
26+
github_token: ${{ secrets.PROMBOT_GITHUB_TOKEN }}

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
.build
12
yet-another-cloudwatch-exporter
23
!charts/yet-another-cloudwatch-exporter
34
vendor
45
dist
56
/yace
6-
.idea
7+
*.tar.gz

Dockerfile

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,15 @@
1-
FROM golang:1.23 as builder
1+
ARG ARCH="amd64"
2+
ARG OS="linux"
3+
FROM quay.io/prometheus/busybox-${OS}-${ARCH}:latest
4+
LABEL maintainer="The Prometheus Authors <prometheus-developers@googlegroups.com>"
25

3-
WORKDIR /opt/
6+
ARG ARCH="amd64"
7+
ARG OS="linux"
8+
COPY .build/${OS}-${ARCH}/yace /bin/yace
49

5-
COPY go.mod go.sum ./
6-
RUN go mod download
10+
COPY examples/ec2.yml /etc/yace/config.yml
711

8-
COPY . ./
9-
10-
ENV GOOS linux
11-
ENV CGO_ENABLED=0
12-
13-
ARG VERSION
14-
RUN go build -v -ldflags "-X main.version=$VERSION" -o yace ./cmd/yace
15-
16-
FROM alpine:3.20.3
17-
18-
EXPOSE 5000
19-
ENTRYPOINT ["yace"]
20-
CMD ["--config.file=/tmp/config.yml"]
21-
RUN addgroup -g 1000 exporter && \
22-
adduser -u 1000 -D -G exporter exporter -h /exporter
23-
24-
WORKDIR /exporter/
25-
26-
27-
RUN apk --no-cache add ca-certificates
28-
COPY --from=builder /opt/yace /usr/local/bin/yace
29-
USER exporter
12+
EXPOSE 5000
13+
USER nobody
14+
ENTRYPOINT [ "/bin/yace" ]
15+
CMD [ "--config.file=/etc/yace/config.yml" ]

0 commit comments

Comments
 (0)