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 ARG BUILD_FROM
FROM $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 \ RUN apk add --no-cache \
bash \
bluez \ bluez \
dbus \ dbus \
gcc \ gcc \
musl-dev \ musl-dev \
libjpeg-turbo-dev \ libjpeg-turbo-dev \
zlib-dev \ zlib-dev
libffi-dev
# Install Python runtime dependencies # Install Python runtime dependencies
RUN pip3 install --no-cache-dir --break-system-packages \ RUN pip install --no-cache-dir \
"bleak>=0.21" \ "bleak>=0.21" \
"numpy" \ "numpy" \
"pillow" \ "pillow" \
@@ -21,7 +21,7 @@ RUN pip3 install --no-cache-dir --break-system-packages \
"python-multipart>=0.0.9" "python-multipart>=0.0.9"
# Remove build-only packages to keep the image slim # 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 # Copy the fichero Python package into the container
WORKDIR /app WORKDIR /app

View File

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

View File

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