Skip to content

Commit

Permalink
Merge pull request #18 from privacybydesign/Dockerize
Browse files Browse the repository at this point in the history
Dockerizing watchdog
  • Loading branch information
saravahdatipour authored Jan 17, 2025
2 parents ba9d9a3 + 595f756 commit 5b8d6b2
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 2 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/delivery.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
16 changes: 16 additions & 0 deletions .github/workflows/status-check.yaml
Original file line number Diff line number Diff line change
@@ -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 .
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
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

COPY --from=builder /app/watchdogd /app/watchdogd

EXPOSE 8080

WORKDIR /app

ENTRYPOINT ["/app/watchdogd"]
8 changes: 8 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: '3'
services:
watchdog:
build: .
ports:
- "8080:8080"
volumes:
- ./config.yaml:/app/config.yaml
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 = `
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5b8d6b2

Please sign in to comment.