Skip to content
This repository has been archived by the owner on Aug 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #10 from LizardByte/nightly
Browse files Browse the repository at this point in the history
v0.0.2
  • Loading branch information
ReenigneArcher authored Sep 12, 2022
2 parents 79cc3f4 + 8f8d489 commit 3925eff
Show file tree
Hide file tree
Showing 11 changed files with 258 additions and 4 deletions.
8 changes: 8 additions & 0 deletions .Dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# ignore git files
.git*

# ignore hidden files
.*

# ignore directories
docs/
1 change: 1 addition & 0 deletions .docker_platforms
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
linux/amd64,linux/arm64/v8,linux/arm/v7
4 changes: 2 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
run: |
echo "Installing Requirements"
python --version
python -m pip --no-python-version-warning --disable-pip-version-check install --upgrade pip==20.3.4 setuptools
python -m pip --no-python-version-warning --disable-pip-version-check install --upgrade pip setuptools
# install dev requirements
python -m pip install --upgrade -r requirements-dev.txt
Expand All @@ -62,7 +62,7 @@ jobs:
env:
BUILD_VERSION: ${{ needs.check_changelog.outputs.next_version }}
run: |
python scripts/build_plist.py
python ./scripts/build_plist.py
- name: Test Plex Plugin
working-directory: PlexyGlass.bundle
Expand Down
192 changes: 192 additions & 0 deletions .github/workflows/ci-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
---
# This action is centrally managed in https://github.com/<organization>/.github/
# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in
# the above-mentioned repo.

name: CI Docker

on:
pull_request:
branches: [master, nightly]
types: [opened, synchronize, reopened]
push:
branches: [master, nightly]
workflow_dispatch:

jobs:
check_dockerfile:
name: Check Dockerfile
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Check
id: check
run: |
if [ -f "./Dockerfile" ]
then
FOUND=true
else
FOUND=false
fi
echo "::set-output name=dockerfile::${FOUND}"
outputs:
dockerfile: ${{ steps.check.outputs.dockerfile }}

lint_dockerfile:
name: Lint Dockerfile
needs: [check_dockerfile]
if: ${{ needs.check_dockerfile.outputs.dockerfile == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Lint Dockerfile
uses: actions/checkout@v3

- uses: hadolint/[email protected]
with:
dockerfile: ./Dockerfile

check_changelog:
name: Check Changelog
needs: [check_dockerfile]
if: ${{ needs.check_dockerfile.outputs.dockerfile == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
if: ${{ github.ref == 'refs/heads/master' || github.base_ref == 'master' }}
uses: actions/checkout@v3

- name: Verify Changelog
id: verify_changelog
if: ${{ github.ref == 'refs/heads/master' || github.base_ref == 'master' }}
# base_ref for pull request check, ref for push
uses: LizardByte/.github/actions/verify_changelog@master
with:
token: ${{ secrets.GITHUB_TOKEN }}
outputs:
next_version: ${{ steps.verify_changelog.outputs.changelog_parser_version }}

docker:
name: Docker
needs: [check_dockerfile, check_changelog]
if: ${{ needs.check_dockerfile.outputs.dockerfile == 'true' }}
runs-on: ubuntu-latest
permissions:
packages: write
contents: write

steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive

- name: Prepare
id: prepare
env:
NEXT_VERSION: ${{ needs.check_changelog.outputs.next_version }}
run: |
# get branch name
BRANCH=${GITHUB_HEAD_REF}
if [ -z "$BRANCH" ]
then
echo "This is a PUSH event"
BRANCH=${{ github.ref_name }}
fi
# determine to push image to dockerhub and ghcr or not
if [[ $GITHUB_EVENT_NAME == "push" ]]; then
PUSH=true
else
PUSH=false
fi
# setup the tags
REPOSITORY=${{ github.repository }}
BASE_TAG=$(echo $REPOSITORY | tr '[:upper:]' '[:lower:]')
COMMIT=${{ github.sha }}
TAGS="${BASE_TAG}:${COMMIT:0:7},ghcr.io/${BASE_TAG}:${COMMIT:0:7}"
if [[ $GITHUB_REF == refs/heads/master ]]; then
TAGS="${TAGS},${BASE_TAG}:latest,ghcr.io/${BASE_TAG}:latest"
TAGS="${TAGS},${BASE_TAG}:master,ghcr.io/${BASE_TAG}:master"
elif [[ $GITHUB_REF == refs/heads/nightly ]]; then
TAGS="${TAGS},${BASE_TAG}:nightly,ghcr.io/${BASE_TAG}:nightly"
else
TAGS="${TAGS},${BASE_TAG}:test,ghcr.io/${BASE_TAG}:test"
fi
if [[ ${NEXT_VERSION} != "" ]]; then
TAGS="${TAGS},${BASE_TAG}:${NEXT_VERSION},ghcr.io/${BASE_TAG}:${NEXT_VERSION}"
fi
# read the platforms from `.docker_platforms`
PLATFORMS=$(<.docker_platforms)
echo ::set-output name=branch::${BRANCH}
echo ::set-output name=build_date::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
echo ::set-output name=commit::${COMMIT}
echo ::set-output name=platforms::${PLATFORMS}
echo ::set-output name=push::${PUSH}
echo ::set-output name=tags::${TAGS}
- name: Set Up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
id: buildx

- name: Cache Docker Layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Log in to Docker Hub
if: ${{ steps.prepare.outputs.push == 'true' }} # PRs do not have access to secrets
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Log in to the Container registry
if: ${{ steps.prepare.outputs.push == 'true' }} # PRs do not have access to secrets
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ secrets.GH_BOT_NAME }}
password: ${{ secrets.GH_BOT_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v3
with:
context: ./
file: ./Dockerfile
push: ${{ steps.prepare.outputs.push }}
platforms: ${{ steps.prepare.outputs.platforms }}
build-args: |
BRANCH=${{ steps.prepare.outputs.branch }}
BUILD_DATE=${{ steps.prepare.outputs.build_date }}
BUILD_VERSION=${{ needs.check_changelog.outputs.next_version }}
COMMIT=${{ steps.prepare.outputs.commit }}
tags: ${{ steps.prepare.outputs.tags }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache

- name: Update Docker Hub Description
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
uses: peter-evans/dockerhub-description@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }} # token is not currently supported
repository: ${{ env.BASE_TAG }}
short-description: ${{ github.event.repository.description }}
readme-filepath: ./DOCKER_README.md
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## [0.0.2] - 2022-09-11
### Added
- Add docker-mod for linuxserver plex image
-
## [0.0.1] - 2022-09-09
### Added
- Initial Release
11 changes: 11 additions & 0 deletions DOCKER_README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Docker

This is a docker mod for Plex which adds [PlexyGlass](https://github.com/LizardByte/PlexyGlass) to Plex as a plugin,
to be downloaded/updated during container start.

In plex docker arguments, set an environment variable `DOCKER_MODS=lizardbyte/plexyglass:latest`

If adding multiple mods, enter them in an array separated by `|`, such as
`DOCKER_MODS=lizardbyte/plexyglass:latest|linuxserver/mods:other-plex-mod`

For more information about linuxserver docker-mods, see [here](https://linuxserver.github.io/docker-mods/).
33 changes: 33 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# buildstage
FROM python:2.7.18-alpine3.11 as buildstage

# build args
ARG BUILD_VERSION
ARG COMMIT
ARG GITHUB_SHA=$COMMIT
# note: BUILD_VERSION may be blank, COMMIT is also available
# note: build_plist.py uses BUILD_VERSION and GITHUB_SHA

# setup build directory
RUN mkdir /build
WORKDIR /build/

# copy repo
COPY . .

RUN python # update pip \
-m pip --no-python-version-warning --disable-pip-version-check install --upgrade pip==20.3.4 setuptools \
&& python -m pip install --upgrade -r requirements-dev.txt # install dev requirements \
&& python ./scripts/install_requirements.py # install plugin requirements \
&& python ./scripts/build_plist.py # build plist \
&& rm -r ./scripts/ # remove scripts dir

# single layer deployed image
FROM scratch

# variables
ARG PLUGIN_NAME="PlexyGlass.bundle"
ARG PLUGIN_DIR="/config/Library/Application Support/Plex Media Server/Plug-ins"

# add files from buildstage
COPY --from=buildstage /build/ $PLUGIN_DIR/$PLUGIN_NAME
3 changes: 3 additions & 0 deletions docs/source/about/docker.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:github_url: https://github.com/LizardByte/PlexyGlass/tree/nightly/DOCKER_README.md

.. mdinclude:: ../../../DOCKER_README.md
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
# 'm2r2', # enable markdown files
'm2r2', # enable markdown files
'numpydoc', # this automatically loads `sphinx.ext.autosummary` as well
'sphinx.ext.autodoc', # autodocument modules
'sphinx.ext.autosectionlabel',
Expand All @@ -92,7 +92,7 @@
exclude_patterns = ['toc.rst']

# Extensions to include.
source_suffix = ['.rst']
source_suffix = ['.rst', '.md']

# Change default contents file
master_doc = 'index'
Expand Down
1 change: 1 addition & 0 deletions docs/source/toc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

about/overview
about/installation
about/docker
about/usage

.. toctree::
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# development environment requirements, these should not be distributed
flake8==3.9.2;python_version<"3"
m2r2==0.3.2;python_version<"3"
numpydoc==0.9.2;python_version<"3"
pathlib2==2.3.7.post1;python_version<"3"
git+https://github.com/LizardByte/plexhints.git#egg=plexhints # type hinting library for plex development
Expand Down

0 comments on commit 3925eff

Please sign in to comment.