Skip to content

Commit

Permalink
chore: add health check in docker (#1452)
Browse files Browse the repository at this point in the history
* chore: add healthcheck in docker-compose
* chore: use docker compose v2
  • Loading branch information
Flouse authored Sep 28, 2023
1 parent 47e7407 commit 71f5bad
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 12 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/build_image_ghcr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,18 @@ jobs:

- name: Review devtools/chain/docker-compose.yml
run: |
echo "====== devtools/chain/docker-compose.yml ======\n"
echo "====== devtools/chain/docker-compose.yml ======"
cat docker-compose.yml
echo "===============================================\n"
echo "==============================================="
docker -v
- name: Run docker compose up and a simple test
- name: Run docker compose (v2) up and check the Axon node's health
run: |
docker-compose up -d
docker-compose ps
docker-compose logs --tail 6
echo "start containers in detached mode and wait for them to become healthy"
docker compose up -d --wait
echo "TODO: health_check" && sleep 6
docker compose ps
docker compose logs --tail 6
npx zx <<'EOF'
import { waitXBlocksPassed } from '../ci/scripts/helper.js'
Expand Down
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@ RUN set -eux; \
cmake \
clang \
llvm \
jq \
gcc; \
rm -rf /var/lib/apt/lists/*

RUN cd /build && cargo build --release


FROM debian:bookworm-20230612-slim

RUN apt-get update \
&& apt-get install -y --no-install-recommends curl jq \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /app

COPY --from=builder \
Expand Down
7 changes: 6 additions & 1 deletion devtools/chain/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ services:
networks:
- axon-net
restart: unless-stopped
# CMD: see https://github.com/axonweb3/axon/blob/b89083/devtools/docker/docker-entrypoint.sh
# https://docs.docker.com/compose/compose-file/05-services/#healthcheck
healthcheck:
test: /app/devtools/docker/health_check.sh
start_period: 10s
timeout: 62s
# CMD: see https://github.com/axonweb3/axon/blob/dev/devtools/docker/docker-entrypoint.sh

explorer:
container_name: blockscan
Expand Down
6 changes: 3 additions & 3 deletions devtools/chain/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ Run Axon and it's explorer ([blockscan](https://github.com/Magickbase/blockscan)
Before getting started, ensure that you have the following prerequisites installed on your system:

- Docker v20.10+
- Docker-compose 2.x.x+
- Docker Compose v2.x.x+

## Run the Services

```bash
git clone --depth=1 https://github.com/axonweb3/axon.git
cd axon/devtools/chain
docker-compose up -d
docker compose up -d
```

### Watch the Logs
To monitor the logs of the running services, use the following command:
```bash
docker-compose logs -f --tail 1
docker compose logs -f --tail 1
```

This command will display the logs of the services, showing the latest log entries.
Expand Down
Empty file modified devtools/docker/health_check.sh
100644 → 100755
Empty file.

0 comments on commit 71f5bad

Please sign in to comment.