Skip to content

Commit 9a8c5f3

Browse files
haasonsaasclaude
andcommitted
Add /api/health endpoint and update Dockerfile for container deployment
- Add lightweight /api/health endpoint returning {"ok": true} for k8s probes - Update Dockerfile to include frontend build stage (Node + npm) - Change default CMD to serve mode for container use Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 73f0706 commit 9a8c5f3

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

Dockerfile

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
# Build stage
1+
# Frontend build stage
2+
FROM node:20-alpine AS frontend
3+
4+
WORKDIR /app/web
5+
COPY web/package.json web/package-lock.json ./
6+
RUN npm ci
7+
COPY web/ .
8+
RUN npm run build
9+
10+
# Rust build stage
211
FROM rust:alpine AS builder
312

413
RUN apk add --no-cache musl-dev
@@ -8,9 +17,13 @@ WORKDIR /app
817
# Cache dependencies
918
COPY Cargo.toml Cargo.lock ./
1019
RUN mkdir src && echo 'fn main() {}' > src/main.rs && \
20+
mkdir -p web/dist && \
1121
cargo build --release && \
1222
rm -rf src
1323

24+
# Copy frontend build output (embedded via rust-embed)
25+
COPY --from=frontend /app/web/dist ./web/dist
26+
1427
# Build actual binary
1528
COPY src ./src
1629
RUN touch src/main.rs && cargo build --release
@@ -22,5 +35,7 @@ RUN apk add --no-cache ca-certificates git
2235

2336
COPY --from=builder /app/target/release/diffscope /usr/local/bin/diffscope
2437

38+
EXPOSE 3000
39+
2540
ENTRYPOINT ["diffscope"]
26-
CMD ["--help"]
41+
CMD ["serve", "--host", "0.0.0.0", "--port", "3000"]

src/server/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ pub async fn start_server(config: Config, host: &str, port: u16) -> anyhow::Resu
8484
.allow_headers(tower_http::cors::Any);
8585

8686
let api_routes = Router::new()
87+
.route("/health", get(|| async { axum::Json(serde_json::json!({"ok": true})) }))
8788
.route("/status", get(api::get_status))
8889
.route("/review", post(api::start_review))
8990
.route("/reviews", get(api::list_reviews))

0 commit comments

Comments
 (0)