diff --git a/.gitignore b/.gitignore index 63e92ba9..9f036102 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ dist/ songs/ qrcode.png .DS_Store +docker-compose.yml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..e483e038 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +# Use bullseye over bookworm for better image size and ffmpeg compatibility +FROM python:3.12-slim-bullseye + +# Install required packages +RUN apt-get update --allow-releaseinfo-change +RUN apt-get install ffmpeg wireless-tools -y + +WORKDIR /app + +# Copy minimum required files into the image +COPY pyproject.toml ./ +COPY pikaraoke ./pikaraoke +COPY docs ./docs + +# Install pikaraoke +RUN pip install . + +COPY docker/entrypoint.sh ./ +RUN chmod +x entrypoint.sh + +ENTRYPOINT ["./entrypoint.sh"] diff --git a/docker/docker-compose.yml.example b/docker/docker-compose.yml.example new file mode 100644 index 00000000..05e8e626 --- /dev/null +++ b/docker/docker-compose.yml.example @@ -0,0 +1,14 @@ +services: + pikaraoke: + image: pikaraoke:latest + container_name: PiKaraoke + # Below Host network mode may work better on some systems and replace manual IP configuration. Does not work on OSX + # network_mode: host + environment: + EXTRA_ARGS: --url http://:5555 # Replace with your LAN IP or DNS url, not necesary if using network_mode: host + volumes: + - :/app/pikaraoke-songs # Replace with local dir. Insures your songs are persisted outside the container + restart: unless-stopped + ports: + - "5555:5555" # Forward the port for the web interface + - "5556:5556" # Forward the port for the ffmpeg video stream interface diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh new file mode 100755 index 00000000..287b403f --- /dev/null +++ b/docker/entrypoint.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +# Run pikaraoke with necessary parameters +pikaraoke -d /app/pikaraoke-songs/ --headless $EXTRA_ARGS + +# Keep the container running +tail -f /dev/null diff --git a/pikaraoke/lib/get_platform.py b/pikaraoke/lib/get_platform.py index d7057314..6e1ad1d7 100644 --- a/pikaraoke/lib/get_platform.py +++ b/pikaraoke/lib/get_platform.py @@ -1,3 +1,4 @@ +import io import os import platform import re @@ -35,13 +36,12 @@ def is_transpose_enabled(): def is_raspberry_pi(): try: - return ( - (os.uname()[4][:3] == "arm" or os.uname()[4] == "aarch64") - and sys.platform != "darwin" - and not is_android() - ) - except AttributeError: - return False + with io.open("/sys/firmware/devicetree/base/model", "r") as m: + if "raspberry pi" in m.read().lower(): + return True + except Exception: + pass + return False def is_android():