-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add healthchecks and scripts for stencil population during build
- Loading branch information
Showing
14 changed files
with
250 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Use Memcached from the Debian Linux project | ||
FROM memcached:latest | ||
|
||
# Need to undo the misdeeds of Memcached developers | ||
USER root | ||
|
||
# Add labels for metadata | ||
LABEL maintainer="Dhruv Bhanushali <https://dhruvkb.github.io/>" | ||
|
||
# Install dependencies | ||
RUN apt-get update \ | ||
&& apt-get install -y netcat \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Undo our undoing of Memcache's misdeeds, just in case they are important | ||
USER memcache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Use Postgres from the Debian Linux project | ||
FROM postgres:latest | ||
|
||
# Add labels for metadata | ||
LABEL maintainer="Dhruv Bhanushali <https://dhruvkb.github.io/>" | ||
|
||
# Install the health check script | ||
COPY checkhealth.sh /usr/local/bin/checkhealth |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
set -eo pipefail | ||
|
||
HOST="$(hostname -i || echo '127.0.0.1')" | ||
USER="${POSTGRES_USER:-postgres}" | ||
DB="${POSTGRES_DB:-postgres}" | ||
|
||
export PGPASSWORD="${POSTGRES_PASSWORD:-}" | ||
|
||
# A Postgres node is considered healthy if | ||
# * it connects with the given username and password | ||
# * it returns 1 for a 'SELECT 1' SQL query | ||
|
||
args=( | ||
# Force postgres to not use the local socket and test external connectivity | ||
--host "$HOST" | ||
--username "$USER" | ||
--dbname "$DB" | ||
--quiet --no-align --tuples-only | ||
) | ||
|
||
if select="$(echo 'SELECT 1' | psql "${args[@]}")" && [ "$select" = '1' ]; then | ||
exit 0 | ||
fi | ||
|
||
exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
POSTGRES_DB= | ||
POSTGRES_USER= | ||
POSTGRES_PASSWORD= | ||
POSTGRES_DB=[[db]] | ||
POSTGRES_USER=[[user]] | ||
POSTGRES_PASSWORD=[[password]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Use RabbitMQ from the Debian Linux project | ||
FROM rabbitmq:management | ||
|
||
# Add labels for metadata | ||
LABEL maintainer="Dhruv Bhanushali <https://dhruvkb.github.io/>" | ||
|
||
# Install the health check script | ||
COPY checkhealth.sh /usr/local/bin/checkhealth |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
set -eo pipefail | ||
|
||
# A RabbitMQ node is considered healthy if | ||
# * the rabbit app finished booting & it's running | ||
# * there are no alarms | ||
# * there is at least 1 active listener | ||
|
||
rabbitmqctl eval ' | ||
{ true, rabbit_app_booted_and_running } = { rabbit:is_booted(node()), rabbit_app_booted_and_running }, | ||
{ [], no_alarms } = { rabbit:alarms(), no_alarms }, | ||
[] /= rabbit_networking:active_listeners(), | ||
rabbitmq_node_is_healthy. | ||
' || exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
RABBITMQ_DEFAULT_USER= | ||
RABBITMQ_DEFAULT_PASS= | ||
RABBITMQ_DEFAULT_USER=[[user]] | ||
RABBITMQ_DEFAULT_PASS=[[pass]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Use Redis from the Debian Linux project | ||
FROM redis:latest | ||
|
||
# Add labels for metadata | ||
LABEL maintainer="Dhruv Bhanushali <https://dhruvkb.github.io/>" | ||
|
||
# Install the health check script | ||
COPY checkhealth.sh /usr/local/bin/checkhealth |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
set -eo pipefail | ||
|
||
host="$(hostname -i || echo '127.0.0.1')" | ||
|
||
# A Redis node is considered healthy if | ||
# * it responds 'PONG' to every ping | ||
|
||
if ping="$(redis-cli -h "$host" ping)" && [ "$ping" = 'PONG' ]; then | ||
exit 0 | ||
fi | ||
|
||
exit 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
# Enter the Memcached Docker folder | ||
cd memcached/ | ||
|
||
# Build the container from the Memcached folder and tag it | ||
TIMESTAMP=$(date +"%s") | ||
|
||
docker build \ | ||
--tag omniport-memcached:${TIMESTAMP} \ | ||
--tag omniport-memcached:latest \ | ||
. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
|
||
# Enter the Postgres Docker folder | ||
cd postgres/ | ||
|
||
read -p "Rebuild database .env file? (y/N): " REBUILD | ||
if [ $REBUILD == 'Y' -o $REBUILD == 'y' ]; then | ||
read -p "Enter the name of the database: " DB | ||
read -p "Enter the user of the database: " USER | ||
read -p "Enter the password of the database: " PASSWORD | ||
|
||
# Perform text substitution to generate the new .env file | ||
printf "Writing database environment file... " | ||
cp database_stencil.env database.env | ||
sed -i "s/\[\[db\]\]/${DB}/g" database.env | ||
sed -i "s/\[\[user\]\]/${USER}/g" database.env | ||
sed -i "s/\[\[password\]\]/${PASSWORD}/g" database.env | ||
printf "done\n" | ||
fi | ||
|
||
# Build the container from the Postgres folder and tag it | ||
TIMESTAMP=$(date +"%s") | ||
|
||
docker build \ | ||
--tag omniport-postgres:${TIMESTAMP} \ | ||
--tag omniport-postgres:latest \ | ||
. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
|
||
# Enter the RabbitMQ Docker folder | ||
cd rabbitmq/ | ||
|
||
read -p "Rebuild message broker .env file? (y/N): " REBUILD | ||
if [ $REBUILD == 'Y' -o $REBUILD == 'y' ]; then | ||
read -p "Enter the user of the message broker: " USER | ||
read -p "Enter the pass of the message broker: " PASS | ||
|
||
# Perform text substitution to generate the new .env file | ||
printf "Writing message broker environment file... " | ||
cp message_broker_stencil.env message_broker.env | ||
sed -i "s/\[\[user\]\]/${USER}/g" message_broker.env | ||
sed -i "s/\[\[pass\]\]/${PASS}/g" message_broker.env | ||
printf "done\n" | ||
fi | ||
|
||
# Build the container from the RabbitMQ folder and tag it | ||
TIMESTAMP=$(date +"%s") | ||
|
||
docker build \ | ||
--tag omniport-rabbitmq:${TIMESTAMP} \ | ||
--tag omniport-rabbitmq:latest \ | ||
. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
# Enter the Redis Docker folder | ||
cd redis/ | ||
|
||
# Build the container from the Redis folder and tag it | ||
TIMESTAMP=$(date +"%s") | ||
|
||
docker build \ | ||
--tag omniport-redis:${TIMESTAMP} \ | ||
--tag omniport-redis:latest \ | ||
. |