forked from Infisical/infisical
-
Notifications
You must be signed in to change notification settings - Fork 0
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 test image before push
- Loading branch information
1 parent
8896e12
commit 752ebaa
Showing
11 changed files
with
389 additions
and
93 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
version: '3' | ||
|
||
services: | ||
backend: | ||
container_name: infisical-backend-test | ||
restart: unless-stopped | ||
depends_on: | ||
- mongo | ||
image: infisical/backend:test | ||
command: npm run start | ||
environment: | ||
- NODE_ENV=production | ||
- MONGO_URL=mongodb://test:example@mongo:27017/?authSource=admin | ||
- MONGO_USERNAME=test | ||
- MONGO_PASSWORD=example | ||
networks: | ||
- infisical-test | ||
|
||
mongo: | ||
container_name: infisical-mongo-test | ||
image: mongo | ||
restart: always | ||
environment: | ||
- MONGO_INITDB_ROOT_USERNAME=test | ||
- MONGO_INITDB_ROOT_PASSWORD=example | ||
networks: | ||
- infisical-test | ||
|
||
networks: | ||
infisical-test: |
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 @@ | ||
# Name of the target container to check | ||
container_name="$1" | ||
# Timeout in seconds. Default: 60 | ||
timeout=$((${2:-60})); | ||
|
||
if [ -z $container_name ]; then | ||
echo "No container name specified"; | ||
exit 1; | ||
fi | ||
|
||
echo "Container: $container_name"; | ||
echo "Timeout: $timeout sec"; | ||
|
||
try=0; | ||
is_healthy="false"; | ||
while [ $is_healthy != "true" ]; | ||
do | ||
try=$(($try + 1)); | ||
printf "■"; | ||
is_healthy=$(docker inspect --format='{{json .State.Health}}' $container_name | jq '.Status == "healthy"'); | ||
sleep 1; | ||
if [[ $try -eq $timeout ]]; then | ||
echo " Container was not ready within timeout"; | ||
exit 1; | ||
fi | ||
done |
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
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 @@ | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
/* eslint-disable no-console */ | ||
/* eslint-disable no-undef */ | ||
const http = require('http'); | ||
const PORT = process.env.PORT || 4000; | ||
const options = { | ||
host: 'localhost', | ||
port: PORT, | ||
timeout: 2000, | ||
path: '/healthcheck' | ||
}; | ||
|
||
const healthCheck = http.request(options, (res) => { | ||
console.log(`HEALTHCHECK STATUS: ${res.statusCode}`); | ||
if (res.statusCode == 200) { | ||
process.exit(0); | ||
} else { | ||
process.exit(1); | ||
} | ||
}); | ||
|
||
healthCheck.on('error', function (err) { | ||
console.error(err); | ||
process.exit(1); | ||
}); | ||
|
||
healthCheck.end(); |
Oops, something went wrong.