File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -29,10 +29,14 @@ FROM ubuntu:22.04 as runtime
29
29
30
30
WORKDIR /
31
31
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
33
34
34
35
COPY --from=build /app/target/release/bors .
35
36
36
37
EXPOSE 80
37
38
39
+ HEALTHCHECK --timeout=10s --start-period=10s \
40
+ CMD curl -f http://localhost/health || exit 1
41
+
38
42
ENTRYPOINT ["./bors" ]
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ use anyhow::Error;
8
8
use axum:: extract:: State ;
9
9
use axum:: http:: StatusCode ;
10
10
use axum:: response:: IntoResponse ;
11
- use axum:: routing:: post;
11
+ use axum:: routing:: { get , post} ;
12
12
use axum:: Router ;
13
13
use octocrab:: Octocrab ;
14
14
use std:: future:: Future ;
@@ -47,10 +47,15 @@ pub type ServerStateRef = Arc<ServerState>;
47
47
pub fn create_app ( state : ServerState ) -> Router {
48
48
Router :: new ( )
49
49
. route ( "/github" , post ( github_webhook_handler) )
50
+ . route ( "/health" , get ( health_handler) )
50
51
. layer ( ConcurrencyLimitLayer :: new ( 100 ) )
51
52
. with_state ( Arc :: new ( state) )
52
53
}
53
54
55
+ async fn health_handler ( ) -> impl IntoResponse {
56
+ ( StatusCode :: OK , "" )
57
+ }
58
+
54
59
/// Axum handler that receives a webhook and sends it to a webhook channel.
55
60
pub async fn github_webhook_handler (
56
61
State ( state) : State < ServerStateRef > ,
You can’t perform that action at this time.
0 commit comments