You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(bridge): run with the socket group and report Docker failures - #9
The bridge ran as node with a group ID that scripts/venue.sh read on the host, which is not necessarily the group the socket has inside the container. When Docker access failed, power and network buttons failed without a clear reason on the page. The scenario buttons could also be pressed with an empty barcode, and the lane did not show whether the cable was plugged in.
What changed
Add scripts/bridge-entrypoint.sh as the image ENTRYPOINT. It checks that the socket exists, reads its group with stat -c %g, and starts the server through setpriv --reuid=node --regid=node --groups=<gid>. Remove USER node from the Dockerfile, group_add from compose.devices.yaml, and the host-side DOCKER_GID lookup from scripts/venue.sh. venue.sh also stops overriding DOCKER_CONFIG and DOCKER_HOST, so the host's Docker CLI settings apply.
bridge/src/docker.ts: errors read Docker API <status>: <message>, and socketHealth() pings /_ping.
bridge/src/server.ts: check the socket at startup, include docker in every snapshot, return 503 from /health while Docker is not accessible, log successful actions as action events, and log failures to the console and the event list as well as sending them to the browser.
web/src/main.tsx: show Network cable plugged|unplugged in each lane and the Docker socket message in the header; disable Two gates at once, All gates at once, Scan again and Start burst until the scenario barcode is filled; a ticket button also fills that field.
Tests: reports Docker API status and message from an inaccessible socket in bridge/test/docker.test.ts, the cable label in web/test/lane.test.tsx, and the cable label and the disabled scenario button in e2e/entrance.spec.ts.
web/src/main.tsx:每条通道显示 Network cable plugged|unplugged,页头显示 Docker socket 状态信息;场景条码为空时禁用 Two gates at once、All gates at once、Scan again 和 Start burst;点击票据按钮时也会填入该输入框。
测试:bridge/test/docker.test.ts 新增 reports Docker API status and message from an inaccessible socket;web/test/lane.test.tsx 检查网线标签;e2e/entrance.spec.ts 检查网线标签和被禁用的场景按钮。
Yes. The entrypoint only checks the socket and reads its group, then execs the server through setpriv as node with that supplementary group. The Node process never runs as root.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The bridge ran as
nodewith a group ID thatscripts/venue.shread on the host, which is not necessarily the group the socket has inside the container. When Docker access failed, power and network buttons failed without a clear reason on the page. The scenario buttons could also be pressed with an empty barcode, and the lane did not show whether the cable was plugged in.What changed
scripts/bridge-entrypoint.shas the imageENTRYPOINT. It checks that the socket exists, reads its group withstat -c %g, and starts the server throughsetpriv --reuid=node --regid=node --groups=<gid>. RemoveUSER nodefrom theDockerfile,group_addfromcompose.devices.yaml, and the host-sideDOCKER_GIDlookup fromscripts/venue.sh.venue.shalso stops overridingDOCKER_CONFIGandDOCKER_HOST, so the host's Docker CLI settings apply.bridge/src/docker.ts: errors readDocker API <status>: <message>, andsocketHealth()pings/_ping.bridge/src/server.ts: check the socket at startup, includedockerin every snapshot, return 503 from/healthwhile Docker is not accessible, log successful actions asactionevents, and log failures to the console and the event list as well as sending them to the browser.web/src/main.tsx: showNetwork cable plugged|unpluggedin each lane and the Docker socket message in the header; disableTwo gates at once,All gates at once,Scan againandStart burstuntil the scenario barcode is filled; a ticket button also fills that field.reports Docker API status and message from an inaccessible socketinbridge/test/docker.test.ts, the cable label inweb/test/lane.test.tsx, and the cable label and the disabled scenario button ine2e/entrance.spec.ts.How to verify
/healthanswers 200 when the bridge can reach the Docker socket and 503 with the error message when it cannot.背景
bridge 以
node用户运行,所用的组 ID 由scripts/venue.sh在主机上读取,而这不一定是 socket 在容器内的组。Docker 访问失败时,电源和网络按钮会失败,页面上却看不出原因。另外,场景按钮在条码为空时也能点,通道上也看不出网线是否插着。改动
scripts/bridge-entrypoint.sh作为镜像的ENTRYPOINT:确认 socket 存在,用stat -c %g读取它的组,再通过setpriv --reuid=node --regid=node --groups=<gid>启动服务。相应地删除Dockerfile中的USER node、compose.devices.yaml中的group_add,以及scripts/venue.sh在主机上查询DOCKER_GID的代码。venue.sh也不再覆盖DOCKER_CONFIG和DOCKER_HOST,直接沿用主机上的 Docker CLI 设置。bridge/src/docker.ts:错误信息改为Docker API <status>: <message>,新增socketHealth(),通过/_ping检查连通性。bridge/src/server.ts:启动时检查 socket,每份快照都带上docker状态;Docker 不可用时/health返回 503;操作成功记为action事件;失败时除了发给浏览器,还会写入控制台和事件列表。web/src/main.tsx:每条通道显示Network cable plugged|unplugged,页头显示 Docker socket 状态信息;场景条码为空时禁用Two gates at once、All gates at once、Scan again和Start burst;点击票据按钮时也会填入该输入框。bridge/test/docker.test.ts新增reports Docker API status and message from an inaccessible socket;web/test/lane.test.tsx检查网线标签;e2e/entrance.spec.ts检查网线标签和被禁用的场景按钮。怎么验证
bridge 能访问 Docker socket 时
/health返回 200,不能访问时返回 503 并附带错误信息。