Skip to content

Commit 7e555c3

Browse files
authored
Merge pull request #5 from nohn/build_docker_image_via_github_actions
Build docker image via GitHub actions
2 parents e213eed + ae100fa commit 7e555c3

File tree

4 files changed

+87
-0
lines changed

4 files changed

+87
-0
lines changed

.github/workflows/ci.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
8+
jobs:
9+
docker-build-push:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: 'Pull Code'
13+
uses: actions/checkout@main
14+
- name: 'Login to GitHub Container Registry'
15+
uses: docker/login-action@v3
16+
with:
17+
registry: ghcr.io
18+
username: ${{github.actor}}
19+
password: ${{secrets.GITHUB_TOKEN}}
20+
- name: 'Build Inventory Image'
21+
run: |
22+
docker build . --tag ghcr.io/$GITHUB_REPOSITORY_OWNER/downdetector-exporter:latest
23+
docker push ghcr.io/$GITHUB_REPOSITORY_OWNER/downdetector-exporter:latest

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
downdetector-credentials.yaml
22
downdetector-exporter
3+
*~

Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM golang:1.19 AS build-stage
2+
3+
WORKDIR /app
4+
5+
COPY go.mod go.sum ./
6+
RUN go mod download
7+
8+
COPY *.go ./
9+
RUN CGO_ENABLED=0 GOOS=linux go build -o /downdetector-exporter
10+
11+
FROM gcr.io/distroless/base-debian12 AS build-release-stage
12+
13+
WORKDIR /
14+
COPY --from=build-stage /downdetector-exporter /downdetector-exporter
15+
EXPOSE 9313
16+
USER nonroot:nonroot
17+
ENTRYPOINT ["/downdetector-exporter"]
18+

README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,51 @@ METRICS_PATH
110110
LOG_LEVEL
111111
```
112112

113+
#### Running in Docker Compose
114+
115+
Example of running in docker compose using some the above variables
116+
117+
```
118+
services:
119+
downdetector-exporter:
120+
container_name: downdetector-exporter
121+
image: ghcr.io/kic68/downdetector-exporter
122+
restart: always
123+
environment:
124+
- COMPANY_IDS=23456,12345,34567
125+
- DD_USERNAME=client-id
126+
- DD_PASSWORD=secret-token
127+
```
128+
129+
#### Running in Kubernetes
130+
131+
Example of running in kubernetes:
132+
133+
```
134+
apiVersion: apps/v1
135+
kind: Deployment
136+
metadata:
137+
name: downdetector-exporter
138+
spec:
139+
replicas: 1
140+
strategy: {}
141+
template:
142+
spec:
143+
containers:
144+
- env:
145+
- name: COMPANY_IDS
146+
value: "23456,12345,34567"
147+
- name: DD_USERNAME
148+
value: client-id
149+
- name: DD_PASSWORD
150+
value: secret-token
151+
image: ghcr.io/kic68/downdetector-exporter
152+
name: downdetector-exporter
153+
resources: {}
154+
restartPolicy: Always
155+
status: {}
156+
```
157+
113158
### Grafana dashboard
114159

115160
There's a grafana_dashboard.json file in the repository which can be imported to Grafana.

0 commit comments

Comments
 (0)