Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add healthchecks to docker-compose.yml #36

Merged
merged 4 commits into from
Apr 24, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ services:
- "SMARTHOST_ALIASES=${SMARTHOST_ALIASES}"

redis:
image: redis:7.2
image: eqalpha/keydb:x86_64_v6.3.4
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This image is x64 only while the Redis image is ARM as well. Would it be possible to remove the arch modifier here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that unless MISP changes the default key-value storage, we should only document this alternative in the README.md rather than modify the docker-compose.yml file

Copy link
Contributor Author

@ftoppi ftoppi Mar 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine by me. All their images are arch-specific except eqalpha/keydb:latest which is both for arm64 and x86_64.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also reference https://github.com/valkey-io/valkey if a docker image is available.

healthcheck:
test: keydb-cli ping || exit 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the alternative command if were to use Redis here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redis-cli ping

interval: 2s
timeout: 1s
retries: 3
start_period: 30s

db:
# We use MariaDB because it supports ARM and has the expected collations
Expand All @@ -27,6 +33,12 @@ services:
- mysql_data:/var/lib/mysql
cap_add:
- SYS_NICE # CAP_SYS_NICE Prevent runaway mysql log
healthcheck:
test: mysqladmin --user=$$MYSQL_USER --password=$$MYSQL_PASSWORD status
interval: 2s
timeout: 1s
retries: 3
start_period: 30s

misp-core:
image: ghcr.io/misp/misp-docker/misp-core:latest
Expand All @@ -46,8 +58,16 @@ services:
- PYPI_CYBOX_VERSION=${PYPI_CYBOX_VERSION}
- PYPI_PYMISP_VERSION=${PYPI_PYMISP_VERSION}
depends_on:
- redis
- db
redis:
condition: service_healthy
db:
condition: service_healthy
healthcheck:
test: curl -ks https://localhost/users/login > /dev/null || exit 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this check run inside the container? In other words, Is localhost the correct setting regardless of our BASE_URL?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's run inside the container.
You can see below I don't expose ports in my stack and it's still healthy:

$ docker compose ps 2> /dev/null
NAME                  IMAGE                                          COMMAND                  SERVICE        CREATED        STATUS                  PORTS
misp-db-1             mariadb:10.11                                  "docker-entrypoint.s…"   db             43 hours ago   Up 43 hours (healthy)   3306/tcp
misp-mail-1           ixdotai/smtp                                   "/bin/entrypoint.sh …"   mail           43 hours ago   Up 43 hours             25/tcp
misp-misp-core-1      ghcr.io/misp/misp-docker/misp-core:latest      "/entrypoint.sh"         misp-core      42 hours ago   Up 42 hours (healthy)
misp-misp-modules-1   ghcr.io/misp/misp-docker/misp-modules:latest   "/usr/local/bin/misp…"   misp-modules   43 hours ago   Up 43 hours
misp-redis-1          eqalpha/keydb:x86_64_v6.3.4                    "docker-entrypoint.s…"   redis          43 hours ago   Up 43 hours (healthy)   6379/tcp

interval: 2s
timeout: 1s
retries: 3
start_period: 30s
ports:
- "80:80"
- "443:443"
Expand Down Expand Up @@ -126,7 +146,8 @@ services:
environment:
- "REDIS_BACKEND=redis"
depends_on:
- redis
redis:
condition: service_healthy

volumes:
mysql_data: