From 1f2831a7606daa6ae049047403ddc329f1fa8e69 Mon Sep 17 00:00:00 2001 From: saravahdatipour Date: Thu, 16 Jan 2025 16:49:28 +0100 Subject: [PATCH 1/5] Dockerizing watchdog --- Dockerfile | 23 +++++++++++++++++++++++ docker-compose.yaml | 8 ++++++++ 2 files changed, 31 insertions(+) create mode 100644 Dockerfile create mode 100644 docker-compose.yaml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..de1fb2a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,23 @@ +FROM golang:1.21 AS builder + +WORKDIR /app + +COPY go.mod go.sum ./ + +RUN go mod download + +COPY . . + +RUN CGO_ENABLED=0 GOOS=linux go build -o watchdogd + +FROM alpine:latest + +RUN mkdir -p /tmp && chmod 777 /tmp + +COPY --from=builder /app/watchdogd /app/watchdogd + +EXPOSE 8079 + +WORKDIR /app + +ENTRYPOINT ["/app/watchdogd"] \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..55d8e55 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,8 @@ +version: '3' +services: + watchdog: + build: . + ports: + - "8079:8079" + volumes: + - ./config.yaml:/app/config.yaml \ No newline at end of file From 463867d9f8fa56a77830d34ac96d6fb9a3ad8493 Mon Sep 17 00:00:00 2001 From: saravahdatipour Date: Thu, 16 Jan 2025 17:05:58 +0100 Subject: [PATCH 2/5] No need for tmp dir when not using slim alpine --- Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index de1fb2a..c6f82c2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,8 +12,6 @@ RUN CGO_ENABLED=0 GOOS=linux go build -o watchdogd FROM alpine:latest -RUN mkdir -p /tmp && chmod 777 /tmp - COPY --from=builder /app/watchdogd /app/watchdogd EXPOSE 8079 From d2337e2e5eb1d078223becf0ec2fe429e9af55bb Mon Sep 17 00:00:00 2001 From: saravahdatipour Date: Thu, 16 Jan 2025 17:17:19 +0100 Subject: [PATCH 3/5] Add GitHub Delivery Workflows --- .github/workflows/delivery.yaml | 39 +++++++++++++++++++++++++++++ .github/workflows/status-check.yaml | 16 ++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 .github/workflows/delivery.yaml create mode 100644 .github/workflows/status-check.yaml diff --git a/.github/workflows/delivery.yaml b/.github/workflows/delivery.yaml new file mode 100644 index 0000000..07e36ec --- /dev/null +++ b/.github/workflows/delivery.yaml @@ -0,0 +1,39 @@ +name: Delivery + +on: + # Allow triggering pushing to GHCR manually. + workflow_dispatch: + +permissions: + contents: write + packages: write + +jobs: + publish-docker-image: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }} + tags: | + type=raw,value=${{ github.ref == 'refs/heads/master' && 'latest' || 'staging' }} + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build container and push to GitHub Container Registry + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/.github/workflows/status-check.yaml b/.github/workflows/status-check.yaml new file mode 100644 index 0000000..0d1a4c3 --- /dev/null +++ b/.github/workflows/status-check.yaml @@ -0,0 +1,16 @@ +name: Status checks + +on: + push: + branches: [ master ] + pull_request: + # Make it possible to trigger the checks manually. + workflow_dispatch: + +jobs: + docker-build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Run Dockerfile build stage + run: docker build -t privacybydesign/irma-watchdogd:build . \ No newline at end of file From dc442557cfc271da732accec66146d38be34b08b Mon Sep 17 00:00:00 2001 From: saravahdatipour Date: Fri, 17 Jan 2025 10:43:39 +0100 Subject: [PATCH 4/5] Bind outbound to 8080 --- Dockerfile | 2 +- docker-compose.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index c6f82c2..d100692 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,7 +14,7 @@ FROM alpine:latest COPY --from=builder /app/watchdogd /app/watchdogd -EXPOSE 8079 +EXPOSE 8080 WORKDIR /app diff --git a/docker-compose.yaml b/docker-compose.yaml index 55d8e55..2248854 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -3,6 +3,6 @@ services: watchdog: build: . ports: - - "8079:8079" + - "8080:8079" volumes: - ./config.yaml:/app/config.yaml \ No newline at end of file From 595f7569c402fd6929911f53f9477cbe08748888 Mon Sep 17 00:00:00 2001 From: saravahdatipour Date: Fri, 17 Jan 2025 11:48:49 +0100 Subject: [PATCH 5/5] Bind to :8080in the go app itself --- docker-compose.yaml | 2 +- main.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 2248854..56c0255 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -3,6 +3,6 @@ services: watchdog: build: . ports: - - "8080:8079" + - "8080:8080" volumes: - ./config.yaml:/app/config.yaml \ No newline at end of file diff --git a/main.go b/main.go index 9c7039e..da41b3c 100644 --- a/main.go +++ b/main.go @@ -37,7 +37,7 @@ var exampleConfig string = ` MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAELzHV5ipBimWpuZIDaQQd+KmNpNop dpBeCqpDwf+Grrw9ReODb6nwlsPJ/c/gqLnc+Y3sKOAJ2bFGI+jHBSsglg== -----END PUBLIC KEY----- - bindaddr: ':8079' + bindaddr: ':8080' interval: 5m ` var rawTemplate string = ` @@ -102,7 +102,7 @@ func main() { var confPath string // set configuration defaults - conf.BindAddr = ":8079" + conf.BindAddr = ":8080" conf.Interval = 5 * time.Minute // parse commandline