Skip to content

Commit

Permalink
Merge pull request #131 from MarcoIeni/chore-docker-add-healthcheck
Browse files Browse the repository at this point in the history
chore(docker): add healthcheck
  • Loading branch information
Kobzol authored Sep 3, 2024
2 parents 89e0b35 + 93f4416 commit 371ae05
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@ FROM ubuntu:22.04 as runtime

WORKDIR /

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

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

EXPOSE 80

HEALTHCHECK --timeout=10s --start-period=10s \
CMD curl -f http://localhost/health || exit 1

ENTRYPOINT ["./bors"]
7 changes: 6 additions & 1 deletion src/github/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use anyhow::Error;
use axum::extract::State;
use axum::http::StatusCode;
use axum::response::IntoResponse;
use axum::routing::post;
use axum::routing::{get, post};
use axum::Router;
use octocrab::Octocrab;
use std::future::Future;
Expand Down Expand Up @@ -47,10 +47,15 @@ pub type ServerStateRef = Arc<ServerState>;
pub fn create_app(state: ServerState) -> Router {
Router::new()
.route("/github", post(github_webhook_handler))
.route("/health", get(health_handler))
.layer(ConcurrencyLimitLayer::new(100))
.with_state(Arc::new(state))
}

async fn health_handler() -> impl IntoResponse {
(StatusCode::OK, "")
}

/// Axum handler that receives a webhook and sends it to a webhook channel.
pub async fn github_webhook_handler(
State(state): State<ServerStateRef>,
Expand Down

0 comments on commit 371ae05

Please sign in to comment.