forked from marcoambrosini/aio-stalwart
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test: Create test script to validate script (#21)
* Update test.sh Signed-off-by: Jean-Yves <[email protected]> * Update test.sh Signed-off-by: Jean-Yves <[email protected]> * Add healthcheck.sh Signed-off-by: Jean-Yves <[email protected]> * fix curl version Signed-off-by: Jean-Yves <[email protected]> --------- Signed-off-by: Jean-Yves <[email protected]>
- Loading branch information
Showing
3 changed files
with
47 additions
and
10 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,3 @@ | ||
#!/bin/bash | ||
|
||
test "$(curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:10003/healthz/ready)" == "200" |
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,16 +1,44 @@ | ||
#!/bin/bash | ||
|
||
# NOTE: This script use podman instead of docker ! | ||
docker() { | ||
podman "$@" | ||
STEP_NB=5 | ||
STEP_I=0 | ||
print_step() { | ||
STEP_I=$((STEP_I+1)) | ||
echo "" | ||
echo "=====[$STEP_I/$STEP_NB]=====" | ||
echo "$3" | ||
} | ||
|
||
# | ||
# Work in progress | ||
# | ||
|
||
IMAGE=$(docker build . | tee /dev/tty | tail -n 1) | ||
NC_DOMAIN="example.com" | ||
CADDY="my_caddy_example_com" | ||
STALWART="my_stalwart_example_com" | ||
SSL_PATH="caddy/certificates/acme-v02.api.letsencrypt.org-directory/mail.$NC_DOMAIN" | ||
PASSWORD="password" | ||
|
||
echo "Script generated :" | ||
print_step "Build Docker Image" | ||
docker container rm $STALWART -f | ||
docker volume rm $STALWART $CADDY -f | ||
docker build -t "$STALWART" . | ||
echo "docker run --rm -v $STALWART:/opt/stalwart-mail -v $CADDY:/caddy:ro --env "NC_DOMAIN=$NC_DOMAIN" $STALWART stalwart-cli --help" | ||
|
||
docker run --rm --env AUTO_CONFIG_TLS_CERT=OFF "$IMAGE" cat /opt/stalwart-mail/etc/config.toml | ||
|
||
print_step "Generate prepare env" | ||
docker run --rm -v $CADDY:/ssl --entrypoint /bin/mkdir $STALWART -p "/ssl/$SSL_PATH/" | ||
docker run --rm -v $CADDY:/ssl --entrypoint /bin/openssl $STALWART req -x509 -noenc -subj "/C=AA/ST=A/O=A/CN=mail.$NC_DOMAIN" -keyout "/ssl/$SSL_PATH/mail.$NC_DOMAIN.key" -out "/ssl/$SSL_PATH/mail.$NC_DOMAIN.crt" | ||
|
||
print_step "Run container" | ||
docker run --rm -v $CADDY:/caddy:ro -v $STALWART:/opt/stalwart-mail \ | ||
-e "NC_DOMAIN=$NC_DOMAIN" \ | ||
-e "STALWART_USER_PASS=$PASSWORD" \ | ||
--name $STALWART $STALWART & | ||
STALWART_PID=$! | ||
sleep 11 | ||
|
||
print_step "Test" | ||
docker exec $STALWART stalwart-cli -u http://127.0.0.1:10003 -c "admin:$PASSWORD" server list-config | sort > out.txt | ||
|
||
print_step "Remove volume" | ||
docker container rm $STALWART -f | ||
docker volume rm $STALWART $CADDY | ||
tail --pid=$STALWART_PID -f /dev/null |