diff --git a/.dockerignore b/.dockerignore index f535c9c7..742c4925 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,5 +1,8 @@ .git .github .gitignore +contrib +init-scripts +pylintrc *.md !CHANGELOG*.md diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml new file mode 100644 index 00000000..215e34ed --- /dev/null +++ b/.github/workflows/publish-docker.yml @@ -0,0 +1,82 @@ +name: Publish Docker +on: + push: + branches: [master, beta, nightly] + tags: [v*] +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Prepare + id: prepare + run: | + if [[ $GITHUB_REF == refs/tags/* ]]; then + echo ::set-output name=version::${GITHUB_REF#refs/tags/} + elif [[ $GITHUB_REF == refs/heads/master ]]; then + echo ::set-output name=version::latest + else + echo ::set-output name=version::${GITHUB_REF#refs/heads/} + fi + if [[ $GITHUB_REF == refs/tags/* ]]; then + echo ::set-output name=branch::master + else + echo ::set-output name=branch::${GITHUB_REF#refs/heads/} + fi + echo ::set-output name=build_date::$(date -u +'%Y-%m-%dT%H:%M:%SZ') + echo ::set-output name=docker_platforms::linux/amd64,linux/arm64,linux/arm + echo ::set-output name=docker_image::tautulli/tautulli + + - name: Set up Docker Buildx + id: buildx + uses: crazy-max/ghaction-docker-buildx@v1 + with: + version: latest + + - name: Checkout + uses: actions/checkout@v2 + + - name: Docker Buildx (no push) + run: | + docker buildx build \ + --platform ${{ steps.prepare.outputs.docker_platforms }} \ + --output "type=image,push=false" \ + --build-arg "VERSION=${{ steps.prepare.outputs.version }}" \ + --build-arg "BRANCH=${{ steps.prepare.outputs.branch }}" \ + --build-arg "BUILD_DATE=${{ steps.prepare.outputs.build_date }}" \ + --build-arg "VCS_REF=${GITHUB_SHA::8}" \ + --tag "${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }}" \ + --file Dockerfile . + + - name: Docker Login + if: success() + env: + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + run: | + echo "${DOCKER_PASSWORD}" | docker login --username "${{ secrets.DOCKER_USERNAME }}" --password-stdin + + - name: Docker Buildx (push) + if: success() + run: | + docker buildx build \ + --platform ${{ steps.prepare.outputs.docker_platforms }} \ + --output "type=image,push=true" \ + --build-arg "VERSION=${{ steps.prepare.outputs.version }}" \ + --build-arg "BRANCH=${{ steps.prepare.outputs.branch }}" \ + --build-arg "BUILD_DATE=${{ steps.prepare.outputs.build_date }}" \ + --build-arg "VCS_REF=${GITHUB_SHA::8}" \ + --tag "${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }}" \ + --file Dockerfile . + + - name: Clear + if: always() + run: | + rm -f ${HOME}/.docker/config.json + + - name: Post Status to Discord + uses: sarisia/actions-status-discord@v1 + if: always() + with: + webhook: ${{ secrets.DISCORD_WEBHOOK }} + status: ${{ job.status }} + job: ${{ github.workflow }} + nofail: true diff --git a/.github/workflows/publishrelease.yml b/.github/workflows/publish-release.yml similarity index 87% rename from .github/workflows/publishrelease.yml rename to .github/workflows/publish-release.yml index f5e0b5d9..8834af3f 100644 --- a/.github/workflows/publishrelease.yml +++ b/.github/workflows/publish-release.yml @@ -1,8 +1,7 @@ -name: Create Release +name: Publish Release on: push: - tags: - - 'v*' + tags: [v*] jobs: build: runs-on: ubuntu-latest @@ -10,7 +9,7 @@ jobs: - name: Checkout Code uses: actions/checkout@master - name: Get Release Version - run: echo ::set-env name=RELEASE_VERSION::${GITHUB_REF/refs\/tags\//} + run: echo ::set-env name=RELEASE_VERSION::${GITHUB_REF#refs/tags/} - name: Get Changelog run: echo ::set-env name=CHANGELOG::"$( sed -n '/^## /{p; :loop n; p; /^## /q; b loop}' CHANGELOG.md | sed '$d' | sed '$d' | sed '$d' | sed ':a;N;$!ba;s/\n/%0A/g' )" - name: Create Release diff --git a/.github/workflows/publishdocker-branch.yml b/.github/workflows/publishdocker-branch.yml deleted file mode 100644 index b8a6b336..00000000 --- a/.github/workflows/publishdocker-branch.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Publish Docker Branch -on: - push: - branches: [master, beta, nightly] -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout Code - uses: actions/checkout@master - - name: Get Branch - run: echo ::set-env name=BRANCH::${GITHUB_REF#refs/heads/} - - name: Publish to Registry - uses: elgohr/Publish-Docker-Github-Action@master - env: - VERSION: ${{ github.sha }} - with: - name: tautulli/tautulli - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - dockerfile: Dockerfile - buildargs: VERSION, BRANCH - - name: Post Status to Discord - uses: sarisia/actions-status-discord@v1 - if: always() - with: - webhook: ${{ secrets.DISCORD_WEBHOOK }} - status: ${{ job.status }} - job: ${{ github.workflow }} - nofail: true diff --git a/.github/workflows/publishdocker-release.yml b/.github/workflows/publishdocker-release.yml deleted file mode 100644 index 96f5bb66..00000000 --- a/.github/workflows/publishdocker-release.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: Publish Docker Release -on: - push: - tags: - - 'v*' -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout Code - uses: actions/checkout@master - - name: Get Branch - run: echo ::set-env name=BRANCH::${GITHUB_REF/refs\/tags\//} - - name: Publish to Registry - uses: elgohr/Publish-Docker-Github-Action@master - env: - VERSION: ${{ github.sha }} - with: - name: tautulli/tautulli - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - dockerfile: Dockerfile - buildargs: VERSION, BRANCH - tags: ${{ env.BRANCH }} - - name: Post Status to Discord - uses: sarisia/actions-status-discord@v1 - if: always() - with: - webhook: ${{ secrets.DISCORD_WEBHOOK }} - status: ${{ job.status }} - job: ${{ github.workflow }} - nofail: true diff --git a/Dockerfile b/Dockerfile index 5efa135a..0467f616 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ -FROM python:2.7.17-slim +FROM tautulli/tautulli-baseimage:latest -LABEL maintainer="TheMeanCanEHdian" +LABEL maintainer="Tautulli" ARG VERSION ARG BRANCH @@ -11,16 +11,8 @@ ENV TZ=UTC WORKDIR /app RUN \ -apt-get -q -y update --no-install-recommends && \ -apt-get install -q -y --no-install-recommends \ - curl && \ -rm -rf /var/lib/apt/lists/* && \ -pip install --no-cache-dir --upgrade pip && \ -pip install --no-cache-dir --upgrade \ - pycryptodomex \ - pyopenssl && \ -echo ${VERSION} > /app/version.txt && \ -echo ${BRANCH} > /app/branch.txt + echo ${VERSION} > /app/version.txt && \ + echo ${BRANCH} > /app/branch.txt COPY . /app