Skip to content

Commit

Permalink
docker image, github workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelkoetter committed Sep 19, 2022
1 parent dbdde8e commit 772830b
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.git/
.github/
venv/
.env
example-*
test.conf
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
61 changes: 61 additions & 0 deletions .github/workflows/build-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Build Docker Image

on:
push:
branches:
- master
paths-ignore:
- README.md
release:
types: [published]

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3.0.2

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Docker meta
id: meta
uses: docker/metadata-action@v4.0.1
with:
images: mkoetter/netbox-kea-subnets
tags: |
type=edge
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
id: docker_build
uses: docker/build-push-action@v3.1.1
with:
context: .
push: true
platforms: linux/amd64, linux/arm/v6, linux/arm/v7, linux/arm64/v8
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}

- name: Docker Hub Description
uses: peter-evans/dockerhub-description@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: mkoetter/netbox-kea-subnets
short-description: ${{ github.event.repository.description }}
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM python:3-alpine

WORKDIR /usr/src/app

COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt

COPY . .

ENTRYPOINT [ "python", "./kea-subnets.py" ]
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
# Configure Kea DHCP Subnets using Netbox

[![Build Docker Image](https://github.com/michaelkoetter/netbox-kea-subnets/actions/workflows/build-image.yml/badge.svg)](https://github.com/michaelkoetter/netbox-kea-subnets/actions/workflows/build-image.yml)
[![image-version](https://img.shields.io/static/v1?logo=docker&label=Docker+Hub&message=mkoetter/netbox-kea-subnets&color=informational)](https://hub.docker.com/r/mkoetter/netbox-kea-subnets)

This script fetches data from Netbox to create Kea subnet configuration from Prefixes, IP Ranges and IP Addresses.

A Jinja2 template is used to render each subnet. It can be customized to add additional data, e.g. from Netbox custom fields (see example in `templates`).

## Installation
## Docker Images

Docker Images are automatically built for new releases.

```bash
docker run --rm mkoetter/netbox-kea-subnets:latest --help
```

## Development

```bash
python3 -m venv venv/
Expand Down

0 comments on commit 772830b

Please sign in to comment.