move pipeline to github native, remove redundant dockerfiles, and add helper actions
This commit is contained in:
parent
f5aa55a1db
commit
eeb0198e3d
6 changed files with 186 additions and 48 deletions
23
.github/actions/docker-multi-login-action/action.yml
vendored
Normal file
23
.github/actions/docker-multi-login-action/action.yml
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
name: 'Docker Multi Login Action'
|
||||
description: 'Log in to dockerhub, quay, and github container registry'
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- shell: bash
|
||||
run: |
|
||||
echo "🔑 Logging into dockerhub..."
|
||||
if docker login --username ${{ fromJSON(env.secrets).DOCKERHUB_USERNAME }} --password ${{ fromJSON(env.secrets).DOCKERHUB_PASSWORD }} > /dev/null 2>&1; then
|
||||
echo "🎉 Login Succeeded!"
|
||||
fi
|
||||
- shell: bash
|
||||
run: |
|
||||
echo "🔑 Logging into quay.io..."
|
||||
if docker login quay.io --username ${{ fromJSON(env.secrets).QUAY_USERNAME }} --password ${{ fromJSON(env.secrets).QUAY_PASSWORD }} > /dev/null 2>&1; then
|
||||
echo "🎉 Login Succeeded!"
|
||||
fi
|
||||
- shell: bash
|
||||
run: |
|
||||
echo "🔑 Logging into ghcr.io..."
|
||||
if docker login ghcr.io --username ${{ fromJSON(env.secrets).GHCR_USERNAME }} --password ${{ fromJSON(env.secrets).GHCR_PASSWORD }} > /dev/null 2>&1; then
|
||||
echo "🎉 Login Succeeded!"
|
||||
fi
|
46
.github/actions/docker-target-image-list-action/action.yml
vendored
Normal file
46
.github/actions/docker-target-image-list-action/action.yml
vendored
Normal file
|
@ -0,0 +1,46 @@
|
|||
name: 'Docker Target Image List Generator'
|
||||
description: 'A Github Action to generate a list of fully qualified target images for docker related steps'
|
||||
inputs:
|
||||
registries:
|
||||
description: "Comma separated list of docker registries"
|
||||
required: false
|
||||
default: "docker.io,quay.io,ghcr.io"
|
||||
images:
|
||||
description: "Comma separated list of images"
|
||||
required: true
|
||||
tags:
|
||||
description: "Comma separated list of image tags"
|
||||
required: false
|
||||
default: "edge"
|
||||
outputs:
|
||||
fully-qualified-target-images:
|
||||
description: "List of fully qualified docker target images"
|
||||
value: ${{ steps.gen-fqti.outputs.fully-qualified-target-images }}
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Generate fully qualified docker target images
|
||||
id: gen-fqti
|
||||
shell: bash
|
||||
run: |
|
||||
IFS=',' read -r -a registries <<< "${{ inputs.registries }}"
|
||||
IFS=',' read -r -a images <<< "${{ inputs.images }}"
|
||||
IFS=',' read -r -a tags <<< "${{ inputs.tags }}"
|
||||
FQTI=""
|
||||
echo "Generating fully qualified docker target images for:"
|
||||
echo "🐋 Registries: ${#registries[@]}"
|
||||
echo "📷 Images: ${#images[@]}"
|
||||
echo "🏷️ Tags: ${#tags[@]}"
|
||||
echo "🧮 Total: $((${#registries[@]}*${#images[@]}*${#tags[@]}))"
|
||||
for registry in "${registries[@]}"; do
|
||||
for image in "${images[@]}"; do
|
||||
for tag in "${tags[@]}"; do
|
||||
if [ -z "$FQTI" ]; then
|
||||
FQTI="${registry}/${image}:${tag}"
|
||||
else
|
||||
FQTI="$FQTI,${registry}/${image}:${tag}"
|
||||
fi
|
||||
done
|
||||
done
|
||||
done
|
||||
echo ::set-output name=fully-qualified-target-images::${FQTI}
|
106
.github/workflows/docker.yaml
vendored
Normal file
106
.github/workflows/docker.yaml
vendored
Normal file
|
@ -0,0 +1,106 @@
|
|||
name: varken
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 10 * * *'
|
||||
push:
|
||||
branches: master
|
||||
tags:
|
||||
- 'v*.*.*'
|
||||
paths:
|
||||
- 'varken/**'
|
||||
- 'Varken.py'
|
||||
- 'Dockerfile'
|
||||
pull_request:
|
||||
branches: master
|
||||
paths:
|
||||
- 'varken/**'
|
||||
- 'Varken.py'
|
||||
- 'Dockerfile'
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
tag:
|
||||
description: 'Use this tag instead of most recent'
|
||||
required: false
|
||||
ignore-existing-tag:
|
||||
description: 'Ignore existing tag if "true"'
|
||||
required: false
|
||||
env:
|
||||
IMAGES: ${{ github.repository_owner }}/${{ github.workflow }}
|
||||
PLATFORMS: "linux/amd64,linux/arm64,linux/arm/v7"
|
||||
jobs:
|
||||
lint-and-test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-verison: '3.x'
|
||||
run: pip install flake8
|
||||
- name: Lint
|
||||
run: flake8 --max-line-length 120 Varken.py varken/*.py
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
needs: lint-and-test
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Prepare
|
||||
id: prep
|
||||
run: |
|
||||
VERSION=edge
|
||||
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
||||
VERSION=${GITHUB_REF#refs/tags/v}
|
||||
fi
|
||||
if [ "${{ github.event_name }}" = "schedule" ]; then
|
||||
VERSION=nightly
|
||||
fi
|
||||
TAGS="${VERSION}"
|
||||
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
|
||||
TAGS="$TAGS,latest"
|
||||
fi
|
||||
echo ::set-output name=version::${VERSION}
|
||||
echo ::set-output name=tags::${TAGS}
|
||||
echo ::set-output name=build_date::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
|
||||
echo ::set-output name=vcs_ref::${GITHUB_SHA::8}
|
||||
- uses: ./.github/actions/docker-target-image-list-action
|
||||
name: Generate Target Images
|
||||
id: gen-tags
|
||||
with:
|
||||
images: ${{ env.IMAGES }}
|
||||
tags: ${{ steps.prep.outputs.tags }}
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
with:
|
||||
platforms: ${{ env.PLATFORMS }}
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
with:
|
||||
install: true
|
||||
version: latest
|
||||
driver-opts: image=moby/buildkit:master
|
||||
- name: Docker Multi Login
|
||||
uses: ./.github/actions/docker-multi-login-action
|
||||
env:
|
||||
secrets: ${{ toJSON(secrets) }}
|
||||
- name: Build and Push
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
platforms: ${{ env.PLATFORMS }}
|
||||
pull: true
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
tags: ${{ steps.gen-tags.outputs.fully-qualified-target-images }}
|
||||
build-args: |
|
||||
VERSION=${{ steps.prep.outputs.version }}
|
||||
BUILD_DATE=${{ steps.prep.outputs.build_date }}
|
||||
VCS_REF=${{ steps.prep.outputs.vcs_ref }}
|
||||
- name: Inspect
|
||||
if: ${{ github.event_name != 'pull_request' }}
|
||||
run: |
|
||||
IFS=',' read -r -a images <<< "${{ steps.gen-tags.outputs.fully-qualified-target-images }}"
|
||||
for image in "${images[@]}"; do
|
||||
docker buildx imagetools inspect ${image}
|
||||
done
|
15
Dockerfile
15
Dockerfile
|
@ -1,6 +1,15 @@
|
|||
FROM amd64/python:3.7.3-alpine
|
||||
FROM python:3.9.1-alpine
|
||||
|
||||
LABEL maintainers="dirtycajunrice,samwiseg0"
|
||||
LABEL maintainer="dirtycajunrice,samwiseg0" \
|
||||
org.opencontainers.image.created=$BUILD_DATE \
|
||||
org.opencontainers.image.url="https://github.com/Boerderij/Varken" \
|
||||
org.opencontainers.image.source="https://github.com/Boerderij/Varken" \
|
||||
org.opencontainers.image.version=$VERSION \
|
||||
org.opencontainers.image.revision=$VCS_REF \
|
||||
org.opencontainers.image.vendor="boerderij" \
|
||||
org.opencontainers.image.title="varken" \
|
||||
org.opencontainers.image.description="Varken is a standalone application to aggregate data from the Plex ecosystem into InfluxDB using Grafana for a frontend" \
|
||||
org.opencontainers.image.licenses="MIT"
|
||||
|
||||
ENV DEBUG="True"
|
||||
|
||||
|
@ -20,5 +29,3 @@ RUN apk add --no-cache tzdata && \
|
|||
pip install --no-cache-dir -r /app/requirements.txt
|
||||
|
||||
CMD cp /app/data/varken.example.ini /config/varken.example.ini && python3 /app/Varken.py
|
||||
|
||||
VOLUME /config
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
FROM arm32v6/python:3.7.3-alpine
|
||||
|
||||
LABEL maintainers="dirtycajunrice,samwiseg0"
|
||||
|
||||
ENV DEBUG="True"
|
||||
|
||||
ENV DATA_FOLDER="/config"
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY /requirements.txt /Varken.py /app/
|
||||
|
||||
COPY /varken /app/varken
|
||||
|
||||
COPY /data /app/data
|
||||
|
||||
RUN apk add --no-cache tzdata && \
|
||||
pip install --no-cache-dir -r /app/requirements.txt
|
||||
|
||||
CMD cp /app/data/varken.example.ini /config/varken.example.ini && python3 /app/Varken.py
|
||||
|
||||
VOLUME /config
|
|
@ -1,22 +0,0 @@
|
|||
FROM arm64v8/python:3.7.3-alpine
|
||||
|
||||
LABEL maintainers="dirtycajunrice,samwiseg0"
|
||||
|
||||
ENV DEBUG="True"
|
||||
|
||||
ENV DATA_FOLDER="/config"
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY /requirements.txt /Varken.py /app/
|
||||
|
||||
COPY /varken /app/varken
|
||||
|
||||
COPY /data /app/data
|
||||
|
||||
RUN apk add --no-cache tzdata && \
|
||||
pip install --no-cache-dir -r /app/requirements.txt
|
||||
|
||||
CMD cp /app/data/varken.example.ini /config/varken.example.ini && python3 /app/Varken.py
|
||||
|
||||
VOLUME /config
|
Loading…
Reference in a new issue