fix: use python:3.12-alpine3.21 from Docker Hub, rewrite run.sh without bashio
Some checks failed
Deploy to GitHub Pages / build (push) Has been cancelled
Deploy to GitHub Pages / deploy (push) Has been cancelled

This commit is contained in:
2026-03-07 12:08:34 +01:00
parent f94f6a686d
commit 218b3c4961
3 changed files with 26 additions and 31 deletions

View File

@@ -1,18 +1,18 @@
ARG BUILD_FROM
FROM $BUILD_FROM
# System libraries: BlueZ for BLE/RFCOMM + build tools for numpy & pillow
# BlueZ for BLE/RFCOMM + build tools for packages without binary wheels
RUN apk add --no-cache \
bash \
bluez \
dbus \
gcc \
musl-dev \
libjpeg-turbo-dev \
zlib-dev \
libffi-dev
zlib-dev
# Install Python runtime dependencies
RUN pip3 install --no-cache-dir --break-system-packages \
RUN pip install --no-cache-dir \
"bleak>=0.21" \
"numpy" \
"pillow" \
@@ -21,7 +21,7 @@ RUN pip3 install --no-cache-dir --break-system-packages \
"python-multipart>=0.0.9"
# Remove build-only packages to keep the image slim
RUN apk del gcc musl-dev libffi-dev
RUN apk del gcc musl-dev
# Copy the fichero Python package into the container
WORKDIR /app

View File

@@ -1,6 +1,6 @@
build_from:
aarch64: "ghcr.io/home-assistant/aarch64-base-python:3.12"
amd64: "ghcr.io/home-assistant/amd64-base-python:3.12"
armhf: "ghcr.io/home-assistant/armhf-base-python:3.12"
armv7: "ghcr.io/home-assistant/armv7-base-python:3.12"
i386: "ghcr.io/home-assistant/i386-base-python:3.12"
aarch64: "python:3.12-alpine3.21"
amd64: "python:3.12-alpine3.21"
armhf: "python:3.12-alpine3.21"
armv7: "python:3.12-alpine3.21"
i386: "python:3.12-alpine3.21"

View File

@@ -1,29 +1,24 @@
#!/usr/bin/with-contenv bashio
# shellcheck shell=bash
#!/bin/sh
# shellcheck shell=sh
set -e
declare port
declare ble_address
declare transport
declare channel
CONFIG_PATH="/data/options.json"
port=$(bashio::config 'port')
transport=$(bashio::config 'transport')
channel=$(bashio::config 'channel')
# Read add-on options from the HA-provided JSON file using Python (already installed).
PORT=$(python3 -c "import json; d=json.load(open('${CONFIG_PATH}')); print(d.get('port', 8765))")
TRANSPORT=$(python3 -c "import json; d=json.load(open('${CONFIG_PATH}')); print(d.get('transport', 'ble'))")
CHANNEL=$(python3 -c "import json; d=json.load(open('${CONFIG_PATH}')); print(d.get('channel', 1))")
BLE_ADDRESS=$(python3 -c "import json; d=json.load(open('${CONFIG_PATH}')); print(d.get('ble_address') or '')")
# Pass connection settings to the Python module via environment variables.
# The module reads these at import time, so they must be exported before uvicorn
# imports fichero.api.
export FICHERO_TRANSPORT="${transport}"
export FICHERO_CHANNEL="${channel}"
export FICHERO_TRANSPORT="${TRANSPORT}"
export FICHERO_CHANNEL="${CHANNEL}"
ble_address=$(bashio::config 'ble_address')
if [ -n "${ble_address}" ]; then
export FICHERO_ADDR="${ble_address}"
bashio::log.info "Using fixed Bluetooth address: ${ble_address}"
if [ -n "${BLE_ADDRESS}" ]; then
export FICHERO_ADDR="${BLE_ADDRESS}"
echo "[fichero] Using fixed Bluetooth address: ${BLE_ADDRESS}"
else
bashio::log.info "No address configured will auto-scan for printer on first request."
echo "[fichero] No address configured - will auto-scan for printer on first request."
fi
bashio::log.info "Starting Fichero Printer API on 0.0.0.0:${port} (transport: ${transport})..."
exec uvicorn fichero.api:app --host 0.0.0.0 --port "${port}"
echo "[fichero] Starting Fichero Printer API on 0.0.0.0:${PORT} (transport: ${TRANSPORT})..."
exec uvicorn fichero.api:app --host 0.0.0.0 --port "${PORT}"