diff --git a/.github/workflows/base-image.yml b/.github/workflows/base-image.yml new file mode 100644 index 000000000..e02051107 --- /dev/null +++ b/.github/workflows/base-image.yml @@ -0,0 +1,74 @@ +name: Base Image Build + +on: + push: + branches: [ main, dev ] + paths: + - 'docker/DispatcharrBase' + pull_request: + branches: [ main, dev ] + paths: + - 'docker/DispatcharrBase' + workflow_dispatch: # Allow manual triggering + +permissions: + contents: write # For managing releases and pushing tags + packages: write # For publishing to GitHub Container Registry + +jobs: + build-base-image: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Generate timestamp for build + id: timestamp + run: | + TIMESTAMP=$(date -u +'%Y%m%d%H%M%S') + echo "timestamp=${TIMESTAMP}" >> $GITHUB_OUTPUT + + - name: Set repository and image metadata + id: meta + run: | + # Get lowercase repository owner + REPO_OWNER=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]') + echo "repo_owner=${REPO_OWNER}" >> $GITHUB_OUTPUT + + # Get repository name + REPO_NAME=$(echo "${{ github.repository }}" | cut -d '/' -f 2 | tr '[:upper:]' '[:lower:]') + echo "repo_name=${REPO_NAME}" >> $GITHUB_OUTPUT + + # Determine branch name + if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then + echo "branch_tag=base" >> $GITHUB_OUTPUT + elif [[ "${{ github.ref }}" == "refs/heads/dev" ]]; then + echo "branch_tag=base-dev" >> $GITHUB_OUTPUT + else + # For other branches, use the branch name + BRANCH=$(echo "${{ github.ref }}" | sed 's/refs\/heads\///' | sed 's/[^a-zA-Z0-9]/-/g') + echo "branch_tag=base-${BRANCH}" >> $GITHUB_OUTPUT + fi + + - name: Build and push Docker base image + uses: docker/build-push-action@v4 + with: + context: . + file: ./docker/DispatcharrBase + push: ${{ github.event_name != 'pull_request' }} + platforms: linux/amd64,linux/arm64 + tags: | + ghcr.io/${{ steps.meta.outputs.repo_owner }}/${{ steps.meta.outputs.repo_name }}:base + ghcr.io/${{ steps.meta.outputs.repo_owner }}/${{ steps.meta.outputs.repo_name }}:base-${{ steps.timestamp.outputs.timestamp }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1418cbf56..ee26ac3fb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -100,6 +100,8 @@ jobs: ghcr.io/${{ steps.meta.outputs.repo_owner }}/${{ steps.meta.outputs.repo_name }}:${{ steps.version.outputs.version }}-${{ steps.timestamp.outputs.timestamp }} ghcr.io/${{ steps.meta.outputs.repo_owner }}/${{ steps.meta.outputs.repo_name }}:${{ steps.version.outputs.sha_short }} build-args: | + REPO_OWNER=${{ steps.meta.outputs.repo_owner }} + REPO_NAME=${{ steps.meta.outputs.repo_name }} BRANCH=${{ github.ref_name }} REPO_URL=https://github.com/${{ github.repository }} TIMESTAMP=${{ steps.timestamp.outputs.timestamp }} diff --git a/docker/DispatcharrBase b/docker/DispatcharrBase index 0cfaf44e2..587417153 100644 --- a/docker/DispatcharrBase +++ b/docker/DispatcharrBase @@ -1,25 +1,21 @@ -# --- Stage 1: Get FFmpeg from lscr.io --- -FROM lscr.io/linuxserver/ffmpeg:latest AS ffmpeg +FROM lscr.io/linuxserver/ffmpeg:latest ENV DEBIAN_FRONTEND=noninteractive ENV VIRTUAL_ENV=/dispatcharrpy ENV PATH="$VIRTUAL_ENV/bin:$PATH" -# --- Install system-level base dependencies --- -RUN apt-get update && apt-get install -y \ - software-properties-common \ - && add-apt-repository -y ppa:deadsnakes/ppa - - -RUN apt-get install -y \ - curl wget gnupg2 ca-certificates lsb-release build-essential \ - gcc libpcre3 libpcre3-dev libpq-dev procps streamlink \ - libva-drm2 libva-x11-2 libva-dev libva-wayland2 \ - i965-va-driver intel-media-va-driver mesa-va-drivers \ - python3.13 python3.13-dev python3.13-venv python3-pip \ - libstdc++6 libglib2.0-0 libgomp1 libvdpau1 libva2 \ - libxcb-shape0 libv4l-0 ocl-icd-libopencl1 \ - alsa-base libasound2t64 nginx \ +# --- Install Python 3.13 and system dependencies --- +# Note: Hardware acceleration (VA-API, VDPAU, NVENC) already included in base ffmpeg image +RUN apt-get update && apt-get install --no-install-recommends -y \ + ca-certificates software-properties-common gnupg2 curl wget \ + && add-apt-repository ppa:deadsnakes/ppa \ + && apt-get update \ + && apt-get install --no-install-recommends -y \ + python3.13 python3.13-dev python3.13-venv \ + python-is-python3 python3-pip \ + libpcre3 libpcre3-dev libpq-dev procps \ + build-essential gcc \ + nginx streamlink \ && apt-get clean && rm -rf /var/lib/apt/lists/* # --- Create Python virtual environment --- diff --git a/docker/Dockerfile b/docker/Dockerfile index 38ed5c259..ab7ea6854 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -6,8 +6,13 @@ RUN corepack enable && corepack prepare yarn@stable --activate && \ yarn install && yarn build && \ rm -rf node_modules .cache -# --- Final image based on the base --- -FROM sergeantpanda/dispatcharr:base AS final +# --- Define base image build arguments --- +ARG REPO_OWNER=dispatcharr +ARG REPO_NAME=dispatcharr +ARG BASE_TAG=base + +# --- Final image based on the dynamic base --- +FROM ghcr.io/${REPO_OWNER}/${REPO_NAME}:${BASE_TAG} AS final ENV VIRTUAL_ENV=/dispatcharrpy ENV PATH="$VIRTUAL_ENV/bin:$PATH" WORKDIR /app