testing and docker replacements

This commit is contained in:
Anthony Stirling
2025-07-16 23:09:26 +01:00
parent 2f977ff250
commit 3fd52ed564
25 changed files with 363 additions and 427 deletions

View File

@@ -0,0 +1,63 @@
services:
backend:
build:
context: ../..
dockerfile: docker/backend/Dockerfile
container_name: Stirling-PDF-Security-with-login
restart: on-failure:5
deploy:
resources:
limits:
memory: 4G
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:8080/api/v1/info/status | grep -q 'UP'"]
interval: 5s
timeout: 10s
retries: 16
ports:
- "8080:8080"
volumes:
- ../../stirling/latest/data:/usr/share/tessdata:rw
- ../../stirling/latest/config:/configs:rw
- ../../stirling/latest/logs:/logs:rw
environment:
DISABLE_ADDITIONAL_FEATURES: "false"
DOCKER_ENABLE_SECURITY: "true"
SECURITY_ENABLELOGIN: "true"
SECURITY_INITIALLOGIN_USERNAME: "admin"
SECURITY_INITIALLOGIN_PASSWORD: "stirling"
SYSTEM_DEFAULTLOCALE: en-US
UI_APPNAME: Stirling-PDF
UI_HOMEDESCRIPTION: Demo site for Stirling-PDF Latest with Security and Login
UI_APPNAMENAVBAR: Stirling-PDF Latest
SYSTEM_MAXFILESIZE: "100"
METRICS_ENABLED: "true"
SYSTEM_GOOGLEVISIBILITY: "true"
SECURITY_CUSTOMGLOBALAPIKEY: "123456789"
SHOW_SURVEY: "true"
networks:
- stirling-network
frontend:
build:
context: ../..
dockerfile: docker/frontend/Dockerfile
container_name: stirling-pdf-frontend-security-login
restart: on-failure:5
ports:
- "3000:80"
environment:
BACKEND_URL: http://backend:8080
depends_on:
- backend
networks:
- stirling-network
networks:
stirling-network:
driver: bridge
volumes:
stirling-data:
stirling-config:
stirling-logs:

View File

@@ -0,0 +1,59 @@
services:
backend:
build:
context: ../..
dockerfile: docker/backend/Dockerfile
container_name: Stirling-PDF-Security
restart: on-failure:5
deploy:
resources:
limits:
memory: 4G
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:8080/api/v1/info/status | grep -q 'UP'"]
interval: 5s
timeout: 10s
retries: 16
ports:
- "8080:8080"
volumes:
- ../../stirling/latest/data:/usr/share/tessdata:rw
- ../../stirling/latest/config:/configs:rw
- ../../stirling/latest/logs:/logs:rw
environment:
DISABLE_ADDITIONAL_FEATURES: "false"
SECURITY_ENABLELOGIN: "false"
SYSTEM_DEFAULTLOCALE: en-US
UI_APPNAME: Stirling-PDF
UI_HOMEDESCRIPTION: Demo site for Stirling-PDF Latest with Security
UI_APPNAMENAVBAR: Stirling-PDF Latest
SYSTEM_MAXFILESIZE: "100"
METRICS_ENABLED: "true"
SYSTEM_GOOGLEVISIBILITY: "true"
SHOW_SURVEY: "true"
networks:
- stirling-network
frontend:
build:
context: ../..
dockerfile: docker/frontend/Dockerfile
container_name: stirling-pdf-frontend-security
restart: on-failure:5
ports:
- "3000:80"
environment:
BACKEND_URL: http://backend:8080
depends_on:
- backend
networks:
- stirling-network
networks:
stirling-network:
driver: bridge
volumes:
stirling-data:
stirling-config:
stirling-logs:

View File

@@ -0,0 +1,59 @@
services:
backend:
build:
context: ../..
dockerfile: docker/backend/Dockerfile.ultra-lite
container_name: Stirling-PDF-Ultra-Lite
restart: on-failure:5
deploy:
resources:
limits:
memory: 2G
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:8080/api/v1/info/status | grep -q 'UP' && curl -fL http://localhost:8080/ | grep -qv 'Please sign in'"]
interval: 5s
timeout: 10s
retries: 16
ports:
- "8080:8080"
volumes:
- ../../stirling/latest/config:/configs:rw
- ../../stirling/latest/logs:/logs:rw
environment:
DISABLE_ADDITIONAL_FEATURES: "true"
SECURITY_ENABLELOGIN: "false"
ENDPOINTS_GROUPS_TO_REMOVE: "CLI"
SYSTEM_DEFAULTLOCALE: en-US
UI_APPNAME: Stirling-PDF-Ultra-lite
UI_HOMEDESCRIPTION: Demo site for Stirling-PDF-Ultra-lite Latest
UI_APPNAMENAVBAR: Stirling-PDF-Ultra-lite Latest
SYSTEM_MAXFILESIZE: "100"
METRICS_ENABLED: "true"
SYSTEM_GOOGLEVISIBILITY: "true"
SHOW_SURVEY: "true"
networks:
- stirling-network
frontend:
build:
context: ../..
dockerfile: docker/frontend/Dockerfile
container_name: stirling-pdf-frontend-ultra-lite
restart: on-failure:5
ports:
- "3000:80"
environment:
BACKEND_URL: http://backend:8080
depends_on:
- backend
networks:
- stirling-network
networks:
stirling-network:
driver: bridge
volumes:
stirling-data:
stirling-config:
stirling-logs:

View File

@@ -225,8 +225,8 @@ test_compose() {
echo "Testing $compose_file configuration..."
# Start up the Docker Compose service
docker-compose -f "$compose_file" up -d
# Start up the Docker Compose service with forced rebuild
docker-compose -f "$compose_file" up -d --build
# Wait for the service to become healthy
if check_health "$service_name" "$compose_file"; then
@@ -276,22 +276,27 @@ main() {
EXPECTED_VERSION=$(get_expected_version)
echo "Expected version: $EXPECTED_VERSION"
# Building Docker images
# docker build --no-cache --pull --build-arg VERSION_TAG=alpha -t stirlingtools/stirling-pdf:latest -f ./Dockerfile .
docker build --build-arg VERSION_TAG=alpha -t docker.stirlingpdf.com/stirlingtools/stirling-pdf:latest-ultra-lite -f ./Dockerfile.ultra-lite .
# Test each configuration
run_tests "Stirling-PDF-Ultra-Lite" "./exampleYmlFiles/docker-compose-latest-ultra-lite.yml"
run_tests "Stirling-PDF-Ultra-Lite" "./testing/compose/docker-compose-ultra-lite.yml"
echo "Testing webpage accessibility..."
cd "testing"
if ./test_webpages.sh -f webpage_urls.txt -b http://localhost:8080; then
passed_tests+=("Webpage-Accessibility-lite")
echo "Testing basic frontend homepage accessibility..."
if curl -f http://localhost:3000 > /dev/null 2>&1; then
passed_tests+=("Frontend-Homepage-Accessibility-lite")
echo "Frontend homepage accessibility check passed"
else
failed_tests+=("Webpage-Accessibility-lite")
echo "Webpage accessibility lite tests failed"
failed_tests+=("Frontend-Homepage-Accessibility-lite")
echo "Frontend homepage accessibility check failed"
fi
cd "$PROJECT_ROOT"
# echo "Testing webpage accessibility..."
# cd "testing"
# if ./test_webpages.sh -f webpage_urls.txt -b http://localhost:8080; then
# passed_tests+=("Webpage-Accessibility-lite")
# else
# failed_tests+=("Webpage-Accessibility-lite")
# echo "Webpage accessibility lite tests failed"
# fi
# cd "$PROJECT_ROOT"
echo "Testing version verification..."
if verify_app_version "Stirling-PDF-Ultra-Lite" "http://localhost:8080"; then
@@ -302,10 +307,11 @@ main() {
echo "Version verification failed for Stirling-PDF-Ultra-Lite"
fi
docker-compose -f "./exampleYmlFiles/docker-compose-latest-ultra-lite.yml" down
# run_tests "Stirling-PDF" "./exampleYmlFiles/docker-compose-latest.yml"
# docker-compose -f "./exampleYmlFiles/docker-compose-latest.yml" down
docker-compose -f "./testing/compose/docker-compose-ultra-lite.yml" down
# Clean up any generated config files
echo "Cleaning up generated config files..."
rm -rf "$PROJECT_ROOT/stirling/" 2>/dev/null || true
export DISABLE_ADDITIONAL_FEATURES=false
# Run the gradlew build command and check if it fails
@@ -319,43 +325,44 @@ main() {
EXPECTED_VERSION=$(get_expected_version)
echo "Expected version with security enabled: $EXPECTED_VERSION"
# Building Docker images with security enabled
# docker build --no-cache --pull --build-arg VERSION_TAG=alpha -t stirlingtools/stirling-pdf:latest -f ./Dockerfile .
# docker build --no-cache --pull --build-arg VERSION_TAG=alpha -t stirlingtools/stirling-pdf:latest-ultra-lite -f ./Dockerfile.ultra-lite .
docker build --no-cache --pull --build-arg VERSION_TAG=alpha -t docker.stirlingpdf.com/stirlingtools/stirling-pdf:latest-fat -f ./Dockerfile.fat .
# Test each configuration with security
# run_tests "Stirling-PDF-Ultra-Lite-Security" "./exampleYmlFiles/docker-compose-latest-ultra-lite-security.yml"
# docker-compose -f "./exampleYmlFiles/docker-compose-latest-ultra-lite-security.yml" down
# run_tests "Stirling-PDF-Security" "./exampleYmlFiles/docker-compose-latest-security.yml"
# docker-compose -f "./exampleYmlFiles/docker-compose-latest-security.yml" down
run_tests "Stirling-PDF-Security" "./testing/compose/docker-compose-security.yml"
run_tests "Stirling-PDF-Security-Fat" "./exampleYmlFiles/docker-compose-latest-fat-security.yml"
echo "Testing webpage accessibility..."
cd "testing"
if ./test_webpages.sh -f webpage_urls_full.txt -b http://localhost:8080; then
passed_tests+=("Webpage-Accessibility-full")
echo "Testing basic frontend homepage accessibility..."
if curl -f http://localhost:3000 > /dev/null 2>&1; then
passed_tests+=("Frontend-Homepage-Accessibility-full")
echo "Frontend homepage accessibility check passed"
else
failed_tests+=("Webpage-Accessibility-full")
echo "Webpage accessibility full tests failed"
failed_tests+=("Frontend-Homepage-Accessibility-full")
echo "Frontend homepage accessibility check failed"
fi
cd "$PROJECT_ROOT"
# echo "Testing webpage accessibility..."
# cd "testing"
# if ./test_webpages.sh -f webpage_urls_full.txt -b http://localhost:8080; then
# passed_tests+=("Webpage-Accessibility-full")
# else
# failed_tests+=("Webpage-Accessibility-full")
# echo "Webpage accessibility full tests failed"
# fi
# cd "$PROJECT_ROOT"
echo "Testing version verification..."
if verify_app_version "Stirling-PDF-Security-Fat" "http://localhost:8080"; then
passed_tests+=("Stirling-PDF-Security-Fat-Version-Check")
echo "Version verification passed for Stirling-PDF-Security-Fat"
if verify_app_version "Stirling-PDF-Security" "http://localhost:8080"; then
passed_tests+=("Stirling-PDF-Security-Version-Check")
echo "Version verification passed for Stirling-PDF-Security"
else
failed_tests+=("Stirling-PDF-Security-Fat-Version-Check")
echo "Version verification failed for Stirling-PDF-Security-Fat"
failed_tests+=("Stirling-PDF-Security-Version-Check")
echo "Version verification failed for Stirling-PDF-Security"
fi
docker-compose -f "./exampleYmlFiles/docker-compose-latest-fat-security.yml" down
docker-compose -f "./testing/compose/docker-compose-security.yml" down
# Clean up any generated config files
echo "Cleaning up generated config files..."
rm -rf "$PROJECT_ROOT/stirling/" 2>/dev/null || true
run_tests "Stirling-PDF-Security-Fat-with-login" "./exampleYmlFiles/test_cicd.yml"
run_tests "Stirling-PDF-Security-with-login" "./testing/compose/docker-compose-security-with-login.yml"
if [ $? -eq 0 ]; then
# Create directory for file snapshots if it doesn't exist
@@ -368,7 +375,7 @@ main() {
DIFF_FILE="$SNAPSHOT_DIR/files_diff.txt"
# Define container name variable for consistency
CONTAINER_NAME="Stirling-PDF-Security-Fat-with-login"
CONTAINER_NAME="Stirling-PDF-Security-with-login"
capture_file_list "$CONTAINER_NAME" "$BEFORE_FILE"
@@ -409,28 +416,12 @@ main() {
fi
fi
docker-compose -f "./exampleYmlFiles/test_cicd.yml" down
docker-compose -f "./testing/compose/docker-compose-security-with-login.yml" down
# Clean up any generated config files
echo "Cleaning up generated config files..."
rm -rf "$PROJECT_ROOT/stirling/" 2>/dev/null || true
run_tests "Stirling-PDF-Fat-Disable-Endpoints" "./exampleYmlFiles/docker-compose-latest-fat-endpoints-disabled.yml"
echo "Testing disabled endpoints..."
if ./testing/test_disabledEndpoints.sh -f ./testing/endpoints.txt -b http://localhost:8080; then
passed_tests+=("Disabled-Endpoints")
else
failed_tests+=("Disabled-Endpoints")
echo "Disabled Endpoints tests failed"
fi
echo "Testing version verification..."
if verify_app_version "Stirling-PDF-Fat-Disable-Endpoints" "http://localhost:8080"; then
passed_tests+=("Stirling-PDF-Fat-Disable-Endpoints-Version-Check")
echo "Version verification passed for Stirling-PDF-Fat-Disable-Endpoints"
else
failed_tests+=("Stirling-PDF-Fat-Disable-Endpoints-Version-Check")
echo "Version verification failed for Stirling-PDF-Fat-Disable-Endpoints"
fi
docker-compose -f "./exampleYmlFiles/docker-compose-latest-fat-endpoints-disabled.yml" down
# Report results
echo "All tests completed in $SECONDS seconds."

View File

@@ -51,29 +51,33 @@ build_and_test() {
local dockerfile_name="./Dockerfile"
local image_base="stirlingtools/stirling-pdf"
local security_suffix=""
local docker_compose_base="./exampleYmlFiles/docker-compose-latest"
local docker_compose_base="./testing/compose/docker-compose"
local compose_suffix=".yml"
local service_name_base="Stirling-PDF"
if [ "$enable_security" == "true" ]; then
security_suffix="-Security"
docker_compose_base+="-security" # Append to base name for Docker Compose files with security
fi
case "$build_type" in
full)
dockerfile_name="./Dockerfile"
dockerfile_name="./docker/backend/Dockerfile"
if [ "$enable_security" == "true" ]; then
compose_file="${docker_compose_base}-fat-security${compose_suffix}"
service_name="Stirling-PDF-Security-Fat"
else
compose_file="${docker_compose_base}-fat${compose_suffix}"
service_name="stirling-pdf-backend-fat"
fi
;;
ultra-lite)
dockerfile_name="./Dockerfile.ultra-lite"
dockerfile_name="./docker/backend/Dockerfile.ultra-lite"
if [ "$enable_security" == "true" ]; then
compose_file="${docker_compose_base}-ultra-lite-security${compose_suffix}"
service_name="stirling-pdf-backend-ultra-lite-security"
else
compose_file="${docker_compose_base}-ultra-lite${compose_suffix}"
service_name="Stirling-PDF-Ultra-Lite"
fi
;;
esac
# Dynamic image tag and service name based on build type and security
local image_tag="${image_base}:latest${build_type}${security_suffix}"
local service_name="${service_name_base}${build_type^}${security_suffix}"
local compose_file="${docker_compose_base}${build_type}${compose_suffix}"
# Gradle build with or without security
echo "Running ./gradlew clean build with security=$enable_security..."
./gradlew clean build
@@ -83,10 +87,6 @@ build_and_test() {
exit 1
fi
# Building Docker image
echo "Building Docker image $image_tag with Dockerfile $dockerfile_name..."
docker build --build-arg VERSION_TAG=$version_tag -t $image_tag -f $dockerfile_name .
if [ "$run_compose" == "true" ]; then
echo "Running Docker Compose for $build_type with security=$enable_security..."
docker-compose -f "$compose_file" up -d