import files

This commit is contained in:
Yann Autissier
2021-02-09 17:05:00 +01:00
parent f5c4576411
commit 44a6d37ba5
425 changed files with 23195 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
FROM consul:1.6.1 as dist
ARG DOCKER_BUILD_DIR
LABEL maintainer 1001Pharmacies <technique+docker@1001pharmacies.com>
# install docker
RUN apk add --no-cache bash docker gawk sudo \
&& echo "consul ALL=(root) NOPASSWD: /usr/local/bin/container-list-status" >> /etc/sudoers
# install goss
ADD https://github.com/aelsabbahy/goss/releases/latest/download/goss-linux-amd64 /usr/bin/goss
RUN chmod +rx /usr/bin/goss
COPY ${DOCKER_BUILD_DIR}/goss.yml /tests/goss.yml
COPY ${DOCKER_BUILD_DIR}/container-check-status ${DOCKER_BUILD_DIR}/container-list-status /usr/local/bin/
RUN chmod +rx /usr/local/bin/container-check-status /usr/local/bin/container-list-status
HEALTHCHECK CMD goss -g /tests/goss.yml validate --format tap
FROM dist as local
ARG DOCKER_BUILD_DIR
FROM local as debug
ARG DOCKER_BUILD_DIR
FROM local as tests
ARG DOCKER_BUILD_DIR
FROM tests as preprod
ARG DOCKER_BUILD_DIR
FROM preprod as prod
ARG DOCKER_BUILD_DIR
+24
View File
@@ -0,0 +1,24 @@
#!/bin/bash
# https://github.com/hashicorp/consul/issues/3182
if [ $# -ne 1 ]; then
>&2 echo "Invalid parameters: '$@'"
echo "USAGE: $0 <container-id|container-name|container-hostname|container-ip>"
exit 2
fi
CONTAINER_ID="$1"
# CONTAINER_STATUS=$(sudo container-list-status |awk '/\<'${CONTAINER_ID}'\>/ {print $NF}')
read -d "\n" CONTAINER_STATUS CONTAINER_OUTPUT <<< $(sudo container-list-status |awk 'BEGIN {FS="\t"; RS="\0"} /\<'${CONTAINER_ID}'\>/ {print $1,$NF}')
echo ${CONTAINER_STATUS:-undefined}: "${CONTAINER_OUTPUT}"
case "${CONTAINER_STATUS}" in
healthy)
exit 0
;;
starting)
exit 1
;;
esac
exit 2
+5
View File
@@ -0,0 +1,5 @@
#!/bin/sh
# https://github.com/hashicorp/consul/issues/3182
# docker inspect -f '{{.Id}} {{.Config.Hostname}} {{.Name}} {{range .NetworkSettings.Networks}}{{.IPAddress}} {{end}} {{.State.Health.Status}}' $(docker ps -q) 2>/dev/null
docker container inspect --format '{{.State.Health.Status}}{{printf "\t"}}{{.Id}}{{printf "\t"}}{{.Name}}{{printf "\t"}}{{.Config.Hostname}}{{printf "\t"}}{{range .NetworkSettings.Networks}}{{.IPAddress}}{{printf "\t"}}{{end}}{{printf "\t"}}{{$output := ""}}{{range .State.Health.Log}}{{$output = .Output}}{{end}}{{$output}}{{printf "%c" 0}}' $(docker ps -q) 2>/dev/null
+18
View File
@@ -0,0 +1,18 @@
file:
/bin/consul:
exists: true
filetype: file
mode: "0755"
owner: root
sha256: 99bacb9dc1c6b7eaff75326e4ae0396ac2f29eb8ab95bc2124c718d926c3aef4
port:
tcp6:8500:
listening: true
ip:
process:
consul:
running: true
user:
consul:
exists: true
uid: 100