Skip to content

Commit

Permalink
Merge pull request #5 from nohn/build_docker_image_via_github_actions
Browse files Browse the repository at this point in the history
Build docker image via GitHub actions
  • Loading branch information
kic68 authored Nov 5, 2023
2 parents e213eed + ae100fa commit 7e555c3
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: CI

on:
push:
branches: [ master ]
pull_request:

jobs:
docker-build-push:
runs-on: ubuntu-latest
steps:
- name: 'Pull Code'
uses: actions/checkout@main
- name: 'Login to GitHub Container Registry'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}
- name: 'Build Inventory Image'
run: |
docker build . --tag ghcr.io/$GITHUB_REPOSITORY_OWNER/downdetector-exporter:latest
docker push ghcr.io/$GITHUB_REPOSITORY_OWNER/downdetector-exporter:latest
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
downdetector-credentials.yaml
downdetector-exporter
*~
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM golang:1.19 AS build-stage

WORKDIR /app

COPY go.mod go.sum ./
RUN go mod download

COPY *.go ./
RUN CGO_ENABLED=0 GOOS=linux go build -o /downdetector-exporter

FROM gcr.io/distroless/base-debian12 AS build-release-stage

WORKDIR /
COPY --from=build-stage /downdetector-exporter /downdetector-exporter
EXPOSE 9313
USER nonroot:nonroot
ENTRYPOINT ["/downdetector-exporter"]

45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,51 @@ METRICS_PATH
LOG_LEVEL
```

#### Running in Docker Compose

Example of running in docker compose using some the above variables

```
services:
downdetector-exporter:
container_name: downdetector-exporter
image: ghcr.io/kic68/downdetector-exporter
restart: always
environment:
- COMPANY_IDS=23456,12345,34567
- DD_USERNAME=client-id
- DD_PASSWORD=secret-token
```

#### Running in Kubernetes

Example of running in kubernetes:

```
apiVersion: apps/v1
kind: Deployment
metadata:
name: downdetector-exporter
spec:
replicas: 1
strategy: {}
template:
spec:
containers:
- env:
- name: COMPANY_IDS
value: "23456,12345,34567"
- name: DD_USERNAME
value: client-id
- name: DD_PASSWORD
value: secret-token
image: ghcr.io/kic68/downdetector-exporter
name: downdetector-exporter
resources: {}
restartPolicy: Always
status: {}
```

### Grafana dashboard

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

0 comments on commit 7e555c3

Please sign in to comment.