build: add makefile, dockerfile, ci and development stack
- build: add makefile, dockerfile, ci and development stack - feat(config): add environment configuration and logger - feat(server): add server lifecycle with health and version routes - feat(db): add connection, contract check, migrations and stores - feat(cli): add command dispatch and user management - test(db): add integration tests against mysql
This commit is contained in:
1 parent
45d1e307c6
commit
7089a6f408
46 files changed
+8456
No files matched your search
Executable
+42
@@ -0,0 +1,42 @@
|
||||
#!/bin/sh
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
# Copyright (C) 2026 Bryan Joshua Pedini
|
||||
|
||||
set -eu
|
||||
cd "$(dirname "$0")/.."
|
||||
IT_ID=${IT_ID:-$$}
|
||||
IT_NAME=${IT_NAME:-cdwu-it-${IT_ID}}
|
||||
MYSQL_IMAGE=${MYSQL_IMAGE:-mysql:8.4}
|
||||
network="${IT_NAME}"
|
||||
mysql="${IT_NAME}-mysql"
|
||||
tests="${IT_NAME}-tests"
|
||||
image="${IT_NAME}:integration"
|
||||
root_password=$(od -An -tx1 -N16 /dev/urandom | tr -d ' \n')
|
||||
cleanup() {
|
||||
status=$?
|
||||
if [ "$status" -ne 0 ]; then
|
||||
docker logs --tail 80 "$mysql" >&2 2>&1 || true
|
||||
fi
|
||||
docker rm --force "$tests" "$mysql" >/dev/null 2>&1 || true
|
||||
docker network rm "$network" >/dev/null 2>&1 || true
|
||||
docker image rm --force "$image" >/dev/null 2>&1 || true
|
||||
exit "$status"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
trap 'exit 130' INT TERM
|
||||
docker build --target integration --file dockerfile --tag "$image" .
|
||||
docker network create --internal "$network" >/dev/null
|
||||
docker run --detach --name "$mysql" --network "$network" --network-alias mysql \
|
||||
--env MYSQL_ROOT_PASSWORD="$root_password" "$MYSQL_IMAGE" >/dev/null
|
||||
attempt=0
|
||||
until docker exec --env MYSQL_PWD="$root_password" "$mysql" mysqladmin ping --host=127.0.0.1 --user=root --silent >/dev/null 2>&1; do
|
||||
attempt=$((attempt + 1))
|
||||
if [ "$attempt" -ge 120 ]; then
|
||||
echo "mysql did not become ready" >&2
|
||||
exit 1
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
docker run --name "$tests" --network "$network" \
|
||||
--env IT_MYSQL_HOST=mysql --env IT_MYSQL_PORT=3306 --env IT_MYSQL_ROOT_PASSWORD="$root_password" \
|
||||
"$image"
|
||||
Reference in new issue
Block a user