From 66a68f6d2258a0c5b262ee7687217334e1daffdc Mon Sep 17 00:00:00 2001 From: H3npi Date: Tue, 27 Aug 2019 11:23:55 +0200 Subject: [PATCH 1/2] Adds Healthcheck for all docker container --- docker/aarch64/mysql/Dockerfile | 4 ++++ docker/aarch64/sqlite/Dockerfile | 4 ++++ docker/amd64/mysql/Dockerfile | 4 ++++ docker/amd64/mysql/Dockerfile.alpine | 4 ++++ docker/amd64/sqlite/Dockerfile | 4 ++++ docker/amd64/sqlite/Dockerfile.alpine | 5 +++++ docker/armv6/mysql/Dockerfile | 4 ++++ docker/armv6/sqlite/Dockerfile | 4 ++++ docker/armv7/mysql/Dockerfile | 4 ++++ docker/armv7/sqlite/Dockerfile | 4 ++++ docker/healthcheck.sh | 8 ++++++++ 11 files changed, 49 insertions(+) create mode 100644 docker/healthcheck.sh diff --git a/docker/aarch64/mysql/Dockerfile b/docker/aarch64/mysql/Dockerfile index 852fa2e1..1e48e0c0 100644 --- a/docker/aarch64/mysql/Dockerfile +++ b/docker/aarch64/mysql/Dockerfile @@ -97,5 +97,9 @@ COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault COPY --from=build /app/target/aarch64-unknown-linux-gnu/release/bitwarden_rs . +COPY docker/healthcheck.sh ./healthcheck.sh + +HEALTHCHECK --interval=10s --timeout=1s CMD bash healthcheck.sh || exit 1 + # Configures the startup! CMD ["./bitwarden_rs"] \ No newline at end of file diff --git a/docker/aarch64/sqlite/Dockerfile b/docker/aarch64/sqlite/Dockerfile index ed978dd9..9185b3d4 100644 --- a/docker/aarch64/sqlite/Dockerfile +++ b/docker/aarch64/sqlite/Dockerfile @@ -97,5 +97,9 @@ COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault COPY --from=build /app/target/aarch64-unknown-linux-gnu/release/bitwarden_rs . +COPY docker/healthcheck.sh ./healthcheck.sh + +HEALTHCHECK --interval=10s --timeout=1s CMD bash healthcheck.sh || exit 1 + # Configures the startup! CMD ["./bitwarden_rs"] \ No newline at end of file diff --git a/docker/amd64/mysql/Dockerfile b/docker/amd64/mysql/Dockerfile index 19f771ea..8b0d03e5 100644 --- a/docker/amd64/mysql/Dockerfile +++ b/docker/amd64/mysql/Dockerfile @@ -94,5 +94,9 @@ COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault COPY --from=build app/target/release/bitwarden_rs . +COPY docker/healthcheck.sh ./healthcheck.sh + +HEALTHCHECK --interval=10s --timeout=1s CMD bash healthcheck.sh || exit 1 + # Configures the startup! CMD ["./bitwarden_rs"] \ No newline at end of file diff --git a/docker/amd64/mysql/Dockerfile.alpine b/docker/amd64/mysql/Dockerfile.alpine index 10f7ae0a..9ad5573a 100644 --- a/docker/amd64/mysql/Dockerfile.alpine +++ b/docker/amd64/mysql/Dockerfile.alpine @@ -76,5 +76,9 @@ COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault COPY --from=build /app/target/x86_64-unknown-linux-musl/release/bitwarden_rs . +COPY docker/healthcheck.sh ./healthcheck.sh + +HEALTHCHECK --interval=10s --timeout=1s CMD bash healthcheck.sh || exit 1 + # Configures the startup! CMD ["./bitwarden_rs"] \ No newline at end of file diff --git a/docker/amd64/sqlite/Dockerfile b/docker/amd64/sqlite/Dockerfile index 40be616e..2395e24d 100644 --- a/docker/amd64/sqlite/Dockerfile +++ b/docker/amd64/sqlite/Dockerfile @@ -94,5 +94,9 @@ COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault COPY --from=build app/target/release/bitwarden_rs . +COPY docker/healthcheck.sh ./healthcheck.sh + +HEALTHCHECK --interval=10s --timeout=1s CMD bash healthcheck.sh || exit 1 + # Configures the startup! CMD ["./bitwarden_rs"] diff --git a/docker/amd64/sqlite/Dockerfile.alpine b/docker/amd64/sqlite/Dockerfile.alpine index 2f0bd58b..2724b56f 100644 --- a/docker/amd64/sqlite/Dockerfile.alpine +++ b/docker/amd64/sqlite/Dockerfile.alpine @@ -76,5 +76,10 @@ COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault COPY --from=build /app/target/x86_64-unknown-linux-musl/release/bitwarden_rs . +COPY docker/healthcheck.sh ./healthcheck.sh + +HEALTHCHECK --interval=10s --timeout=1s CMD bash healthcheck.sh || exit 1 + + # Configures the startup! CMD ["./bitwarden_rs"] diff --git a/docker/armv6/mysql/Dockerfile b/docker/armv6/mysql/Dockerfile index 796d4072..ab5490ee 100644 --- a/docker/armv6/mysql/Dockerfile +++ b/docker/armv6/mysql/Dockerfile @@ -97,5 +97,9 @@ COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault COPY --from=build /app/target/arm-unknown-linux-gnueabi/release/bitwarden_rs . +COPY docker/healthcheck.sh ./healthcheck.sh + +HEALTHCHECK --interval=10s --timeout=1s CMD bash healthcheck.sh || exit 1 + # Configures the startup! CMD ["./bitwarden_rs"] diff --git a/docker/armv6/sqlite/Dockerfile b/docker/armv6/sqlite/Dockerfile index 7c1963da..bc4c3748 100644 --- a/docker/armv6/sqlite/Dockerfile +++ b/docker/armv6/sqlite/Dockerfile @@ -97,5 +97,9 @@ COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault COPY --from=build /app/target/arm-unknown-linux-gnueabi/release/bitwarden_rs . +COPY docker/healthcheck.sh ./healthcheck.sh + +HEALTHCHECK --interval=10s --timeout=1s CMD bash healthcheck.sh || exit 1 + # Configures the startup! CMD ["./bitwarden_rs"] diff --git a/docker/armv7/mysql/Dockerfile b/docker/armv7/mysql/Dockerfile index ce7f5137..ee0ad028 100644 --- a/docker/armv7/mysql/Dockerfile +++ b/docker/armv7/mysql/Dockerfile @@ -98,5 +98,9 @@ COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault COPY --from=build /app/target/armv7-unknown-linux-gnueabihf/release/bitwarden_rs . +COPY docker/healthcheck.sh ./healthcheck.sh + +HEALTHCHECK --interval=10s --timeout=1s CMD bash healthcheck.sh || exit 1 + # Configures the startup! CMD ["./bitwarden_rs"] \ No newline at end of file diff --git a/docker/armv7/sqlite/Dockerfile b/docker/armv7/sqlite/Dockerfile index 48cf56b2..6ed8e1ab 100644 --- a/docker/armv7/sqlite/Dockerfile +++ b/docker/armv7/sqlite/Dockerfile @@ -97,5 +97,9 @@ COPY Rocket.toml . COPY --from=vault /web-vault ./web-vault COPY --from=build /app/target/armv7-unknown-linux-gnueabihf/release/bitwarden_rs . +COPY docker/healthcheck.sh ./healthcheck.sh + +HEALTHCHECK --interval=10s --timeout=1s CMD bash healthcheck.sh || exit 1 + # Configures the startup! CMD ["./bitwarden_rs"] \ No newline at end of file diff --git a/docker/healthcheck.sh b/docker/healthcheck.sh new file mode 100644 index 00000000..08e9e8b1 --- /dev/null +++ b/docker/healthcheck.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env sh + +if [ -z "$ROCKET_TLS"] +then + curl --fail http://localhost/alive || exit 1 +else + curl --fail https://localhost/alive || exit 1 +fi \ No newline at end of file From cce3ce816c1e21861631252d466fe014ab4980e7 Mon Sep 17 00:00:00 2001 From: H3npi Date: Wed, 4 Sep 2019 09:12:53 +0200 Subject: [PATCH 2/2] Adds environment port to curl healthcheck --- docker/healthcheck.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/healthcheck.sh b/docker/healthcheck.sh index 08e9e8b1..7b4e3fc2 100644 --- a/docker/healthcheck.sh +++ b/docker/healthcheck.sh @@ -2,7 +2,7 @@ if [ -z "$ROCKET_TLS"] then - curl --fail http://localhost/alive || exit 1 + curl --fail http://localhost:${ROCKET_PORT:-"80"}/alive || exit 1 else - curl --fail https://localhost/alive || exit 1 + curl --fail https://localhost:${ROCKET_PORT:-"80"}/alive || exit 1 fi \ No newline at end of file