jbergstroem / mariadb-alpine

A tiny and fast MariaDB container
MIT License
72 stars 19 forks source link

feat: use mariadb client for healthchecks #221

Open jbergstroem opened 1 year ago

jbergstroem commented 1 year ago

Instead of grepping for an existing daemon, we now run a query similar to how mysqladmin does it (connects to server/db and runs select 1).

Todo

jbergstroem commented 1 year ago

Findings:

jbergstroem commented 1 year ago

this makes this image deviate from the original mariadb one a bit too much for me

This is what the original does:

$ mariadb -h localhost --protocol tcp -e 'select 1'

If you set up this repo using the PR and remove your environment variables you'd see the same result.

Edit: if you check the original issue about adding this functionality to MariaDB; they are talking about the same thing / what I am trying to do as default: https://github.com/MariaDB/mariadb-docker/issues/94

The cleanest approach to me from a production standpoint is to initialize your container, no longer pass credentials in your compose, then mount a config that contains authentication in a [mariadb-client] directive. Even with that, what I'm suggesting in this PR would work just fine (no variables are set -> just connect without passing credentials, reading from config instead).

I would add it to the documentation / best practices. That would be a great way to unit test this as well.

What do you think?