Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 70 additions & 22 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,21 @@ on:
branches:
- main
- dev
repository_dispatch:
types:
- rebuild-from-core
workflow_dispatch:
inputs:
image_repository:
description: "Docker image repository to publish to"
required: false
default: "pymcdev/pymc-repeater"
default: ""

jobs:
docker:
if: |
github.event_name == 'workflow_dispatch' ||
github.event_name == 'repository_dispatch' ||
github.repository == 'pyMC-dev/pyMC_Repeater' ||
github.repository == 'yellowcooln/pyMC_Repeater'
runs-on: ubuntu-latest
Expand All @@ -27,6 +31,7 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.channel || github.ref_name }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
Expand All @@ -39,6 +44,58 @@ jobs:
with:
python-version: "3.12"

- name: Determine build context
id: context
shell: bash
env:
INPUT_IMAGE_REPOSITORY: ${{ inputs.image_repository }}
PAYLOAD_CHANNEL: ${{ github.event.client_payload.channel }}
PAYLOAD_CORE_REF: ${{ github.event.client_payload.core_ref }}
PAYLOAD_CORE_SHA: ${{ github.event.client_payload.core_sha }}
run: |
set -euo pipefail

channel="${PAYLOAD_CHANNEL:-${GITHUB_REF_NAME}}"
case "${channel}" in
main|dev) ;;
*)
echo "Unsupported repeater channel: ${channel}" >&2
exit 1
;;
esac

core_ref="${PAYLOAD_CORE_REF:-${channel}}"
if [ -n "${PAYLOAD_CORE_SHA}" ]; then
core_sha="${PAYLOAD_CORE_SHA}"
else
core_sha="$(git ls-remote https://github.com/pyMC-dev/pyMC_core.git "refs/heads/${core_ref}" | cut -f1)"
fi

if [ -z "${core_sha}" ]; then
echo "Failed to resolve pyMC_core ref ${core_ref}" >&2
exit 1
fi

if [ -n "${INPUT_IMAGE_REPOSITORY}" ]; then
image_repository="${INPUT_IMAGE_REPOSITORY}"
elif [ "${{ github.repository }}" = "yellowcooln/pyMC_Repeater" ]; then
image_repository="yellowcooln/pymc-repeater"
else
image_repository="pymcdev/pymc-repeater"
fi

repeater_sha="$(git rev-parse HEAD)"
repeater_short_sha="$(git rev-parse --short=7 HEAD)"

echo "Using image repository: ${image_repository}"
echo "Building repeater ${channel} against pyMC_core ${core_ref} @ ${core_sha}"
echo "channel=${channel}" >> "$GITHUB_OUTPUT"
echo "core_ref=${core_ref}" >> "$GITHUB_OUTPUT"
echo "core_sha=${core_sha}" >> "$GITHUB_OUTPUT"
echo "image_repository=${image_repository}" >> "$GITHUB_OUTPUT"
echo "repeater_sha=${repeater_sha}" >> "$GITHUB_OUTPUT"
echo "repeater_short_sha=${repeater_short_sha}" >> "$GITHUB_OUTPUT"

- name: Compute package version
id: package_version
run: |
Expand All @@ -52,30 +109,19 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Determine image repository
id: image_repo
shell: bash
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ -n "${{ inputs.image_repository }}" ]; then
image_repository="${{ inputs.image_repository }}"
elif [ "${{ github.repository }}" = "yellowcooln/pyMC_Repeater" ]; then
image_repository="yellowcooln/pymc-repeater"
else
image_repository="pymcdev/pymc-repeater"
fi

echo "Using image repository: ${image_repository}"
echo "image_repository=${image_repository}" >> "$GITHUB_OUTPUT"

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ steps.image_repo.outputs.image_repository }}
images: ${{ steps.context.outputs.image_repository }}
tags: |
type=raw,value=main,enable=${{ github.ref == 'refs/heads/main' }}
type=raw,value=dev,enable=${{ github.ref == 'refs/heads/dev' }}
type=sha,format=short
type=raw,value=${{ steps.context.outputs.channel }}
type=raw,value=sha-${{ steps.context.outputs.repeater_short_sha }}
labels: |
org.opencontainers.image.revision=${{ steps.context.outputs.repeater_sha }}
io.pymc.repeater.channel=${{ steps.context.outputs.channel }}
io.pymc.core.ref=${{ steps.context.outputs.core_ref }}
io.pymc.core.sha=${{ steps.context.outputs.core_sha }}

- name: Build and push
uses: docker/build-push-action@v6
Expand All @@ -86,6 +132,8 @@ jobs:
push: true
build-args: |
PACKAGE_VERSION=${{ steps.package_version.outputs.version }}
PYMC_CORE_REF=${{ steps.context.outputs.core_ref }}
PYMC_CORE_SHA=${{ steps.context.outputs.core_sha }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
Expand All @@ -95,8 +143,8 @@ jobs:
if: github.repository == 'pyMC-dev/pyMC_Repeater'
env:
DISPATCH_TOKEN: ${{ secrets.HA_ADDON_REPO_DISPATCH_TOKEN }}
CHANNEL: ${{ github.ref_name }}
REVISION: ${{ github.sha }}
CHANNEL: ${{ steps.context.outputs.channel }}
REVISION: ${{ steps.context.outputs.repeater_sha }}
run: |
if [ -z "${DISPATCH_TOKEN}" ]; then
echo "HA_ADDON_REPO_DISPATCH_TOKEN is not set" >&2
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -365,10 +365,13 @@ sudo bash ./setup-radio-config.sh

4. Configure the [docker compose](./docker-compose.yml) to your specific hardware and file paths. Be sure to comment-out or delete lines that aren't required for your hardware. Please note that your hardware devices might be at a different path than those listed in the docker compose file.

5. Build and start the container.
5. Pull and start the container. The example compose file defaults to
`pymcdev/pymc-repeater:dev`. Override `PYMC_REPEATER_IMAGE` if you want a
different channel or a fork image.

```bash
docker compose up -d --force-recreate --build
docker compose pull
docker compose up -d --force-recreate
```

## Roadmap / Planned Features
Expand Down
10 changes: 5 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
services:
pymc-repeater:
build:
context: .
args:
PUID: ${PUID:-1000}
PGID: ${PGID:-1000}
image: ${PYMC_REPEATER_IMAGE:-pymcdev/pymc-repeater:dev}
pull_policy: always
container_name: pymc-repeater
restart: unless-stopped
environment:
PUID: ${PUID:-1000}
PGID: ${PGID:-1000}
ports:
- 8000:8000
devices:
Expand Down
10 changes: 8 additions & 2 deletions dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ ARG USER=repeater
ARG GROUP=repeater
ARG PUID=15888
ARG PGID=15888
ARG PYMC_CORE_REF=dev
ARG PYMC_CORE_SHA
ARG TARGETARCH
ARG YQ_VERSION=v4.40.5

Expand Down Expand Up @@ -63,8 +65,12 @@ COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
# Switch to the unprivileged runtime user
USER ${USER}

# Install package
RUN pip install --no-cache-dir .
# Install the matching pyMC_core ref by resolved commit SHA, then install repeater
# without re-resolving dependencies back to a cached branch tip.
RUN test -n "${PYMC_CORE_SHA}" \
&& echo "Installing pyMC_core ${PYMC_CORE_REF} @ ${PYMC_CORE_SHA}" \
&& pip install --no-cache-dir "pymc_core[hardware] @ git+https://github.com/pyMC-dev/pyMC_core.git@${PYMC_CORE_SHA}" \
&& pip install --no-cache-dir --no-deps .

USER root

Expand Down