From 060df89396e27448eca6a0e076c2a4d45619a035 Mon Sep 17 00:00:00 2001 From: Reinaldy Rafli Date: Tue, 29 Aug 2023 21:34:34 +0700 Subject: [PATCH 1/2] feat(backend): ping endpoint --- backend/server.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/server.go b/backend/server.go index 90a46be..9d30d60 100644 --- a/backend/server.go +++ b/backend/server.go @@ -23,7 +23,7 @@ func NewServer(config *ServerConfig) *echo.Echo { // NOTE: Only need to handle CORS, everything else is being handled by the API gateway e.Use(middleware.CORSWithConfig(middleware.CORSConfig{ AllowOrigins: []string{"https://conf.teknologiumum.com"}, - AllowMethods: []string{"POST"}, + AllowMethods: []string{http.MethodPost}, AllowHeaders: []string{echo.HeaderOrigin, echo.HeaderContentType, echo.HeaderAccept}, AllowCredentials: false, MaxAge: 3600, // 1 day @@ -31,6 +31,10 @@ func NewServer(config *ServerConfig) *echo.Echo { e.Use(middleware.RequestID()) + e.GET("/ping", func(c echo.Context) error { + return c.NoContent(http.StatusOK) + }) + e.POST("/users", func(c echo.Context) error { requestId := c.Request().Header.Get(echo.HeaderXRequestID) sentryHub := sentryecho.GetHubFromContext(c) From 38cd7e92d515cb90b580e78aab29c3d8c7034e8e Mon Sep 17 00:00:00 2001 From: Reinaldy Rafli Date: Tue, 29 Aug 2023 21:51:14 +0700 Subject: [PATCH 2/2] feat(backend): put healthcheck on dockerfile --- backend/Dockerfile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/backend/Dockerfile b/backend/Dockerfile index 269e2b4..1b066d1 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -10,12 +10,20 @@ FROM debian:bookworm-slim AS runtime WORKDIR /app +RUN apt-get update && \ + apt-get install -y curl && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + ARG PORT=8080 RUN mkdir -p /app/csv COPY --from=build /app/ . +HEALTHCHECK --interval=60s --timeout=40s \ + CMD curl -f http://localhost:8080/ping || exit 1 + EXPOSE ${PORT} CMD ["/app/conf-backend", "server"] \ No newline at end of file