Skip to content

Commit

Permalink
Merge pull request #4 from vshn/ci/cd
Browse files Browse the repository at this point in the history
Clean up Dockerfile and Setup CI/CD and Renovate
  • Loading branch information
mhutter authored Aug 16, 2024
2 parents fee635c + 2ba83bb commit 59ab833
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.git/
.github/
Dockerfile
README.md
renovate.json
47 changes: 47 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Build & Push Container Image
on:
push:
branches:
- main
tags:
- "v*"
pull_request: {}

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
# Push image to GitHub Packages.
build_and_push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v4
with:
fetch-depth: "0"

- name: Log in to the Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Determine Tags & Labels based on Git ref
id: meta
uses: docker/metadata-action@v5
with:
images: "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"

- name: Build & Push container image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
19 changes: 19 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Test
on:
pull_request:
branches:
- main

jobs:
test:
name: Docker build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build image
run: docker build -t test .
- name: Run image
run: docker run -d --name clamav test
- name: Verify
run: |
[ $(docker inspect clamav --format='{{.State.Running}}') = 'true' ]
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM docker.io/library/alpine:3.19

ENV CLAMAV_VERSION=1.2.2-r0
# renovate: datasource=repology depName=alpine_3_19/clamav versioning=loose
ENV CLAMAV_VERSION="1.2.2-r0"

RUN apk add --no-cache \
clamav-daemon=${CLAMAV_VERSION} \
Expand Down
19 changes: 17 additions & 2 deletions renovate.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:recommended"
"extends": ["config:recommended"],
"reviewers": ["team:nunki"],
"customManagers": [
{
"customType": "regex",
"fileMatch": ["^Dockerfile$"],
"matchStrings": [
"#\\s*renovate:\\s*datasource=(?<datasource>.*?) depName=(?<depName>.*?)( versioning=(?<versioning>.*?))?\\sENV .*?_VERSION=\"(?<currentValue>.*)\"\\s"
],
"versioningTemplate": "{{#if versioning}}{{{versioning}}}{{else}}semver{{/if}}"
}
],
"packageRules": [
{
"matchUpdateTypes": ["patch", "digest"],
"automerge": true
}
]
}

0 comments on commit 59ab833

Please sign in to comment.