Files
mhoennigandClaude Opus 5 c0e52cb95f
werkator build succeeded after 00:36
Spring Boot, and the database as a jdbc:tc URL (#2)
The programmatic PostgreSQLContainer was one way to ask werkdock for a
database. The way most projects actually ask is a jdbc:tc URL, where
Testcontainers is the JDBC driver and no Java code mentions a container
at all. This adds that form, as a Spring Boot application whose
application.yml holds the URLs, and leaves the programmatic test class
untouched — the two take different paths through Testcontainers and are
therefore two questions, not one.

JdbcUrlDatabaseTest asks four of them: the configured URL connects, the
init script named in it has run, the server listens on a port that is
not the container's own, and a second URL is a second server. All nine
tests pass against werkdock, on a developer machine and in CI on the
managed webspace, and werkdock needed no change for any of it: a JDBC
init script travels over the connection, so it does not want the
archive endpoint werkdock has yet to grow.

TC_DAEMON=true is in the URLs on purpose. Without it Testcontainers
stops the database when the last connection closes, and a connection
pool closes connections whenever it likes.

Versions now come from Spring Boot's BOM, so Testcontainers moved from
1.19.3 to 1.21.4 — deliberately, and both test classes pass on it. A
declared version does not hold against a platform constraint in Gradle;
pretending otherwise in a comment would have been worse than saying
which version actually runs.

The Spring Boot plugin names the plain jar werkprobe-plain.jar; dist
still collects it and the libraries, so the flat classpath on a managed
webspace runs either main class. run-probe.sh --spring picks the new one.

Squashed from branch spring-boot-jdbc-tc and pushed to main directly;
the pull request was opened afterwards, not before.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-11 07:31:27 +02:00

36 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
# Copy the probe to a host that has a JVM and werkdock, then run it.
#
# tools/deploy.sh mih09-werkdock@mih09.hostsharing.net
# tools/deploy.sh USER@HOST REMOTE_DIR (default: probe)
#
# Everything travels in ONE ssh connection: the Hostsharing webspaces
# refuse connections that follow each other too quickly.
set -euo pipefail
target="${1:?usage: tools/deploy.sh USER@HOST [REMOTE_DIR]}"
remote_dir="${2:-probe}"
cd "$(dirname "$0")/.."
echo "== building"
./gradlew -q --console=plain dist
staging="build/deploy"
rm -rf "$staging"
mkdir -p "$staging"
cp build/dist/*.jar "$staging/"
cp src/main/java/werkprobe/*.java "$staging/"
cp tools/run-probe.sh "$staging/"
chmod +x "$staging/run-probe.sh"
echo "== copying $(du -sh "$staging" | cut -f1) to $target:~/$remote_dir"
tar -C "$staging" -czf - . | ssh "$target" "
rm -rf ~/$remote_dir.new &&
mkdir -p ~/$remote_dir.new &&
tar -C ~/$remote_dir.new -xzf - &&
rm -rf ~/$remote_dir &&
mv ~/$remote_dir.new ~/$remote_dir &&
ls ~/$remote_dir/run-probe.sh"
echo "== run it with: ssh $target '~/$remote_dir/run-probe.sh'"