Skip to content

Commit 23fa410

Browse files
committed
fix(docker): working compose healthchecks and default-scope demo alignment
- install busybox applet links as root in the server image: distroless USER nonroot cannot write /bin, so the previous --install silently failed and CMD-SHELL healthchecks could never resolve sh/wget - add server/agent/dashboard healthchecks to deploy and dev compose with depends_on service_healthy gates, and make the self-hosted deploy wait for health - align bundled agent config and SDK example images to the bootstrap scope (game default, env dev): demo-game/development does not exist on fresh installs, which made the SDK demos register into an invalid scope (verified while running the J-001.03 clean deploy acceptance) - build the dashboard image from repo context with docker/Dockerfile.web in CI (matches the deploy compose build) and bump node24/pnpm11
1 parent d966e46 commit 23fa410

9 files changed

Lines changed: 142 additions & 65 deletions

File tree

.github/workflows/ci-dashboard.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,8 @@ jobs:
316316
timeout-minutes: 15
317317
uses: docker/build-push-action@v7
318318
with:
319-
context: ./web
320-
file: ./web/Dockerfile
319+
context: .
320+
file: ./docker/Dockerfile.web
321321
push: true
322322
tags: ${{ steps.meta.outputs.tags }}
323323
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/deploy-self-hosted.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ jobs:
101101
croupier-server \
102102
croupier-agent \
103103
croupier-dashboard \
104-
croupier-sdk-example-demo
104+
croupier-sdk-demo-go
105105
do
106106
if ! docker container inspect "${name}" >/dev/null 2>&1; then
107107
continue
@@ -121,9 +121,9 @@ jobs:
121121
run: |
122122
COMPOSE_ARGS=(--project-name "${CROUPIER_COMPOSE_PROJECT}" --env-file "${{ inputs.deploy_dir }}/.env" -f "${{ inputs.deploy_dir }}/docker-compose.yml")
123123
if [ "${{ inputs.enable_sdk_examples }}" = "true" ]; then
124-
docker compose "${COMPOSE_ARGS[@]}" --profile sdk-examples up -d --remove-orphans
124+
docker compose "${COMPOSE_ARGS[@]}" --profile sdk-examples up -d --wait --remove-orphans
125125
else
126-
docker compose "${COMPOSE_ARGS[@]}" up -d --remove-orphans
126+
docker compose "${COMPOSE_ARGS[@]}" up -d --wait --remove-orphans
127127
fi
128128
129129
- name: Show running services

docker/Dockerfile.server

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,13 @@ FROM ${RUNTIME_IMAGE}
2323
WORKDIR /app
2424
# busybox-static 提供最小 shell/网络工具(sh/cat/netstat/ps),便于容器运维排查;
2525
# 仍保持 distroless 基底,不引入包管理器。
26+
# busybox applet 符号链接必须以 root 安装:distroless 默认 USER nonroot,
27+
# 否则 --install 在 /bin 下静默失败(Permission denied),healthcheck 的
28+
# CMD-SHELL wget/sh 找不到可执行文件。
2629
COPY --from=busybox:1.37-uclibc /bin/busybox /bin/busybox
30+
USER root:root
2731
RUN ["/bin/busybox", "--install", "/bin"]
32+
USER nonroot:nonroot
2833
COPY --from=build /out/croupier-server /app/
2934
COPY --from=build --chown=nonroot:nonroot /src/configs /app/configs
3035
COPY --from=build --chown=nonroot:nonroot /out/data /app/data

docker/Dockerfile.web

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## Multi-stage build for the Dashboard UI (Umi Max)
22
# Global build args must be declared before any FROM
3-
ARG NODE_IMAGE=node:22-alpine
3+
ARG NODE_IMAGE=node:24-alpine
44
ARG NGINX_IMAGE=nginx:alpine
55

66
# Build stage
@@ -13,7 +13,7 @@ RUN if [ -n "$NPM_REGISTRY" ]; then npm config set registry "$NPM_REGISTRY"; fi
1313

1414
# Install deps (pnpm)
1515
COPY web/package.json web/pnpm-lock.yaml ./
16-
RUN corepack enable && corepack prepare pnpm@10.28.2 --activate && pnpm install --frozen-lockfile
16+
RUN corepack enable && corepack prepare pnpm@11.11.0 --activate && pnpm install --frozen-lockfile
1717

1818
# Build
1919
COPY web/ .

docker/configs/agent.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ server:
1111

1212
agent:
1313
id: "croupier-docker-agent"
14-
gameId: "demo-game"
15-
env: "development"
14+
gameId: "default"
15+
env: "dev"
1616
localAddr: "agent:19091"
1717
httpAddr: "agent:19091"
1818
labels: {}

docker/docker-compose.deploy.yml

Lines changed: 60 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ services:
1515
networks:
1616
- croupier-network
1717
healthcheck:
18-
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-croupier} -d ${POSTGRES_DB:-croupier}"]
18+
test:
19+
[
20+
"CMD-SHELL",
21+
"pg_isready -U ${POSTGRES_USER:-croupier} -d ${POSTGRES_DB:-croupier}",
22+
]
1923
interval: 10s
2024
timeout: 5s
2125
retries: 5
@@ -55,7 +59,11 @@ services:
5559
soft: 262144
5660
hard: 262144
5761
healthcheck:
58-
test: ["CMD-SHELL", "wget -qO- http://localhost:8123/?query=SELECT%201 || exit 1"]
62+
test:
63+
[
64+
"CMD-SHELL",
65+
"wget -qO- http://localhost:8123/?query=SELECT%201 || exit 1",
66+
]
5967
interval: 10s
6068
timeout: 5s
6169
retries: 10
@@ -86,6 +94,16 @@ services:
8694
condition: service_healthy
8795
clickhouse:
8896
condition: service_healthy
97+
healthcheck:
98+
test:
99+
[
100+
"CMD-SHELL",
101+
'wget -qO- http://127.0.0.1:18780/healthz | grep -q ''"ok":true''',
102+
]
103+
interval: 10s
104+
timeout: 5s
105+
retries: 12
106+
start_period: 20s
89107
networks:
90108
- croupier-network
91109

@@ -100,7 +118,14 @@ services:
100118
- "${AGENT_GRPC_PORT:-19090}:19090"
101119
- "${AGENT_HTTP_PORT:-19091}:19091"
102120
depends_on:
103-
- server
121+
server:
122+
condition: service_healthy
123+
healthcheck:
124+
test: ["CMD", "nc", "-z", "127.0.0.1", "19091"]
125+
interval: 10s
126+
timeout: 5s
127+
retries: 12
128+
start_period: 10s
104129
networks:
105130
- croupier-network
106131

@@ -111,7 +136,14 @@ services:
111136
ports:
112137
- "${DASHBOARD_PORT:-8000}:80"
113138
depends_on:
114-
- server
139+
server:
140+
condition: service_healthy
141+
healthcheck:
142+
test: ["CMD-SHELL", "wget -qO- http://127.0.0.1/ >/dev/null 2>&1"]
143+
interval: 10s
144+
timeout: 5s
145+
retries: 12
146+
start_period: 10s
115147
networks:
116148
- croupier-network
117149

@@ -122,12 +154,13 @@ services:
122154
profiles: ["sdk-examples"]
123155
environment:
124156
CROUPIER_AGENT_ADDR: ${CROUPIER_AGENT_ADDR:-agent:19091}
125-
CROUPIER_GAME_ID: ${CROUPIER_SDK_EXAMPLE_GAME_ID:-demo-game}
157+
CROUPIER_GAME_ID: ${CROUPIER_SDK_EXAMPLE_GAME_ID:-default}
126158
CROUPIER_SERVICE_ID: ${CROUPIER_SDK_GO_EXAMPLE_SERVICE_ID:-game-demo-go}
127159
CROUPIER_LOCAL_LISTEN: ${CROUPIER_SDK_EXAMPLE_LOCAL_LISTEN:-0.0.0.0:19103}
128-
CROUPIER_ENV: ${CROUPIER_SDK_EXAMPLE_ENV:-development}
160+
CROUPIER_ENV: ${CROUPIER_SDK_EXAMPLE_ENV:-dev}
129161
depends_on:
130-
- agent
162+
agent:
163+
condition: service_healthy
131164
networks:
132165
- croupier-network
133166

@@ -138,11 +171,12 @@ services:
138171
profiles: ["sdk-examples"]
139172
environment:
140173
CROUPIER_AGENT_ADDR: ${CROUPIER_AGENT_ADDR:-agent:19091}
141-
CROUPIER_GAME_ID: ${CROUPIER_SDK_EXAMPLE_GAME_ID:-demo-game}
174+
CROUPIER_GAME_ID: ${CROUPIER_SDK_EXAMPLE_GAME_ID:-default}
142175
CROUPIER_SERVICE_ID: ${CROUPIER_SDK_PYTHON_EXAMPLE_SERVICE_ID:-game-demo-python}
143-
CROUPIER_ENV: ${CROUPIER_SDK_EXAMPLE_ENV:-development}
176+
CROUPIER_ENV: ${CROUPIER_SDK_EXAMPLE_ENV:-dev}
144177
depends_on:
145-
- agent
178+
agent:
179+
condition: service_healthy
146180
networks:
147181
- croupier-network
148182

@@ -153,11 +187,12 @@ services:
153187
profiles: ["sdk-examples"]
154188
environment:
155189
CROUPIER_AGENT_ADDR: ${CROUPIER_AGENT_ADDR:-agent:19091}
156-
CROUPIER_GAME_ID: ${CROUPIER_SDK_EXAMPLE_GAME_ID:-demo-game}
190+
CROUPIER_GAME_ID: ${CROUPIER_SDK_EXAMPLE_GAME_ID:-default}
157191
CROUPIER_SERVICE_ID: ${CROUPIER_SDK_JAVA_EXAMPLE_SERVICE_ID:-game-demo-java}
158-
CROUPIER_ENV: ${CROUPIER_SDK_EXAMPLE_ENV:-development}
192+
CROUPIER_ENV: ${CROUPIER_SDK_EXAMPLE_ENV:-dev}
159193
depends_on:
160-
- agent
194+
agent:
195+
condition: service_healthy
161196
networks:
162197
- croupier-network
163198

@@ -168,11 +203,12 @@ services:
168203
profiles: ["sdk-examples"]
169204
environment:
170205
CROUPIER_AGENT_ADDR: ${CROUPIER_AGENT_ADDR:-agent:19091}
171-
CROUPIER_GAME_ID: ${CROUPIER_SDK_EXAMPLE_GAME_ID:-demo-game}
206+
CROUPIER_GAME_ID: ${CROUPIER_SDK_EXAMPLE_GAME_ID:-default}
172207
CROUPIER_SERVICE_ID: ${CROUPIER_SDK_JS_EXAMPLE_SERVICE_ID:-game-demo-js}
173-
CROUPIER_ENV: ${CROUPIER_SDK_EXAMPLE_ENV:-development}
208+
CROUPIER_ENV: ${CROUPIER_SDK_EXAMPLE_ENV:-dev}
174209
depends_on:
175-
- agent
210+
agent:
211+
condition: service_healthy
176212
networks:
177213
- croupier-network
178214

@@ -183,11 +219,12 @@ services:
183219
profiles: ["sdk-examples"]
184220
environment:
185221
CROUPIER_AGENT_ADDR: ${CROUPIER_AGENT_ADDR:-agent:19091}
186-
CROUPIER_GAME_ID: ${CROUPIER_SDK_EXAMPLE_GAME_ID:-demo-game}
222+
CROUPIER_GAME_ID: ${CROUPIER_SDK_EXAMPLE_GAME_ID:-default}
187223
CROUPIER_SERVICE_ID: ${CROUPIER_SDK_CPP_EXAMPLE_SERVICE_ID:-game-demo-cpp}
188-
CROUPIER_ENV: ${CROUPIER_SDK_EXAMPLE_ENV:-development}
224+
CROUPIER_ENV: ${CROUPIER_SDK_EXAMPLE_ENV:-dev}
189225
depends_on:
190-
- agent
226+
agent:
227+
condition: service_healthy
191228
networks:
192229
- croupier-network
193230

@@ -198,11 +235,12 @@ services:
198235
profiles: ["sdk-examples"]
199236
environment:
200237
CROUPIER_AGENT_ADDR: ${CROUPIER_AGENT_ADDR:-agent:19091}
201-
CROUPIER_GAME_ID: ${CROUPIER_SDK_EXAMPLE_GAME_ID:-demo-game}
238+
CROUPIER_GAME_ID: ${CROUPIER_SDK_EXAMPLE_GAME_ID:-default}
202239
CROUPIER_SERVICE_ID: ${CROUPIER_SDK_CSHARP_EXAMPLE_SERVICE_ID:-game-demo-csharp}
203-
CROUPIER_ENV: ${CROUPIER_SDK_EXAMPLE_ENV:-development}
240+
CROUPIER_ENV: ${CROUPIER_SDK_EXAMPLE_ENV:-dev}
204241
depends_on:
205-
- agent
242+
agent:
243+
condition: service_healthy
206244
networks:
207245
- croupier-network
208246

0 commit comments

Comments
 (0)