You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Typesense service fails to initialize in Github Actions #441
I don't know if it's a Typesense or Github Actions issue.
The service fails to initialize because it's "unhealthy".
But health checks are not even sent, Github Actions performs a check with "docker inspect" which seems to fail.
Typesense works well in local (docker-compose) with the same image, env, and ports.
Steps to reproduce
Define a Github Actions workflow with the following service:
Service becomes healthy and the workflow can run properly.
Actual Behavior
Service is unhealthy:
/usr/bin/docker inspect --format="{{if .Config.Healthcheck}}{{print .State.Health.Status}}{{end}}" c45d5a57a553df994ce764614c72decb5c59d195c00ce085cf2dcff1ffc885f5
unhealthy
Error: Failed to initialize, typesense service is unhealthy.
Hi @Femt0, I haven't used Github Actions yet, but one thing that stands out to me is that the data dir defined by TYPESENSE_DATA_DIR: /data is not mounted into the docker container in the snippet you shared. So I suspect the container is actually failing to start.
Are you able to get the docker logs for the Typesense container?
Also, I wonder if in --health-cmd "curl http://127.0.0.1:8108/health", may be 127.0.0.1 is not the hostname exposed by docker? Wonder if it's typesense (so may be http://typesense/health works) since that's set as the network alias?
I am afraid, I cannot get any more logs. When I remove the options property, I can get Typesense to start and pass a separate health check (see second step) in this demo repo.
I think the issue is with the --health-cmd which is part of Docker's HEALTHCHECK. I thought it expects a zero exit code but that is what it get's from curl "http://localhost:8108/health returning {"ok":true}.
@alexanderjulmer I was able to replicate the issue by running docker locally with those health checks. It turns out that the curl command was being run inside the container, and the image doesn't have curl installed. So updating the health check to first install curl worked locally for me"
I'm also trying to achieve a healthcheck in my docker-compose file via as I'm using docker-compose locally and in the github CI:
services:
typesense:
image: typesense/typesense:0.24.0.rcn56ports:
- "8108:8108"environment:
TYPESENSE_DATA_DIR: /dataTYPESENSE_API_KEY: S3CR3T# currently not working as curl not available:#healthcheck:# test: ["CMD-SHELL", "curl --silent --fail localhost:8108/health || exit 1"]# interval: 5s# timeout: 5s# retries: 10volumes:
- typesense-data:/datavolumes:
typesense-data:
I did then try to debug it and run docker ps to get my container id and then did connect then via docker exec -it 3c202f37e9d8 bash into the container.
I found out that even in the container I can not install curl (not enough space as it seems hard limited) I also did not found any other way to make the healthcheck.
So I think the best way would be if the typesense/typesense image is shipped with curl so we can make the healthcheck and don't require to create custom containers just for it.
Thank you for sharing such a piece of code that I was missing, I may add to your solution to fix problem of curl missing if this situation still persists in latest versions:
healthcheck:
# there it is installing curl silently if not already installed.test: ["CMD-SHELL", "apt install curl -y &>/dev/null || curl --silent --fail localhost:8108/health || exit 1"]interval: 5stimeout: 5sretries: 10
Again Thank you! I'm new to typesense and docker healthchecks so your code was much helpful. 😄
You can use raw bash to make a HTTP request and dont install curl or wget.
This command can be included in Typesense Docker to call this with cmd name typesense-ping
Shipping curl in the image seems to be the preferred resolution with this. Unfortunately I was not able to find the manifests and workflows that build to Docker Hub, why I'm not able to send in a PR.
Activity
jasonbosco commentedon Nov 23, 2021
Hi @Femt0, I haven't used Github Actions yet, but one thing that stands out to me is that the data dir defined by
TYPESENSE_DATA_DIR: /datais not mounted into the docker container in the snippet you shared. So I suspect the container is actually failing to start.Are you able to get the docker logs for the Typesense container?
alexanderjulmer commentedon Feb 7, 2022
I am facing the same problem.
I created a demo repo to include only a Typesense container.
You can find the logs here. It seems like the container is not coming up but the volume wasn't the issue.
I'd greatly appreciate if you could look into this. Having a one-off Typesense instance in my testing workflow would be great.
jasonbosco commentedon Feb 7, 2022
@alexanderjulmer Are you able to get the docker logs somehow? That should have the actual logs from Typesense (vs Github actions logs)
jasonbosco commentedon Feb 7, 2022
Also, I wonder if in
--health-cmd "curl http://127.0.0.1:8108/health", may be127.0.0.1is not the hostname exposed by docker? Wonder if it'stypesense(so may behttp://typesense/healthworks) since that's set as the network alias?alexanderjulmer commentedon Feb 7, 2022
I am afraid, I cannot get any more logs. When I remove the
optionsproperty, I can get Typesense to start and pass a separate health check (see second step) in this demo repo.I think the issue is with the
--health-cmdwhich is part of Docker's HEALTHCHECK. I thought it expects a zero exit code but that is what it get's fromcurl "http://localhost:8108/healthreturning{"ok":true}.jasonbosco commentedon Feb 7, 2022
@alexanderjulmer I was able to replicate the issue by running docker locally with those health checks. It turns out that the curl command was being run inside the container, and the image doesn't have curl installed. So updating the health check to first install curl worked locally for me"
docker run \ --name typesense \ --health-cmd "apt-get update && apt-get install -y curl && curl http://127.0.0.1:8108/health" \ --health-interval 10s \ --health-timeout 5s \ --health-retries 5 \ -i -p 8108:8108 \ -v/tmp/typesense-server-data-1c/:/data \ typesense/typesense:0.22.2 --data-dir /data --api-key=xyz --listen-port 8108 --enable-corsAfter about 20s, I see this:
Previously it used to show "unhealthy".
Could you update the health check in Github actions similarly and see if it works?
jirevwe commentedon Aug 16, 2022
I was able to setup a GitHub Actions Typesense runner you can see it here and I'm using it in my project here. Hopefully it can help others too
alexander-schranz commentedon Jan 15, 2023
I'm also trying to achieve a healthcheck in my docker-compose file via as I'm using docker-compose locally and in the github CI:
I did then try to debug it and run
docker psto get my container id and then did connect then viadocker exec -it 3c202f37e9d8 bashinto the container.I found out that even in the container I can not install
curl(not enough space as it seems hard limited) I also did not found any other way to make the healthcheck.So I think the best way would be if the
typesense/typesenseimage is shipped withcurlso we can make the healthcheck and don't require to create custom containers just for it.hahouari commentedon Apr 22, 2023
Thank you for sharing such a piece of code that I was missing, I may add to your solution to fix problem of
curl missingif this situation still persists in latest versions:Again Thank you! I'm new to typesense and docker healthchecks so your code was much helpful. 😄
tonybolzan commentedon Nov 1, 2024
You can use raw bash to make a HTTP request and dont install curl or wget.
This command can be included in Typesense Docker to call this with cmd name
typesense-pingalmereyda commentedon Mar 15, 2025
Shipping
curlin the image seems to be the preferred resolution with this. Unfortunately I was not able to find the manifests and workflows that build to Docker Hub, why I'm not able to send in a PR.ZRktty commentedon Aug 19, 2025
@tonybolzan Thanks! It works like a charm!
fix: Use bash TCP check for Docker health check (no external tools)