Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sdavids/sdavids-docker-healthcheck
Docker health checks
https://github.com/sdavids/sdavids-docker-healthcheck
docker golang nodejs rust
Last synced: 3 days ago
JSON representation
Docker health checks
- Host: GitHub
- URL: https://github.com/sdavids/sdavids-docker-healthcheck
- Owner: sdavids
- Created: 2022-01-22T04:30:47.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-12-06T13:48:21.000Z (about 1 month ago)
- Last Synced: 2024-12-06T14:42:26.632Z (about 1 month ago)
- Topics: docker, golang, nodejs, rust
- Language: Shell
- Homepage:
- Size: 101 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.adoc
- Contributing: CONTRIBUTING.adoc
- License: LICENSES/Apache-2.0.txt
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
- Security: SECURITY.md
Awesome Lists containing this project
README
// SPDX-FileCopyrightText: © 2024 Sebastian Davids
// SPDX-License-Identifier: Apache-2.0
= sdavids-docker-healthcheck
Sebastian Davids
// Metadata:
:description: Docker health checks
// Settings:
:sectnums:
:sectanchors:
:sectlinks:
:toc: macro
:toclevels: 3
:toc-placement!:
:hide-uri-scheme:
:source-highlighter: rouge
:rouge-style: github
// Refs:
:docker-install-url: https://docs.docker.com/install/
:go-install-url: https://go.dev/doc/install
:golangci-install-url: https://golangci-lint.run/usage/install/#local-installation
:easyrsa-install-url: https://easy-rsa.readthedocs.io/en/latest/#obtaining-and-using-easy-rsa
:fnm-install-url: https://github.com/Schniz/fnm#installation
:hadolint-install-url: https://github.com/hadolint/hadolint?tab=readme-ov-file#install
:nvm-install-url: https://github.com/nvm-sh/nvm#installing-and-updating
:rust-install-url: https://www.rust-lang.org/learn/get-started
:uri-apache-license: https://www.apache.org/licenses/LICENSE-2.0
:uri-contributor-covenant: https://www.contributor-covenant.org
:uri-google-style: https://github.com/google/gtsifdef::env-browser[:outfilesuffix: .adoc]
ifdef::env-github[]
:outfilesuffix: .adoc
:important-caption: :heavy_exclamation_mark:
:note-caption: :information_source:
:warning-caption: :warning:
:badges:
endif::[]ifdef::badges[]
image:https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg[Contributor Covenant,Version 2.1,link={uri-contributor-covenant}]
image:https://img.shields.io/badge/code%20style-google-blueviolet.svg[Code Style: Google,link={uri-google-style}]
image:https://img.shields.io/osslifecycle/sdavids/sdavids-docker-healthcheck[OSS Lifecycle]
image:https://img.shields.io/maintenance/yes/2024[Maintenance]
image:https://img.shields.io/github/last-commit/sdavids/sdavids-docker-healthcheck[GitHub last commit]
endif::[]toc::[]
Available Docker health checks:
link:go/http/README.adoc[Go - http]:: a Go-based Docker health check for an HTTP URL
link:go/https/README.adoc[Go - https]:: a Go-based Docker health check for an HTTP(S) URL
link:js/nodejs/README.adoc/[JavaScript - Node.js]:: a Node.js-based Docker health check for an HTTP(S) URL
link:rust/http/README.adoc[Rust - http]:: a Rust-based Docker health check for an HTTP URL
link:rust/https/README.adoc[Rust - https]:: a Rust-based Docker health check for an HTTP(S) URL
link:shell/nc/README.adoc[shell - nc]:: an nc-based Docker health check for a daemon port== Size Comparison
[options="header,autowidth"]
|===
|Program |Size |Notes|<>
>|4.0K
|only checks the daemon's port|<>
>|4.0K
|the `node` binary would add 40.3M|<>
>|188.0K
||<>
>|480.0K
||<>
>|5.0M
||<>
>|5.0M
||<>
>|8.6M
||<>
>|8.8M
||<>
>|9.7M
||<>
>|9.8M
||<>
>|10.3M
||<>
>|19.0M
|
|====== Go
[#go-http]
==== Go - http[source,shell]
----
$ cd go/http
$ scripts/docker_build.sh -t go-http
$ docker run --rm de.sdavids/sdavids-docker-healthcheck:go-http sh -c 'du -kh /usr/local/bin/healthcheck'
5.0M /usr/local/bin/healthcheck
----===== Usage
link:go/http/README.adoc#usage[Go - http]
[#go-https]
==== Go - https[source,shell]
----
$ cd go/https
$ scripts/docker_build.sh -t go-https
$ docker run --rm de.sdavids/sdavids-docker-healthcheck:go-https sh -c 'du -kh /usr/local/bin/healthcheck'
5.0M /usr/local/bin/healthcheck
----===== Usage
link:go/https/README.adoc#usage[Go - https]
=== JavaScript
[#js-nodejs]
==== Node.js[NOTE]
====
This healthcheck is only useful in a Node.js Docker image, i.e. an image where the `node` binary already exists--the `node` binary would add 40.3M.
====[source,shell]
----
$ cd js/nodejs
$ scripts/docker_build.sh -t js-nodejs
$ docker run --rm de.sdavids/sdavids-docker-healthcheck:js-nodejs sh -c 'du -kh /node/healthcheck.mjs'
4.0K /node/healthcheck.mjs
$ docker run --rm de.sdavids/sdavids-docker-healthcheck:js-nodejs sh -c 'du -kh /usr/bin/node'
40.3M /usr/bin/node
----===== Usage
link:js/nodejs/README.adoc#usage[js - nodejs]
[#rust-http]
=== Rust - http[source,shell]
----
$ cd rust/http
$ scripts/docker_build.sh -t rust-http
$ docker run --rm de.sdavids/sdavids-docker-healthcheck:rust-http sh -c 'du -kh /usr/local/bin/healthcheck'
188.0K /usr/local/bin/healthcheck
----==== Usage
link:rust/http/README.adoc#usage[Rust - http]
[#rust-https]
=== Rust - https[source,shell]
----
$ cd rust/https
$ scripts/docker_build.sh -t rust-https
$ docker run --rm de.sdavids/sdavids-docker-healthcheck:rust-https sh -c 'du -kh /usr/local/bin/healthcheck'
480.0K /usr/local/bin/healthcheck
----==== Usage
link:rust/https/README.adoc#usage[Rust - https]
[#shell-nc]
=== shell - nc[NOTE]
====
This healthcheck will only check if the daemon's port is reachable, i.e. it will not check the HTTP body or status code of the response.
====[source,shell]
----
$ cd shell/nc
$ scripts/docker_build.sh -t shell-nc
$ docker run --rm de.sdavids/sdavids-docker-healthcheck:shell-nc sh -c 'du -kh /usr/local/bin/healthcheck'
4.0K /usr/local/bin/healthcheck
----==== Usage
link:shell/nc/README.adoc#usage[shell - nc]
=== curl
[#curl-alpine]
==== alpine[source,shell]
----
$ docker run --rm alpine:3.21.0 sh -c "apk --no-cache --quiet --no-progress add curl=8.11.0-r2 && ldd /usr/bin/curl | awk '{ print $ 3}' | xargs du -ckshL /usr/bin/curl"
260.0K /usr/bin/curl
652.0K /usr/lib/libcurl.so.4
132.0K /usr/lib/libz.so.1
708.0K /lib/ld-musl-aarch64.so.1
260.0K /usr/lib/libcares.so.2
196.0K /usr/lib/libnghttp2.so.14
196.0K /usr/lib/libidn2.so.0
132.0K /usr/lib/libpsl.so.5
848.0K /usr/lib/libssl.so.3
3.9M /usr/lib/libcrypto.so.3
644.0K /usr/lib/libzstd.so.1
68.0K /usr/lib/libbrotlidec.so.1
1.7M /usr/lib/libunistring.so.5
196.0K /usr/lib/libbrotlicommon.so.1
9.8M total
----[#curl-alpaquita-linux-base]
==== alpaquita-linux-base[source,shell]
----
$ docker run --rm bellsoft/alpaquita-linux-base:stream-musl-240821 sh -c "apk --no-cache --quiet --no-progress add curl=8.9.1-r0 && ldd /usr/bin/curl | awk '{ print $ 3}' | xargs du -ckshL /usr/bin/curl"
236.0K /usr/bin/curl
612.0K /lib/libcurl.so.4
100.0K /lib/libz.so.1
788.0K /lib/ld-musl-x86_64.so.1
160.0K /lib/libcares.so.2
140.0K /lib/libnghttp2.so.14
196.0K /lib/libidn2.so.0
76.0K /lib/libpsl.so.5
780.0K /lib/libssl.so.3
4.3M /lib/libcrypto.so.3
1.1M /lib/libzstd.so.1
56.0K /lib/libbrotlidec.so.1
1.6M /lib/libunistring.so.5
140.0K /lib/libbrotlicommon.so.1
10.3M total
----[#curl-debian]
==== debian[source,shell]
----
$ docker run --rm debian:12.8-slim sh -c "apt-get -qq update && apt-get -qq install -y curl=7.88.1-10+deb12u8 >/dev/null 2>&1 && ldd /usr/bin/curl | awk '{ print $ 3}' | xargs du -ckshL /usr/bin/curl"
324K /usr/bin/curl
716K /lib/aarch64-linux-gnu/libcurl.so.4
132K /lib/aarch64-linux-gnu/libz.so.1
1.6M /lib/aarch64-linux-gnu/libc.so.6
196K /lib/aarch64-linux-gnu/libnghttp2.so.14
196K /lib/aarch64-linux-gnu/libidn2.so.0
116K /lib/aarch64-linux-gnu/librtmp.so.1
244K /lib/aarch64-linux-gnu/libssh2.so.1
132K /lib/aarch64-linux-gnu/libpsl.so.5
720K /lib/aarch64-linux-gnu/libssl.so.3
4.3M /lib/aarch64-linux-gnu/libcrypto.so.3
328K /lib/aarch64-linux-gnu/libgssapi_krb5.so.2
388K /lib/aarch64-linux-gnu/libldap-2.5.so.0
68K /lib/aarch64-linux-gnu/liblber-2.5.so.0
644K /lib/aarch64-linux-gnu/libzstd.so.1
68K /lib/aarch64-linux-gnu/libbrotlidec.so.1
1.7M /lib/aarch64-linux-gnu/libunistring.so.2
2.2M /lib/aarch64-linux-gnu/libgnutls.so.30
324K /lib/aarch64-linux-gnu/libhogweed.so.6
324K /lib/aarch64-linux-gnu/libnettle.so.8
520K /lib/aarch64-linux-gnu/libgmp.so.10
908K /lib/aarch64-linux-gnu/libkrb5.so.3
196K /lib/aarch64-linux-gnu/libk5crypto.so.3
68K /lib/aarch64-linux-gnu/libcom_err.so.2
68K /lib/aarch64-linux-gnu/libkrb5support.so.0
132K /lib/aarch64-linux-gnu/libsasl2.so.2
132K /lib/aarch64-linux-gnu/libbrotlicommon.so.1
1.3M /lib/aarch64-linux-gnu/libp11-kit.so.0
132K /lib/aarch64-linux-gnu/libtasn1.so.6
68K /lib/aarch64-linux-gnu/libkeyutils.so.1
68K /lib/aarch64-linux-gnu/libresolv.so.2
68K /lib/aarch64-linux-gnu/libffi.so.8
19M total
----=== wget
[#wget-alpine]
==== alpine[source,shell]
----
$ docker run --rm alpine:3.21.0 sh -c "apk --no-cache --quiet --no-progress add wget=1.25.0-r0 && ldd /usr/bin/wget | awk '{ print $ 3}' | xargs du -ckshL /usr/bin/wget"
468.0K /usr/bin/wget
644.0K /usr/lib/libpcre2-8.so.0
196.0K /usr/lib/libidn2.so.0
848.0K /usr/lib/libssl.so.3
3.9M /usr/lib/libcrypto.so.3
132.0K /usr/lib/libz.so.1
708.0K /lib/ld-musl-aarch64.so.1
1.7M /usr/lib/libunistring.so.5
8.6M total
----[#wget-alpaquita-linux-base]
==== alpaquita-linux-base[source,shell]
----
$ docker run --rm bellsoft/alpaquita-linux-base:stream-musl-240821 sh -c "apk --no-cache --quiet --no-progress add wget=1.24.5-r0 && ldd /usr/bin/wget | awk '{ print $ 3}' | xargs du -ckshL /usr/bin/wget"
404.0K /usr/bin/wget
684.0K /lib/libpcre2-8.so.0
196.0K /lib/libidn2.so.0
780.0K /lib/libssl.so.3
4.3M /lib/libcrypto.so.3
100.0K /lib/libz.so.1
788.0K /lib/ld-musl-x86_64.so.1
1.6M /lib/libunistring.so.5
8.8M total
----[#wget-debian]
==== debian[source,shell]
----
$ docker run --rm debian:12.8-slim sh -c "apt-get -qq update && apt-get -qq install -y wget=1.21.3-1+b1 >/dev/null 2>&1 && ldd /usr/bin/wget | awk '{ print $ 3}' | xargs du -ckshL /usr/bin/wget"
520K /usr/bin/wget
580K /lib/aarch64-linux-gnu/libpcre2-8.so.0
68K /lib/aarch64-linux-gnu/libuuid.so.1
196K /lib/aarch64-linux-gnu/libidn2.so.0
324K /lib/aarch64-linux-gnu/libnettle.so.8
2.2M /lib/aarch64-linux-gnu/libgnutls.so.30
132K /lib/aarch64-linux-gnu/libz.so.1
132K /lib/aarch64-linux-gnu/libpsl.so.5
1.6M /lib/aarch64-linux-gnu/libc.so.6
1.7M /lib/aarch64-linux-gnu/libunistring.so.2
1.3M /lib/aarch64-linux-gnu/libp11-kit.so.0
132K /lib/aarch64-linux-gnu/libtasn1.so.6
324K /lib/aarch64-linux-gnu/libhogweed.so.6
520K /lib/aarch64-linux-gnu/libgmp.so.10
68K /lib/aarch64-linux-gnu/libffi.so.8
9.7M total
----== License
Apache License, Version 2.0 (link:LICENSES/Apache-2.0.txt[Apache-2.0.txt] or {uri-apache-license}).
== Contribution
See link:CONTRIBUTING{outfilesuffix}[].
== Code of Conduct
We abide by the {uri-contributor-covenant}[Contributor Covenant, Version 2.1] and ask that you do as well.
For more information, please see link:CODE_OF_CONDUCT.md[Code of Conduct].
== Development
=== Format Source Code
[source,shell]
----
$ scripts/format.sh
----=== Lint Source Code
[source,shell]
----
$ scripts/lint.sh
----== Development Environment Setup
[IMPORTANT]
====
After initializing this repository you need to install the Git hooks via:[source,shell]
----
$ git config core.hooksPath .githooks
----And configure the https://git-scm.com/docs/git-config#Documentation/git-config.txt-blameignoreRevsFile[ignore-revs-file]:
[source,shell]
----
git config blame.ignoreRevsFile .git-blame-ignore-revs
----
======= Installation
==== Docker
Install {docker-install-url}[Docker].
==== easyrsa
[IMPORTANT]
====
Ensure that you install version `3.1.7` and not `3.2.0`!Version `3.2.0` is an incompatible https://github.com/OpenVPN/easy-rsa/releases/tag/v3.2.0[development snapshot release].
========= Linux
Install {easyrsa-install-url}[easyrsa].
===== Mac
[WARNING]
====
Unfortunately, homebrew provides `easy-rsa` version `3.2.0` at this point in time (August 2024).
====[source,shell]
----
$ curl -L https://github.com/OpenVPN/easy-rsa/releases/download/v3.1.7/EasyRSA-3.1.7.tgz -o ~/Downloads/easy-rsa.tgz
$ tar -xzf ~/Downloads/easy-rsa.tgz -C ~/.local/share
$ mv ~/.local/share/EasyRSA-3.1.7 ~/.local/share/easyrsa
$ ln -s ~/.local/share/easyrsa/easyrsa ~/.local/bin/easyrsa
$ rm ~/Downloads/easy-rsa.tgz
----==== Go
Install {go-install-url}[Go].
==== golangci-lint
Install {golangci-install-url}[golangci-lint].
==== hadolint
===== Linux
Install {hadolint-install-url}[hadolint].
===== Mac
[source,shell]
----
$ brew install hadolint
----==== Node Version Manager
Install {fnm-install-url}[fnm] or {nvm-install-url}[NVM].
===== fnm
.~/.zprofile
[source,shell]
----
if command -v fnm > /dev/null 2>&1; then
eval "$(fnm env --use-on-cd)"
fi
----===== nvm
.~/.zshrc
[source,shell]
----
export NVM_DIR="${HOME}/.nvm"[ -s "${NVM_DIR}/nvm.sh" ] && . "${NVM_DIR}/nvm.sh"
[ -s "${NVM_DIR}/bash_completion" ] && . "${NVM_DIR}/bash_completion"if command -v nvm > /dev/null 2>&1; then
autoload -U add-zsh-hook
load-nvmrc() {
local nvmrc_path="$(nvm_find_nvmrc)"
if [ -n "${nvmrc_path}" ]; then
local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")
if [ "${nvmrc_node_version}" = "N/A" ]; then
nvm install
elif [ "${nvmrc_node_version}" != "$(nvm version)" ]; then
nvm use
fi
elif [ -n "$(PWD=$OLDPWD nvm_find_nvmrc)" ] && [ "$(nvm version)" != "$(nvm version default)" ]; then
echo "Reverting to nvm default version"
nvm use default
fi
}add-zsh-hook chpwd load-nvmrc
load-nvmrc
fi
----==== Rust
Install {rust-install-url}[Rust].
[source,shell]
----
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable --component rust-analyzer
----==== shellcheck
===== Linux
[source,shell]
----
$ sudo apt-get install shellcheck
----===== Mac
[source,shell]
----
$ brew install shellcheck
----==== shfmt
===== Linux
[source,shell]
----
$ sudo apt-get install shfmt
----===== Mac
[source,shell]
----
$ brew install shfmt
----==== yamllint
===== Linux
[source,shell]
----
$ sudo apt-get install yamllint
----===== Mac
[source,shell]
----
$ brew install yamllint
----[#ide]
=== IDESee link:CODING_STYLE.adoc#ide-configuration[IDE Configuration].