feat: Docker packaging and README
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
1 parent
0a395fa735
commit
ae8c17d8d5
3 files changed
+132
No files matched your search
+24
@@ -0,0 +1,24 @@
|
||||
FROM python:3.12-slim
|
||||
|
||||
# Pinned commit of the Turing Smart Screen library (we only need library/).
|
||||
ARG LCD_COMMIT=2b33ab4f00a096916dd6a1174441a53a7ec33b03
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY requirements.txt .
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
ADD https://github.com/mathoudebine/turing-smart-screen-python/archive/${LCD_COMMIT}.tar.gz /tmp/lcd.tar.gz
|
||||
RUN mkdir -p /opt/lcd \
|
||||
&& tar -xzf /tmp/lcd.tar.gz -C /opt/lcd --strip-components=1 --wildcards '*/library' \
|
||||
&& rm /tmp/lcd.tar.gz
|
||||
|
||||
ENV LCD_LIB_PATH=/opt/lcd \
|
||||
PYTHONUNBUFFERED=1 \
|
||||
TZ=Europe/Prague
|
||||
|
||||
COPY assets ./assets
|
||||
COPY lcdkit.py poller.py view.py timeutil.py weather_data.py weather_view.py stats_data.py server_view.py \
|
||||
registry.py runner.py main.py ./
|
||||
|
||||
CMD ["python", "main.py"]
|
||||
@@ -0,0 +1,85 @@
|
||||
# second-screen
|
||||
|
||||
A second 3.5" Turing Smart Screen (Rev A) on the Coolify home server, next to the bus board
|
||||
(`bus-department-schedule`). One Docker container shows **one view at a time**, drawn in the style of a
|
||||
Casio digital watch (slanted 7-segment digits, pale LCD green):
|
||||
|
||||
| `VIEW` | Shows |
|
||||
|---|---|
|
||||
| `weather` | Czech weekday strip, big `HH:MM` with seconds, date, current weather for Zlín, today's max/min, highest rain chance and a 12-hour rain probability bar graph with the total mm |
|
||||
| `server` | CPU / RAM / disk bars, load, CPU temperature, uptime, Docker containers (readable names and status) and the busiest processes |
|
||||
|
||||
Design: `docs/superpowers/specs/2026-10-22-second-screen-design.md`.
|
||||
Plan: `docs/superpowers/plans/2026-10-22-second-screen.md`. Previews: `docs/previews/`.
|
||||
|
||||
## Switching views
|
||||
|
||||
Edit `VIEW:` in `docker-compose.yml`, commit, `git push`, press **Deploy** in Coolify. An unknown or missing
|
||||
`VIEW` shows an error screen naming the valid views and keeps the container idle (no restart loop).
|
||||
|
||||
## Add a view
|
||||
|
||||
1. Write a module with a class that follows the `View` protocol in `view.py` (`start`, `stop`, `frame_key`,
|
||||
`render`, `patch`). Put anything slow (network, system reads) in a `Poller` so drawing never blocks.
|
||||
2. Add one entry to `REGISTRY` in `registry.py`.
|
||||
3. Add a line to the table above, a sample to `preview.py`, and tests.
|
||||
|
||||
## Develop (no screen needed)
|
||||
|
||||
python3 -m venv .venv && .venv/bin/pip install -r requirements-dev.txt
|
||||
.venv/bin/pytest
|
||||
.venv/bin/python preview.py # writes docs/previews/weather.png and server.png
|
||||
|
||||
## Deployment (Coolify)
|
||||
|
||||
- Source: **Public Repository** on Gitea, branch `main`. The repo must stay public: Gitea SSH is disabled,
|
||||
so Coolify cannot use a deploy key.
|
||||
- Build pack **Docker Compose**, base directory `/`, **Docker Compose Location `/docker-compose.yml`**.
|
||||
- No domain and no environment variables: the defaults in `docker-compose.yml` fit this server.
|
||||
- **Update:** commit, `git push`, press **Deploy** (no webhook).
|
||||
- **Logs:** Coolify → the application → Logs, or `ssh coolify 'docker logs --tail 30 <container>'`.
|
||||
- Only one container can hold a screen's serial port. Stop manual copies before deploying.
|
||||
|
||||
### Security note
|
||||
|
||||
The container mounts the Docker socket. Even with `:ro` that gives it full control of Docker on the server
|
||||
(including Coolify, the bus board and everything else), because the API is not read-only. It also mounts the
|
||||
host's `/proc` and `/sys` read-only. This was accepted for this LAN-only home server (owner approved the
|
||||
socket on 2026-10-22). Remove the socket mount and the container list disappears (`NO DOCKER`), everything
|
||||
else keeps working.
|
||||
|
||||
### Running by hand on the server (debugging only)
|
||||
|
||||
ls -l /dev/serial/by-id/
|
||||
docker compose up --build -d
|
||||
docker compose logs -f second-screen
|
||||
|
||||
## If something is wrong
|
||||
|
||||
- **Upside-down:** this screen is mounted the opposite way to the bus board. Set `SCREEN_ORIENTATION` to
|
||||
`REVERSE_LANDSCAPE`.
|
||||
- **Blank screen:** `docker compose logs second-screen`. If it says the screen is not available it retries every 30 s;
|
||||
check the cable and `ls -l /dev/serial/by-id/`. ModemManager can interfere (`systemctl status ModemManager`).
|
||||
- **`STARÉ` tag:** the data is old (weather older than 1 h, server stats older than 30 s). The clock keeps running.
|
||||
- **Error screen at startup:** `VIEW` is not one of the valid views.
|
||||
|
||||
## Config (env vars)
|
||||
|
||||
| Variable | Default | |
|
||||
|---|---|---|
|
||||
| `VIEW` | none (must be set) | `weather` or `server` |
|
||||
| `SCREEN_DEVICE` | `/dev/serial/by-id/usb-Turing_UsbMonitor_USB35INCHIPSV2-if00` | serial device, also passed into the container |
|
||||
| `SCREEN_ORIENTATION` | `LANDSCAPE` | `REVERSE_LANDSCAPE` flips it |
|
||||
| `SCREEN_BRIGHTNESS` | `50` | 0–100 |
|
||||
| `BOARD_TZ` | `Europe/Prague` | time zone of the clock |
|
||||
| `LCD_LIB_PATH` | `/opt/lcd` | where the pinned screen library lives in the image |
|
||||
|
||||
The screen library is pinned to one upstream commit in the `Dockerfile` (`LCD_COMMIT`), the same as the bus board.
|
||||
|
||||
## Known limitations
|
||||
|
||||
- Weather comes from Open-Meteo for Zlín only (coordinates in `weather_data.py`), refreshed every 15 minutes.
|
||||
- The weather graph is the next 12 hours from now, so late in the day it runs into tomorrow.
|
||||
- Server stats: process CPU is a share of the whole machine and grouped by command name; temperature is the CPU
|
||||
package sensor if the host has one, else the hottest thermal zone.
|
||||
- Seconds are redrawn once per second with a small partial update.
|
||||
@@ -0,0 +1,23 @@
|
||||
services:
|
||||
second-screen:
|
||||
build: .
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
# Which view to show: weather | server. To switch: edit, commit, push, press Deploy in Coolify.
|
||||
VIEW: weather
|
||||
# Prefer the stable by-id path (see README); /dev/ttyACM1 can change after replug/reboot.
|
||||
SCREEN_DEVICE: ${SCREEN_DEVICE:-/dev/serial/by-id/usb-Turing_UsbMonitor_USB35INCHIPSV2-if00}
|
||||
SCREEN_ORIENTATION: LANDSCAPE
|
||||
SCREEN_BRIGHTNESS: "50"
|
||||
TZ: Europe/Prague
|
||||
BOARD_TZ: Europe/Prague
|
||||
devices:
|
||||
- "${SCREEN_DEVICE:-/dev/serial/by-id/usb-Turing_UsbMonitor_USB35INCHIPSV2-if00}:${SCREEN_DEVICE:-/dev/serial/by-id/usb-Turing_UsbMonitor_USB35INCHIPSV2-if00}"
|
||||
volumes:
|
||||
# Read-only host views for the server stats view.
|
||||
- /proc:/host/proc:ro
|
||||
- /sys:/host/sys:ro
|
||||
# Any file on the host's root filesystem: only used to measure disk usage (statvfs), contents never read.
|
||||
- /etc/hostname:/host/root:ro
|
||||
# Container list. Read-only does not limit the Docker API: this is full control of Docker (see README).
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
Reference in new issue
Block a user