Skip to content

Commit 93f4416

Browse files
committed
chore(docker): add healthcheck
1 parent 80ea38b commit 93f4416

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,14 @@ FROM ubuntu:22.04 as runtime
2929

3030
WORKDIR /
3131

32-
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y ca-certificates
32+
# curl is needed for healthcheck
33+
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y ca-certificates curl
3334

3435
COPY --from=build /app/target/release/bors .
3536

3637
EXPOSE 80
3738

39+
HEALTHCHECK --timeout=10s --start-period=10s \
40+
CMD curl -f http://localhost/health || exit 1
41+
3842
ENTRYPOINT ["./bors"]

src/github/server.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use anyhow::Error;
88
use axum::extract::State;
99
use axum::http::StatusCode;
1010
use axum::response::IntoResponse;
11-
use axum::routing::post;
11+
use axum::routing::{get, post};
1212
use axum::Router;
1313
use octocrab::Octocrab;
1414
use std::future::Future;
@@ -47,10 +47,15 @@ pub type ServerStateRef = Arc<ServerState>;
4747
pub fn create_app(state: ServerState) -> Router {
4848
Router::new()
4949
.route("/github", post(github_webhook_handler))
50+
.route("/health", get(health_handler))
5051
.layer(ConcurrencyLimitLayer::new(100))
5152
.with_state(Arc::new(state))
5253
}
5354

55+
async fn health_handler() -> impl IntoResponse {
56+
(StatusCode::OK, "")
57+
}
58+
5459
/// Axum handler that receives a webhook and sends it to a webhook channel.
5560
pub async fn github_webhook_handler(
5661
State(state): State<ServerStateRef>,

0 commit comments

Comments
 (0)