Skip to content

Commit c33f647

Browse files
committed
Update deps
1 parent ad76d1f commit c33f647

File tree

12 files changed

+123
-169
lines changed

12 files changed

+123
-169
lines changed

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
*
22

3-
!app.go
3+
!*.go
44
!go.mod
55
!go.sum

.github/dependabot.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,11 @@ updates:
1313
directory: "/"
1414
schedule:
1515
interval: "monthly"
16+
- package-ecosystem: "docker"
17+
directory: "/"
18+
schedule:
19+
interval: "monthly"
20+
- package-ecosystem: "docker-compose"
21+
directory: "/"
22+
schedule:
23+
interval: "monthly"

.github/workflows/build_and_test.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,15 @@ jobs:
1919
- name: Set up Go
2020
uses: actions/setup-go@v5
2121
with:
22-
go-version: 1.18
2322
check-latest: true
2423
cache: true
2524

25+
- name: Check format
26+
run: |
27+
if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then
28+
exit 1
29+
fi
30+
2631
- name: Build
2732
run: go build -v app.go
2833

.github/workflows/codeql-analysis.yml

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

.github/workflows/dependabot_updates.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
steps:
1818
- name: Dependabot metadata
1919
id: metadata
20-
uses: dependabot/fetch-metadata@v2.4.0
20+
uses: dependabot/fetch-metadata@v2
2121
with:
2222
github-token: "${{ secrets.GITHUB_TOKEN }}"
2323

.github/workflows/publish.yml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,18 @@ jobs:
1717
runs-on: ubuntu-latest
1818

1919
steps:
20-
- name: Set version variable
21-
id: version
20+
# checkout is NOT needed for docker/build-push-action
21+
22+
- name: Set version variables
23+
id: vars
2224
run: |
23-
echo "tag=${GITHUB_REF#refs/*/}"
24-
echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
25+
TAG=${GITHUB_REF#refs/*/}
26+
MAJOR=$(echo $TAG | grep -oP '^v\d+')
27+
MINOR=$(echo $TAG | grep -oP '^v\d+\.\d+')
28+
PATCH=$TAG
29+
echo "major=$MAJOR" >> $GITHUB_OUTPUT
30+
echo "minor=$MINOR" >> $GITHUB_OUTPUT
31+
echo "patch=$PATCH" >> $GITHUB_OUTPUT
2532
2633
- name: Set up QEMU
2734
uses: docker/setup-qemu-action@v3
@@ -42,8 +49,12 @@ jobs:
4249
with:
4350
platforms: linux/amd64,linux/arm64,linux/arm/v7
4451
push: true
52+
cache-from: type=gha
53+
cache-to: type=gha,mode=max
4554
tags: |
46-
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version.outputs.tag }}
55+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.vars.outputs.major }}
56+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.vars.outputs.minor }}
57+
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.vars.outputs.patch }}
4758
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
4859
4960
- name: Print image digest

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
app
1+
.vscode/
2+
app
3+
container-mon

Dockerfile

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
# Build the app
2-
FROM golang:1.24-alpine AS build
2+
# https://docs.docker.com/build/building/multi-platform/#cross-compiling-a-go-application
3+
FROM --platform=$BUILDPLATFORM golang:1.25-alpine AS build
4+
ARG TARGETOS
5+
ARG TARGETARCH
36

47
WORKDIR /build
58
COPY . .
6-
RUN go build app.go
9+
RUN RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o container-mon
710

811
# Run the app
9-
FROM alpine:latest
12+
FROM alpine:3
1013

11-
LABEL org.opencontainers.image.source https://github.com/RafhaanShah/Container-Mon
14+
LABEL org.opencontainers.image.source=https://github.com/RafhaanShah/Container-Mon
1215

1316
WORKDIR /app
14-
COPY --from=build /build/app /app
15-
ENTRYPOINT ["./app"]
17+
COPY --from=build /build/container-mon /app
18+
ENTRYPOINT ["./container-mon"]

README.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,18 @@ Get notified when your [Docker](https://www.docker.com/) containers are unhealth
66
![](/assets/screenshot.jpg)
77

88
## Prerequisites
9-
- Have [Go](https://golang.org/) 1.18+ or [Docker](https://www.docker.com/) installed
109
- A notification service supported by [Shoutrrr](https://containrrr.dev/shoutrrr/services/overview/) and the required API keys or other configuration for your chosen service (e.g: Telegram, Discord, Slack, Teams etc)
1110

11+
## Building
12+
Build the app:
13+
```
14+
go build
15+
```
16+
Format:
17+
```
18+
gofmt -w .
19+
```
20+
1221
## Configuration
1322
All configuration is done via environment variables, see the table below for all options and default values. Only `CONTAINERMON_NOTIFICATION_URL` is mandatory, all other fields are optional.
1423
| Name | Type | Default Value | Description |
@@ -30,14 +39,14 @@ All configuration is done via environment variables, see the table below for all
3039
- Stand-alone:
3140
`go run app.go`
3241
- Docker:
33-
```
34-
docker run \
35-
-v /var/run/docker.sock:/var/run/docker.sock \
36-
-e CONTAINERMON_NOTIFICATION_URL=telegram://token@telegram?channels=channel-1 \
37-
ghcr.io/rafhaanshah/container-mon:latest
42+
```shell
43+
docker run \
44+
-v /var/run/docker.sock:/var/run/docker.sock \
45+
-e CONTAINERMON_NOTIFICATION_URL=telegram://token@telegram?channels=channel-1 \
46+
ghcr.io/rafhaanshah/container-mon:latest
3847
```
3948
- Docker-Compose:
40-
```
49+
```yaml
4150
version: "3.8"
4251
services:
4352
container-mon:

app.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func getContainers(ctx context.Context, cli *client.Client, filterByLabel bool,
131131

132132
func isHealthy(ctx context.Context, cli *client.Client, c types.Container, conf config) bool {
133133
running := c.State == "running"
134-
134+
135135
containerJSON, err := cli.ContainerInspect(ctx, c.ID)
136136
if conf.checkContainerExitCode && c.State == "exited" {
137137
// If the container is stopped ("exited"), we need to inspect it to get the exit code.
@@ -152,7 +152,7 @@ func isHealthy(ctx context.Context, cli *client.Client, c types.Container, conf
152152
}
153153

154154
healthy := health.Status == types.Healthy
155-
return healthy
155+
return healthy
156156
}
157157

158158
func getConfig() config {

0 commit comments

Comments
 (0)