Add healthcheck to crystal runtime

This commit is contained in:
Roberto Alsina 2024-06-29 23:30:10 -03:00
parent 5bb7ac45b3
commit 3bee4f5cf6
3 changed files with 6 additions and 5 deletions

View File

@ -10,7 +10,7 @@ RUN shards build --release
RUN strip bin/* RUN strip bin/*
FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine as ship FROM --platform=${TARGETPLATFORM:-linux/amd64} alpine as ship
RUN apk update && apk upgrade && apk add openssl pcre2 libgcc gc libevent && apk cache clean RUN apk update && apk upgrade && apk add openssl pcre2 libgcc gc libevent curl && apk cache clean
RUN addgroup -S app && adduser app -S -G app RUN addgroup -S app && adduser app -S -G app
WORKDIR /home/app WORKDIR /home/app
@ -19,3 +19,4 @@ USER app
COPY --from=build /home/app/bin/function . COPY --from=build /home/app/bin/function .
CMD ["./function"] CMD ["./function"]
HEALTHCHECK CMD curl --fail http://localhost:3000/ping || exit 1

View File

@ -1,4 +1,8 @@
require "kemal" require "kemal"
require "./funko.cr" require "./funko.cr"
get "/ping/" do
"OK"
end
Kemal.run Kemal.run

View File

@ -84,8 +84,6 @@ module Faaso
funkos.each do |funko| funkos.each do |funko|
container_name = "faaso-#{funko.name}" container_name = "faaso-#{funko.name}"
docker_api = Docr::API.new(Docr::Client.new) docker_api = Docr::API.new(Docr::Client.new)
# Pull image from registry
# docker_api.images.create(image: tag)
# Get image history, sorted newer image first # Get image history, sorted newer image first
begin begin
@ -176,8 +174,6 @@ module Faaso
end end
puts "Container for #{funko.name} is running" puts "Container for #{funko.name} is running"
end end
# TODO: Run test for healthcheck
# TODO: Return function URL for testing
end end
end end