diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e18dd7d..d880acb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,22 +14,18 @@ jobs: steps: - name: Checkout Code uses: actions/checkout@v4 + - name: Test Docker Build run: | docker build -t metacall/nodejs-c-liburing-example . - docker run --rm -p 8000:8000 --name metacall_test -d metacall/nodejs-c-liburing-example + docker run -p 8000:8000 --name metacall_test -d metacall/nodejs-c-liburing-example + + - name: Wait for Readiness + run: | + until [ "`docker inspect -f {{.State.Health.Status}} metacall_test`" == "healthy" ]; do + sleep 1 + done -# TODO: This works on my pc.. but it seems not to work in the CI -# RETRIES=0 -# while true; do -# HTTP_CODE="$(wget --server-response -q "http://localhost:8000" 2>&1 | grep "HTTP/" | awk '{print $2}')" -# if [[ "$HTTP_CODE" -eq "200" ]]; then -# echo "Service is ready (HTTP 200)." -# exit 0 -# elif [[ "$RETRIES" -ge "20" ]]; then -# echo "Max retries reached. Service not ready." -# exit 1 -# fi -# RETRIES=$((RETRIES + 1)) -# sleep 5 -# done + - name: Test + run: | + curl localhost:8000 || exit 1 diff --git a/Dockerfile b/Dockerfile index 1d2d96f..93466e7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -39,20 +39,10 @@ WORKDIR /root # Clone and build the project RUN git clone --branch v0.8.7 https://github.com/metacall/core \ - && ./core/tools/metacall-environment.sh release base nodejs c \ && mkdir core/build && cd core/build \ - && cmake \ - -DOPTION_BUILD_LOADERS_C=On \ - -DOPTION_BUILD_LOADERS_NODE=On \ - -DOPTION_BUILD_PORTS=On \ - -DOPTION_BUILD_PORTS_NODE=On \ - -DOPTION_BUILD_DETOURS=Off \ - -DOPTION_BUILD_SCRIPTS=Off \ - -DOPTION_BUILD_TESTS=Off \ - -DOPTION_BUILD_EXAMPLES=Off \ - .. \ - && cmake --build . --target install \ - && ldconfig /usr/local/lib \ + && ../tools/metacall-environment.sh release base nodejs c \ + && ../tools/metacall-configure.sh release nodejs c ports install \ + && ../tools/metacall-build.sh release nodejs c ports install \ && cd ../.. \ && rm -rf core @@ -67,7 +57,7 @@ ENV LOADER_LIBRARY_PATH=/usr/local/lib \ EXPOSE 8000 -HEALTHCHECK --interval=10s --timeout=3s \ - CMD wget --no-verbose --tries=1 --spider http://localhost:8000/ || exit 1 +HEALTHCHECK --interval=1s --timeout=3s --start-period=1ms \ + CMD curl localhost:8000 || exit 1 CMD [ "metacallcli", "/root/index.js" ]