Skip to content

Commit

Permalink
Improve docker and ci.
Browse files Browse the repository at this point in the history
  • Loading branch information
viferga committed Jan 9, 2025
1 parent 08001ac commit 3572f22
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 30 deletions.
26 changes: 11 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
20 changes: 5 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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" ]

0 comments on commit 3572f22

Please sign in to comment.