From 3bee4f5cf650353e993fab787ea3fa4b89100c94 Mon Sep 17 00:00:00 2001 From: Roberto Alsina Date: Sat, 29 Jun 2024 23:30:10 -0300 Subject: [PATCH] Add healthcheck to crystal runtime --- runtimes/crystal/Dockerfile | 3 ++- runtimes/crystal/main.cr | 4 ++++ src/faaso.cr | 4 ---- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/runtimes/crystal/Dockerfile b/runtimes/crystal/Dockerfile index 366e83d..e7f8fa1 100644 --- a/runtimes/crystal/Dockerfile +++ b/runtimes/crystal/Dockerfile @@ -10,7 +10,7 @@ RUN shards build --release RUN strip bin/* 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 WORKDIR /home/app @@ -19,3 +19,4 @@ USER app COPY --from=build /home/app/bin/function . CMD ["./function"] +HEALTHCHECK CMD curl --fail http://localhost:3000/ping || exit 1 \ No newline at end of file diff --git a/runtimes/crystal/main.cr b/runtimes/crystal/main.cr index c8670e8..e719143 100644 --- a/runtimes/crystal/main.cr +++ b/runtimes/crystal/main.cr @@ -1,4 +1,8 @@ require "kemal" require "./funko.cr" +get "/ping/" do + "OK" +end + Kemal.run diff --git a/src/faaso.cr b/src/faaso.cr index 7dc2032..79bb84e 100644 --- a/src/faaso.cr +++ b/src/faaso.cr @@ -84,8 +84,6 @@ module Faaso funkos.each do |funko| container_name = "faaso-#{funko.name}" 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 begin @@ -176,8 +174,6 @@ module Faaso end puts "Container for #{funko.name} is running" end - # TODO: Run test for healthcheck - # TODO: Return function URL for testing end end