Skip to content

Commit 88bd4b2

Browse files
authored
Merge branch 'build' into master
2 parents 0a72641 + eaea7ca commit 88bd4b2

File tree

9 files changed

+190
-70
lines changed

9 files changed

+190
-70
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 0 additions & 33 deletions
This file was deleted.

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/ISSUE_TEMPLATE/question.md

Lines changed: 0 additions & 29 deletions
This file was deleted.

.github/dependabot.yml

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
11
version: 2
2+
registries:
3+
docker-registry-quay-io:
4+
type: docker-registry
5+
url: https://quay.io
6+
username: "${{secrets.DEPENDABOT_USER}}"
7+
password: "${{secrets.DEPENDABOT_PASS}}"
28
updates:
3-
# https://docs.github.com/en/github/administering-a-repository/configuration-options-for-dependency-updates
4-
- package-ecosystem: "gomod"
5-
directory: "/"
6-
schedule:
7-
interval: "weekly"
8-
open-pull-requests-limit: 10
9-
- package-ecosystem: "github-actions"
9+
- package-ecosystem: "gomod"
1010
directory: "/"
1111
schedule:
1212
interval: "weekly"
1313
open-pull-requests-limit: 10
14+
- package-ecosystem: "github-actions"
15+
directory: "/"
16+
schedule:
17+
interval: "weekly"
18+
open-pull-requests-limit: 10
19+
- package-ecosystem: "docker"
20+
directory: "/"
21+
schedule:
22+
interval: "daily"
23+
registries:
24+
- docker-registry-quay-io

.github/workflows/build.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Build
2+
3+
# Controls when the action will run. Triggers the workflow on push or pull request
4+
# events but only for the master branch
5+
on:
6+
push:
7+
branches: [ build ]
8+
9+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
10+
jobs:
11+
# This workflow contains a single job called "build"
12+
build:
13+
strategy:
14+
matrix:
15+
docker: ['scratch','ubi']
16+
# The type of runner that the job will run on
17+
runs-on: ubuntu-latest
18+
name: ${{ matrix.docker }}
19+
steps:
20+
- name: build
21+
uses: sysdiglabs/exporter-builder@v0.5
22+
with:
23+
exporter: redis-exporter
24+
artifactory_token: ${{ secrets.ARTI_TOKEN }}
25+
artifactory_username: david.lorite@sysdig.com
26+
sysdig_secure_token: ${{ secrets.SYSDIG_SECURE_TOKEN }}
27+
tag_name: dev
28+
target: ${{ matrix.docker }}
29+
repository: artifactory.internal.sysdig.com

.github/workflows/push.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Push
2+
3+
# Controls when the action will run. Triggers the workflow on push or pull request
4+
# events but only for the master branch
5+
on:
6+
workflow_run:
7+
workflows: [Release]
8+
types: [completed]
9+
10+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
11+
jobs:
12+
# This workflow contains a single job called "build"
13+
on-success:
14+
# The type of runner that the job will run on
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Upload master to Quay.io
18+
uses: fjogeleit/http-request-action@master
19+
with:
20+
url: 'https://sysdig-jenkins.internal.sysdig.com/view/Integrations/job/integrations-redis-exporter/buildWithParameters?token=${{ secrets.JENKINS_PROMCAT_LAUNCH_TOKEN }}&EXPORTER=redis-exporter&DRY_RUN=false'
21+
method: 'POST'
22+
username: david.lorite@sysdig.com
23+
password: ${{ secrets.JENKINS_PROMCAT_API_TOKEN }}

.github/workflows/release.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Release
2+
on:
3+
release:
4+
types: [released]
5+
jobs:
6+
buildDockerImage:
7+
strategy:
8+
matrix:
9+
docker: ['scratch','ubi']
10+
name: Build docker image ${{ matrix.docker }}
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Release if tagged
14+
if: "!startswith(github.ref, 'refs/tags/v')"
15+
run: exit 78
16+
- name: build
17+
uses: sysdiglabs/exporter-builder@v0.4
18+
with:
19+
exporter: redis-exporter
20+
artifactory_token: ${{ secrets.ARTI_TOKEN }}
21+
artifactory_username: david.lorite@sysdig.com
22+
tag_name: ${{ github.event.release.tag_name }}
23+
target: ${{ matrix.docker }}
24+
repository: artifactory.internal.sysdig.com

Dockerfile

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
FROM golang:1.17 as builder
2+
WORKDIR /go/src/github.com/oliver006/redis_exporter/
3+
4+
ADD . /go/src/github.com/oliver006/redis_exporter/
5+
6+
ARG GOARCH="amd64"
7+
ARG SHA1="[no-sha]"
8+
ARG TAG="[no-tag]"
9+
10+
RUN BUILD_DATE=$(date +%F-%T) CGO_ENABLED=0 GOOS=linux GOARCH=$GOARCH go build -o /redis_exporter \
11+
-ldflags "-s -w -extldflags \"-static\" -X main.BuildVersion=$TAG -X main.BuildCommitSha=$SHA1 -X main.BuildDate=$BUILD_DATE" .
12+
13+
RUN [ $GOARCH = "amd64" ] && /redis_exporter -version || ls -la /redis_exporter
14+
15+
#
16+
# scratch release container
17+
#
18+
FROM scratch as scratch
19+
20+
COPY --from=builder /redis_exporter /redis_exporter
21+
COPY --from=builder /etc/ssl/certs /etc/ssl/certs
22+
COPY --from=builder /etc/nsswitch.conf /etc/nsswitch.conf
23+
24+
# Run as non-root user for secure environments
25+
USER 59000:59000
26+
27+
EXPOSE 9121
28+
ENTRYPOINT [ "/redis_exporter" ]
29+
30+
FROM quay.io/sysdig/sysdig-mini-ubi:1.2.12 as ubi
31+
32+
COPY --from=builder /redis_exporter /redis_exporter
33+
COPY --from=builder /etc/ssl/certs /etc/ssl/certs
34+
COPY --from=builder /etc/nsswitch.conf /etc/nsswitch.conf
35+
36+
# Run as non-root user for secure environments
37+
USER 59000:59000
38+
39+
EXPOSE 9121
40+
ENTRYPOINT [ "/redis_exporter" ]

build/Jenkinsfile

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
string projectName = "prometheus-integrations"
2+
3+
pipeline {
4+
agent none
5+
6+
7+
options {
8+
skipDefaultCheckout()
9+
}
10+
11+
environment {
12+
registryCredential = 'jenkins-artifactory'
13+
ARTIFACTORY_URL = 'docker.internal.sysdig.com'
14+
}
15+
16+
parameters {
17+
booleanParam(name: 'DRY_RUN', defaultValue: true, description: 'Perform a dry run (does not push images)')
18+
string(name: 'EXPORTER', defaultValue: "exporter", description: 'Exporter name')
19+
}
20+
21+
stages {
22+
stage('Pull image from artifactory') {
23+
agent any
24+
steps {
25+
script {
26+
docker.withRegistry("https://${env.ARTIFACTORY_URL}", registryCredential) {
27+
sh """docker pull ${env.ARTIFACTORY_URL}/${env.EXPORTER}:latest"""
28+
env.VERSION = sh(script:"""docker inspect --format '{{ index .Config.Labels "release" }}' ${env.ARTIFACTORY_URL}/${env.EXPORTER}:latest""", returnStdout: true).trim()
29+
echo "VERSION = ${env.VERSION}"
30+
sh """docker pull ${env.ARTIFACTORY_URL}/${env.EXPORTER}:${env.VERSION}"""
31+
sh """docker pull ${env.ARTIFACTORY_URL}/${env.EXPORTER}:${env.VERSION}-ubi"""
32+
}
33+
}
34+
}
35+
}
36+
stage('Push image to Quay'){
37+
agent any
38+
steps {
39+
script {
40+
if (params.DRY_RUN) {
41+
echo "docker push quay.io/sysdig/${env.EXPORTER}:${env.VERSION}"
42+
} else {
43+
docker.withRegistry("https://quay.io", "QUAY") {
44+
sh """docker tag ${env.ARTIFACTORY_URL}/${env.EXPORTER}:${env.VERSION} quay.io/sysdig/${env.EXPORTER}:${env.VERSION}"""
45+
sh """docker tag ${env.ARTIFACTORY_URL}/${env.EXPORTER}:${env.VERSION} quay.io/sysdig/${env.EXPORTER}:latest"""
46+
sh """docker tag ${env.ARTIFACTORY_URL}/${env.EXPORTER}:${env.VERSION}-ubi quay.io/sysdig/${env.EXPORTER}:${env.VERSION}-ubi"""
47+
sh """docker push quay.io/sysdig/${env.EXPORTER}:${env.VERSION}"""
48+
sh """docker push quay.io/sysdig/${env.EXPORTER}:latest"""
49+
sh """docker push quay.io/sysdig/${env.EXPORTER}:${env.VERSION}-ubi"""
50+
}
51+
}
52+
}
53+
}
54+
}
55+
} //stages
56+
}

0 commit comments

Comments
 (0)