feat: users, roles and per-area permissions, production demo image
The controller checks every route against the signed-in user's role, with levels none, view, control and edit per area. Guests get the permissions of a built-in guest role. Auth stays off until the first user exists; LED_ADMIN_USER and LED_ADMIN_PASSWORD create the first admin. Sessions are cookies, passwords are PBKDF2-SHA256, and logins lock per username after five failures. The simulator's WebSocket checks the view permission at handshake and per frame; /ws needs devices control. The web UI gets a sign-in button, a sign-in prompt on refused changes, and a users and roles screen. Also: the device build gets the bridge include path and forward type it was missing, Dockerfile.sim runs non-root, and Dockerfile.prod with docker-compose.prod.yml runs the controller on an internal network behind Caddy for HTTPS. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
02440be55d
commit
f0615dc1b7
26 files changed
+2116
-23
No files matched your search
@@ -0,0 +1,28 @@
|
||||
# Production image of the controller demo: ESP-IDF's linux target running the simulated rig. No hardware.
|
||||
# The web UI is embedded in the binary (main/CMakeLists.txt packs www_dist/www.pack), so no Node is needed.
|
||||
# Build from the repo root: docker build -f Dockerfile.prod -t led-controller:prod .
|
||||
# Run with the compose file: docker compose -f docker-compose.prod.yml up -d (see .env.prod.example)
|
||||
|
||||
FROM espressif/idf:v6.1 AS build
|
||||
WORKDIR /project
|
||||
COPY . .
|
||||
RUN bash -c ". /opt/esp/idf/export.sh && cd sim-controller && idf.py build"
|
||||
|
||||
FROM debian:trixie-slim
|
||||
# The two shared libraries the binary needs, taken from the build image
|
||||
COPY --from=build /usr/lib/x86_64-linux-gnu/libbsd.so.0.12.1 /usr/lib/x86_64-linux-gnu/libbsd.so.0
|
||||
COPY --from=build /usr/lib/x86_64-linux-gnu/libmd.so.0.1.0 /usr/lib/x86_64-linux-gnu/libmd.so.0
|
||||
COPY --from=build /project/sim-controller/build/led_controller_sim.elf /usr/local/bin/led_controller_sim
|
||||
RUN useradd --system --uid 10001 --no-create-home --shell /usr/sbin/nologin led \
|
||||
&& mkdir /data && chown led:led /data
|
||||
ENV LED_SIM_DB=/data \
|
||||
LED_SIM_HTTP_PORT=8080 \
|
||||
LED_SIM_BRIDGE=127.0.0.1:8766
|
||||
USER led
|
||||
VOLUME ["/data"]
|
||||
EXPOSE 8080
|
||||
# Bash's /dev/tcp needs no extra packages: healthy when /status answers 200
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
|
||||
CMD bash -c 'exec 3<>/dev/tcp/127.0.0.1/8080 && printf "GET /status HTTP/1.0\r\n\r\n" >&3 && head -n1 <&3 | grep -q " 200"'
|
||||
STOPSIGNAL SIGTERM
|
||||
ENTRYPOINT ["/usr/local/bin/led_controller_sim"]
|
||||
Reference in new issue
Block a user