mirror of
https://codeberg.org/video-prize-ranch/rimgo.git
synced 2025-06-27 23:48:23 +00:00
feat: add healthcheck
Signed-off-by: rare-magma <rare-magma@posteo.eu>
This commit is contained in:
parent
20715f53af
commit
dd206b5278
@ -8,13 +8,17 @@ COPY . .
|
|||||||
|
|
||||||
RUN npx tailwindcss -i static/tailwind.css -o static/app.css -m
|
RUN npx tailwindcss -i static/tailwind.css -o static/app.css -m
|
||||||
RUN go mod download
|
RUN go mod download
|
||||||
RUN GOOS=linux GOARCH=$TARGETARCH CGO_ENABLED=0 go build -ldflags "-X codeberg.org/rimgo/rimgo/pages.VersionInfo=$(date '+%Y-%m-%d')-$(git rev-list --abbrev-commit -1 HEAD)"
|
RUN GOOS=linux GOARCH=$TARGETARCH CGO_ENABLED=0 go build -ldflags "-X codeberg.org/rimgo/rimgo/pages.VersionInfo=$(date '+%Y-%m-%d')-$(git rev-list --abbrev-commit -1 HEAD)" \
|
||||||
|
&& GOOS=linux GOARCH=$TARGETARCH CGO_ENABLED=0 go build -o healthcheck ./healthcheck
|
||||||
|
|
||||||
FROM scratch as bin
|
FROM scratch as bin
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
||||||
COPY --from=build /src/rimgo .
|
COPY --from=build /src/rimgo .
|
||||||
|
COPY --from=build /src/healthcheck .
|
||||||
|
|
||||||
|
HEALTHCHECK --interval=60s --timeout=5s --start-period=2s --retries=3 CMD [ "/healthcheck","http://localhost:3000/livez" ]
|
||||||
|
|
||||||
EXPOSE 3000
|
EXPOSE 3000
|
||||||
|
|
||||||
|
20
healthcheck/heathcheck.go
Normal file
20
healthcheck/heathcheck.go
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
if len(os.Args) < 2 {
|
||||||
|
log.Fatal("Expected URL as command-line argument")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
url := os.Args[1]
|
||||||
|
fmt.Println(url)
|
||||||
|
if _, err := http.Get(url); err != nil {
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
4
main.go
4
main.go
@ -11,13 +11,14 @@ import (
|
|||||||
"codeberg.org/rimgo/rimgo/static"
|
"codeberg.org/rimgo/rimgo/static"
|
||||||
"codeberg.org/rimgo/rimgo/utils"
|
"codeberg.org/rimgo/rimgo/utils"
|
||||||
"codeberg.org/rimgo/rimgo/views"
|
"codeberg.org/rimgo/rimgo/views"
|
||||||
"github.com/mailgun/raymond/v2"
|
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
"github.com/gofiber/fiber/v2/middleware/cache"
|
"github.com/gofiber/fiber/v2/middleware/cache"
|
||||||
"github.com/gofiber/fiber/v2/middleware/filesystem"
|
"github.com/gofiber/fiber/v2/middleware/filesystem"
|
||||||
|
"github.com/gofiber/fiber/v2/middleware/healthcheck"
|
||||||
"github.com/gofiber/fiber/v2/middleware/recover"
|
"github.com/gofiber/fiber/v2/middleware/recover"
|
||||||
"github.com/gofiber/template/handlebars/v2"
|
"github.com/gofiber/template/handlebars/v2"
|
||||||
"github.com/joho/godotenv"
|
"github.com/joho/godotenv"
|
||||||
|
"github.com/mailgun/raymond/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@ -56,6 +57,7 @@ func main() {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
app.Use(healthcheck.New())
|
||||||
app.Use(recover.New(recover.Config{
|
app.Use(recover.New(recover.Config{
|
||||||
EnableStackTrace: true,
|
EnableStackTrace: true,
|
||||||
StackTraceHandler: func(c *fiber.Ctx, e interface{}) {
|
StackTraceHandler: func(c *fiber.Ctx, e interface{}) {
|
||||||
|
Loading…
Reference in New Issue
Block a user