From 1828f7a4ffdc5b463b58d7b5daf2b3099eb3a93c Mon Sep 17 00:00:00 2001 From: Daniel Graf Date: Tue, 3 Mar 2026 10:01:57 +0100 Subject: [PATCH 1/7] chore: simplify application-docker.properties configuration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Removed unused server and static resource settings. - Updated property names for consistency (`paikka.import-configuration.threads` → `paikka.import.threads`). - Adjusted default path for `paikka.stats-db-path`. --- .../resources/application-docker.properties | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/src/main/resources/application-docker.properties b/src/main/resources/application-docker.properties index 44dfbd0..9fb5c13 100644 --- a/src/main/resources/application-docker.properties +++ b/src/main/resources/application-docker.properties @@ -1,24 +1,11 @@ -server.port=8080 -server.compression.enabled=true -# Minimum response size to trigger compression -server.compression.min-response-size=1024 -# Content types to compress -server.compression.mime-types=text/plain,application/json - -# Static resource caching - only for actual static resources, not HTML templates -spring.web.resources.cache.cachecontrol.max-age=31536000 -spring.web.resources.cache.cachecontrol.cache-public=true -spring.web.resources.chain.strategy.content.enabled=true -spring.web.resources.chain.strategy.content.paths=/css/**,/js/**,/img/**,/fonts/** - -# Paikka configuration - all configurable via environment variables paikka.data-dir=${DATA_DIR:/data} -paikka.import-configuration.threads=${MAX_IMPORT_THREADS:10} +paikka.import.threads=${MAX_IMPORT_THREADS:10} paikka.query.max-results=${MAX_RESULTS:500} paikka.query.default-results=${DEFAULT_RESULTS:10} paikka.query.base-url=${BASE_URL:http://localhost:8080} -paikka.stats-db-path=${STATS_DB_PATH:/data/stats.db} + +paikka.stats-db-path=${STATS_DB_PATH:/stats/stats.db} paikka.admin.password=${ADMIN_PASSWORD:} # Logging configuration From e3bc7fc0f8bff8baedd98de7259914c8673a7176 Mon Sep 17 00:00:00 2001 From: Daniel Graf Date: Tue, 3 Mar 2026 10:03:17 +0100 Subject: [PATCH 2/7] chore: add STATS_DIR environment variable and directory setup in Dockerfile --- Dockerfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Dockerfile b/Dockerfile index e607c78..8a15915 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,6 +15,7 @@ RUN apt update && DEBIAN_FRONTEND=noninteractive apt-get -yq install osmium-tool ENV SPRING_PROFILES_ACTIVE=docker ENV APP_HOME=/app ENV DATA_DIR=/data +ENV STATS_DIR=/stats # Create application directory RUN mkdir -p $APP_HOME && \ @@ -46,6 +47,9 @@ fi mkdir -p $DATA_DIR chown -R paikka:paikka $DATA_DIR +mkdir -p $STATS_DIR +chown -R paikka:paikka $STATS_DIR + # Switch to data directory cd $DATA_DIR From c08e4d38d96ba6cb0b4af2b6f6cb1bcc9ba70c34 Mon Sep 17 00:00:00 2001 From: Daniel Graf Date: Tue, 3 Mar 2026 10:31:02 +0100 Subject: [PATCH 3/7] chore: update docker-compose.yml service configuration - Simplified environment variables for `paikka` service. - Adjusted `start_period` in healthcheck. - Removed unused volume drivers for cleaner setup. --- docker-compose.yml | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index cbfd3c4..81b7903 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,31 +1,24 @@ services: paikka: image: dedicatedcode/paikka:latest + restart: unless-stopped env_file: - .env ports: - "8080:8080" + environment: + - ADMIN_PASSWORD=your-password-here + - BASE_URL=http://localhost:8080 volumes: - paikka-data:/data - paikka-stats:/stats - environment: - - DATA_DIR=/data - - STATS_DB_PATH=/stats/stats.db - - ADMIN_PASSWORD=your-secure-admin-password - - MAX_RESULTS=500 - - DEFAULT_RESULTS=10 - - BASE_URL=http://localhost:8080 - - APP_LOG_LEVEL=INFO - restart: unless-stopped healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8080/api/v1/health"] interval: 30s timeout: 10s retries: 3 - start_period: 10s + start_period: 40s volumes: paikka-data: - driver: local - paikka-stats: - driver: local \ No newline at end of file + paikka-stats: \ No newline at end of file From f01ebf9c0fb10978fb805407d4fb9a57df51e59e Mon Sep 17 00:00:00 2001 From: Daniel Graf Date: Tue, 3 Mar 2026 10:44:54 +0100 Subject: [PATCH 4/7] docs: update README formatting and environment variable details - Improved list indentation for better readability. - Clarified admin password requirements and `.env` setup in Docker Compose section. - Updated memory and swap recommendations for import operations. - Enhanced example commands with detailed parameter descriptions. --- README.md | 220 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 124 insertions(+), 96 deletions(-) diff --git a/README.md b/README.md index 319e5c0..74d142a 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,8 @@ Standard geocoding solutions often fall short for specific personal tracking nee ## Relationship to Reitti -[Reitti](https://github.com/dedicatedcode/reitti) is a comprehensive personal location tracking and analysis application that helps you understand your movement patterns and significant places. PAIKKA acts as the dedicated "location engine" for Reitti, converting raw GPS coordinates into human-readable context. +[Reitti](https://github.com/dedicatedcode/reitti) is a comprehensive personal location tracking and analysis application that helps you understand your movement patterns and significant places. PAIKKA acts as the dedicated "location engine" for Reitti, converting raw GPS +coordinates into human-readable context. ## Limitations @@ -25,30 +26,30 @@ Standard geocoding solutions often fall short for specific personal tracking nee - Optimized for read-heavy serving; updates require re-importing prepared data. - Focused strictly on reverse geocoding (coordinates to place). - **Highly Opinionated POI Selection:** PAIKKA is deliberately selective about which Points of Interest it imports. It only includes POIs with the following OSM tags: - - `amenity` (e.g., restaurant, school, hospital, fuel, atm) - - `shop` (e.g., supermarket, clothes, bakery) - - `tourism` (e.g., hotel, museum, attraction) - - `leisure` (e.g., fitness_centre, playground, park) - - `office` (e.g., company, government, insurance) - - `craft` (e.g., carpenter, electrician, painter) - - `healthcare` (e.g., hospital, pharmacy, clinic) - - `emergency` (e.g., ambulance_station, fire_hydrant) - - `historic` (e.g., monument, archaeological_site) - - `natural` (e.g., peak, cave, waterfall) - - `man_made` (e.g., tower, pier, windmill) - - `place` (e.g., city, town, village, neighborhood) - - `sport` (e.g., tennis, swimming, fitness) - - `public_transport` (e.g., stop_position, station) - - `railway` (stations only) - - `aeroway` (e.g., aerodrome, helipad) - - `building` (commercial, retail, industrial, office – but not residential or generic "yes") - + - `amenity` (e.g., restaurant, school, hospital, fuel, atm) + - `shop` (e.g., supermarket, clothes, bakery) + - `tourism` (e.g., hotel, museum, attraction) + - `leisure` (e.g., fitness_centre, playground, park) + - `office` (e.g., company, government, insurance) + - `craft` (e.g., carpenter, electrician, painter) + - `healthcare` (e.g., hospital, pharmacy, clinic) + - `emergency` (e.g., ambulance_station, fire_hydrant) + - `historic` (e.g., monument, archaeological_site) + - `natural` (e.g., peak, cave, waterfall) + - `man_made` (e.g., tower, pier, windmill) + - `place` (e.g., city, town, village, neighborhood) + - `sport` (e.g., tennis, swimming, fitness) + - `public_transport` (e.g., stop_position, station) + - `railway` (stations only) + - `aeroway` (e.g., aerodrome, helipad) + - `building` (commercial, retail, industrial, office – but not residential or generic "yes") + Many common OSM features are explicitly excluded, such as: - - Natural features like trees and grass - - Man-made structures like electric-poles, trash cans - - Amenities like benches, drinking water, and picnic tables - - Swimming pools and fountains - + - Natural features like trees and grass + - Man-made structures like electric-poles, trash cans + - Amenities like benches, drinking water, and picnic tables + - Swimming pools and fountains + If you need comprehensive POI coverage including all OSM features, **Nominatim** would be a better fit for your use case. While it would be technically possible to import the complete unfiltered dataset, this was never the intended design and has not been tested. ## Features @@ -124,7 +125,7 @@ The [OpenStreetMap website](https://www.openstreetmap.org/export/) allows you to The above benchmarks were performed on the following hardware: - **CPU:** AMD Ryzen 7 5825U with Radeon Graphics (8 cores, 16 threads, 4.5 GHz max) -- **Memory:** 31 GiB system RAM +- **Memory:** 32 GiB system RAM - **Storage:** ZFS Pool on 4 HDD **Import Command Used:** @@ -134,11 +135,13 @@ docker run -ti -v ./:/data dedicatedcode/paikka:develop import --memory 16G --th **Memory Considerations:** -The `--memory` flag (e.g., `--memory 16G`) controls the JVM heap size only. RocksDB requires additional memory beyond the heap for its block cache and internal structures. For optimal performance with large imports, ensure your system has significantly more RAM available than the heap size specified. As a guideline, a 16GB heap typically works well on systems with 24-32GB of RAM for medium-sized countries, while planet imports benefit from 32GB+ heap on systems with 64GB+ RAM. +The `--memory` flag (e.g., `--memory 16G`) controls the JVM heap size only. RocksDB requires additional memory beyond the heap for its block cache and internal structures. For optimal performance with large imports, ensure your system has significantly more RAM available than +the heap size specified. As a guideline, a 16GB heap typically works well on systems with 24-32GB of RAM for medium-sized countries, while planet imports benefit from 32GB+ heap on systems with 64GB+ RAM. **Swap Space:** -Ensure adequate swap space is available. During import, memory usage can spike due to RocksDB's internal buffering and compaction operations. Without sufficient swap, the system may invoke the OOM killer to terminate processes when memory limits are exceeded. A good rule of thumb is to have swap space at least equal to or larger than the JVM heap size (e.g., 16GB heap with 16GB+ swap). +Ensure adequate swap space is available. During import, memory usage can spike due to RocksDB's internal buffering and compaction operations. Without sufficient swap, the system may invoke the OOM killer to terminate processes when memory limits are exceeded. A good rule of +thumb is to have swap space at least equal to or larger than the JVM heap size (e.g., 16GB heap with 16GB+ swap). **Storage Considerations:** @@ -186,11 +189,17 @@ docker run -v /path/to/your/data:/data dedicatedcode/paikka prepare input.osm.pb Run the `import` script to import the filtered data into the data directory: ```bash -docker run -ti -v /path/to/your/data:/data dedicatedcode/paikka:latest import filtered.osm.pbf +docker run -ti \ + -v /path/to/your/data:/data \ + --memory 16g \ + dedicatedcode/paikka:latest \ + import filtered.osm.pbf --memory 16g --threads 10 ``` -- `filtered.osm.pbf` is the filtered PBF file from the previous step -- `/data` is the target directory inside the container (mounted from your local directory) +Parameters: +- `--memory`: JVM heap size (e.g., `16g`, `32g`) +- `--threads`: Number of import threads (default: `10`) +- `--data-dir`: Directory to store imported data (default: `/data` inside container) After import completes, your data directory will contain the processed data files ready for the service. @@ -201,12 +210,16 @@ To run the PAIKKA service itself: ```bash docker run -d \ -v /path/to/your/data:/data \ + -v /path/to/stats:/stats \ -p 8080:8080 \ -e ADMIN_PASSWORD=your-secure-password \ - paikka + dedicatedcode/paikka:latest ``` -The data directory is mounted at `/data` inside the container, and the service runs on port 8080. +- `/data` directory contains the processed POI and geometry data +- `/stats` directory contains the statistics database +- The service runs on port 8080 +- Admin interface requires `ADMIN_PASSWORD` to be set #### Docker Environment Variables @@ -214,27 +227,29 @@ When running with Docker, you can configure the service using environment variab | Environment Variable | Purpose | Default Value | |---------------------|---------|---------------| -| `DATA_DIR` | Directory where processed data is stored | `./data` | +| `DATA_DIR` | Directory where processed data is stored | `/data` | | `MAX_IMPORT_THREADS` | Maximum number of threads for data import | `10` | | `MAX_RESULTS` | Maximum number of results returned by API | `500` | | `DEFAULT_RESULTS` | Default number of results when not specified | `10` | | `BASE_URL` | Base URL for the service (used in responses) | `http://localhost:8080` | -| `STATS_DB_PATH` | Path to the statistics database | `./data/stats.db` | -| `ADMIN_PASSWORD` | Password for admin interface access | _(empty)_ | -| `APP_LOG_LEVEL` | Log level for the application | `INFO` | +| `STATS_DB_PATH` | Path to the statistics database | `/stats/stats.db` | +| `ADMIN_PASSWORD` | Password for admin interface access (required) | _(empty - admin interface disabled if not set)_ | +| `APP_LOG_LEVEL` | Log level for the application (`DEBUG`, `INFO`, `WARN`, `ERROR`) | `INFO` | + +**Note:** The admin interface is disabled if `ADMIN_PASSWORD` is not set. To enable admin features, you must provide a password. Example with custom configuration: ```bash docker run -d \ -v /path/to/your/data:/data \ + -v /path/to/stats:/stats \ -p 8080:8080 \ - -e DATA_DIR=/data \ -e MAX_RESULTS=1000 \ -e DEFAULT_RESULTS=20 \ -e ADMIN_PASSWORD=your-secure-password \ -e APP_LOG_LEVEL=DEBUG \ - paikka + dedicatedcode/paikka:latest ``` ### Examples @@ -264,6 +279,7 @@ mvn spring-boot:run ```bash java -Xmx8g -jar target/paikka-*.jar --data-dir=/path/to/data ``` + ## Running with Docker Compose Docker Compose provides an easy way to run PAIKKA with persistent volumes for data and statistics. @@ -276,35 +292,62 @@ Docker Compose provides an easy way to run PAIKKA with persistent volumes for da ### Quick Start -1. Download the docker-compose.yml file: - ```bash - curl -O https://raw.githubusercontent.com/dedicatedcode/paikka/main/docker-compose.yml - ``` +1. Create a `docker-compose.yml` file with the following content: + +```yaml +version: '3.8' + +services: + paikka: + image: dedicatedcode/paikka:latest + restart: unless-stopped + env_file: + - .env + ports: + - "8080:8080" + environment: + - ADMIN_PASSWORD=your-password-here + - BASE_URL=http://localhost:8080 + volumes: + - paikka-data:/data + - paikka-stats:/stats + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:8080/api/v1/health"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 40s + +volumes: + paikka-data: + paikka-stats: +``` -2. Configure PAIKKA using environment variables in `.env` file or the command line: - ```bash - # Example .env file - ADMIN_PASSWORD=your-secure-password - BASE_URL=https://your-domain.com - MAX_RESULTS=1000 - APP_LOG_LEVEL=DEBUG - ``` +2. Create a `.env` file in the same directory to configure your environment variables: -3. Create a data directory: - ```bash - mkdir -p data - mkdir -p stats - ``` -4. Start the service: +```bash +# Example .env file +ADMIN_PASSWORD=your-secure-password +BASE_URL=http://localhost:8080 +MAX_RESULTS=500 +DEFAULT_RESULTS=10 +MAX_IMPORT_THREADS=10 +APP_LOG_LEVEL=INFO +``` + +3. Start the service: ```bash docker compose up -d ``` -5. Verify the service is running: +4. Verify the service is running: ```bash curl 'http://localhost:8080/api/v1/health' ``` +### Important: Admin Password +The admin interface requires a password to be set via the `ADMIN_PASSWORD` environment variable. If not set, the admin endpoints will be inaccessible. Set it in your `.env` file or docker-compose configuration. + ### Volume Management Docker Compose creates two persistent volumes: @@ -344,66 +387,51 @@ docker compose up -d ### Configuration -Configure the service using environment variables or application properties: +Configure the service using environment variables or application properties. The Docker version uses the following Spring profile properties: ```properties -# Server configuration -server.port=8080 - -# HTTP compression -server.compression.enabled=true -server.compression.min-response-size=1024 -server.compression.mime-types=text/plain,application/json - -# Static resource caching -spring.web.resources.cache.cachecontrol.max-age=31536000 -spring.web.resources.cache.cachecontrol.cache-public=true -spring.web.resources.chain.strategy.content.enabled=true -spring.web.resources.chain.strategy.content.paths=/css/**,/js/**,/img/**,/fonts/** - -# Data directory -paikka.data-dir=./data +# Data directory (Docker default: /data) +paikka.data-dir=${DATA_DIR:/data} # Import configuration -paikka.import.threads=16 -paikka.import.s2-level=14 +paikka.import.threads=${MAX_IMPORT_THREADS:10} paikka.import.chunk-size=100000 # Query configuration -paikka.query.max-results=500 -paikka.query.default-results=10 -paikka.query.base-url=http://localhost:8080 +paikka.query.max-results=${MAX_RESULTS:500} +paikka.query.default-results=${DEFAULT_RESULTS:10} +paikka.query.base-url=${BASE_URL:http://localhost:8080} -# Statistics database path -paikka.stats-db-path=./data/stats.db +# Statistics database path (Docker default: /stats/stats.db) +paikka.stats-db-path=${STATS_DB_PATH:/stats/stats.db} -# Admin password -paikka.admin.password=your-secure-password +# Admin password (required for admin interface) +paikka.admin.password=${ADMIN_PASSWORD:} # Logging -logging.level.com.dedicatedcode.paikka=INFO +logging.level.com.dedicatedcode.paikka=${APP_LOG_LEVEL:INFO} logging.level.root=WARN ``` -| Property | Description | Default Value | -|----------|-------------|---------------| +| Property | Description | Default Value (Docker) | +|----------|-------------|------------------------| | `server.port` | HTTP server port | `8080` | | `server.compression.enabled` | Enable HTTP response compression | `true` | | `server.compression.min-response-size` | Minimum response size to trigger compression (bytes) | `1024` | | `server.compression.mime-types` | MIME types to compress | `text/plain,application/json` | | `spring.web.resources.cache.cachecontrol.max-age` | Static resource cache max age (seconds) | `31536000` | -| `paikka.data-dir` | Directory where processed data is stored | `./data` | -| `paikka.import.threads` | Number of threads for data import | `16` | -| `paikka.import.s2-level` | S2 spatial indexing level (10-15) | `14` | +| `paikka.data-dir` | Directory where processed data is stored | `/data` | +| `paikka.import.threads` | Number of threads for data import | `10` | | `paikka.import.chunk-size` | Number of elements to process per chunk | `100000` | | `paikka.query.max-results` | Maximum number of results returned by API | `500` | | `paikka.query.default-results` | Default number of results when not specified | `10` | | `paikka.query.base-url` | Base URL for the service (used in responses) | `http://localhost:8080` | -| `paikka.stats-db-path` | Path to the statistics database | `./data/stats.db` | -| `paikka.admin.password` | Password for admin interface access | _(empty)_ | +| `paikka.stats-db-path` | Path to the statistics database | `/stats/stats.db` | +| `paikka.admin.password` | Password for admin interface access | _(empty - admin interface disabled)_ | | `logging.level.com.dedicatedcode.paikka` | Application log level | `INFO` | | `logging.level.root` | Root log level | `WARN` | + ### Sample Requests ```bash @@ -423,7 +451,7 @@ curl 'http://localhost:8080/api/v1/geometry/12345' ### Web Interface - Visit `http://localhost:8080/` for the about page -- Visit `http://localhost:8080/admin/stats` to access the admin dashboard (login required) +- Visit `http://localhost:8080/login` to access the admin dashboard (requires `ADMIN_PASSWORD` to be set) ## Integration with Reitti @@ -433,13 +461,13 @@ TBA There are multiple ways of getting support: -- Create a [new issue](https://github.com/dedicatedcode/paikka/issues/new/choose) in the repository +- Create a (https://github.com/dedicatedcode/paikka/issues/new/choose) in the repository - Tag me on [Lemmy](https://discuss.tchncs.de/u/danielgraf) -- Join **#reitti** on [irc.dedicatedcode.com](https://irc.dedicatedcode.com) +- Join **#reitti** on (https://irc.dedicatedcode.com) ## Contributing -Contributions are welcome! Please feel free to submit a Pull Request to [repository](https://github.com/dedicatedcode/paikka). +Contributions are welcome! Please feel free to submit a Pull Request to (https://github.com/dedicatedcode/paikka). ## Technology Stack @@ -457,4 +485,4 @@ This project is licensed under the GNU Affero General Public License v3 (AGPLv3) ## About -PAIKKA is developed as part of the Reitti ecosystem by [dedicatedcode](https://github.com/dedicatedcode). It provides the geocoding infrastructure that powers location-based features in Reitti. +PAIKKA is developed as part of the Reitti ecosystem by (https://github.com/dedicatedcode). It provides the geocoding infrastructure that powers location-based features in Reitti. \ No newline at end of file From c4845cd6b6fa10ae46b43dd45a2c532b27d21173 Mon Sep 17 00:00:00 2001 From: "Daniel Graf (aider-ce)" Date: Tue, 3 Mar 2026 10:55:55 +0100 Subject: [PATCH 5/7] docs: add official instance details to README with usage guidelines --- README.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 74d142a..7b7b47c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,16 @@ ![](.github/banner.png) +## Official Instance + +There is an official instance of PAIKKA running at **https://geo.dedicatedcode.com** that you can use for free. + +**Important notes about this instance:** +- There are **no usage limits or restrictions** – feel free to integrate it into your projects. +- However, there are **no guarantees about availability or SLA** (Service Level Agreement). The service is provided on a best-effort basis. +- The instance is shared among all users. **Please do not abuse it** – excessive or abusive usage will affect everyone else. + +Be nice to each other and use the service responsibly. + PAIKKA is a specialized reverse geocoding service designed to provide high-performance location resolution for [Reitti](https://github.com/dedicatedcode/reitti). The name comes from the Finnish word for "place" and is pronounced [ˈpɑi̯kːɑ]. ## Overview @@ -485,4 +496,4 @@ This project is licensed under the GNU Affero General Public License v3 (AGPLv3) ## About -PAIKKA is developed as part of the Reitti ecosystem by (https://github.com/dedicatedcode). It provides the geocoding infrastructure that powers location-based features in Reitti. \ No newline at end of file +PAIKKA is developed as part of the Reitti ecosystem by (https://github.com/dedicatedcode). It provides the geocoding infrastructure that powers location-based features in Reitti. From 1542adcce8bbe383765b959c97af7d23e2e5fae5 Mon Sep 17 00:00:00 2001 From: Daniel Graf Date: Tue, 3 Mar 2026 12:04:35 +0100 Subject: [PATCH 6/7] chore: add verification step and enhanced rollback logic to update.sh - Introduced query validation to verify deployed data integrity using expected IDs. - Improved rollback mechanism to handle failures more reliably, retaining faulty data for inspection. - Cleaned up old releases upon successful verification for better resource management. --- scripts/update.sh | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/scripts/update.sh b/scripts/update.sh index 031e036..0f79d3f 100644 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -177,8 +177,37 @@ remote_deploy_and_verify() { [ -n "\$OLD_RELEASE_DIR" ] && ln -sfn "\$OLD_RELEASE_DIR" "\$LIVE_DATA_SYMLINK" exit 1 fi - - # ... [Verification logic remains the same] ... + # --- 2. Verify --- + echo_remote "Verifying new data..." + VERIFICATION_FAILED=0 + for query in "\${!TESTS[@]}"; do + ACTUAL_ID=\$(curl -s "\$TEST_URL_BASE?\$query" | jq -r '.[0].id // "not_found"') + if [ "\$ACTUAL_ID" != "\${TESTS[\$query]}" ]; then + echo_remote " --> FAILED: For \$query, expected '\${TESTS[\$query]}', got '\$ACTUAL_ID'" + VERIFICATION_FAILED=1 + else + echo_remote " --> SUCCESS: Verified query for \$query" + fi + done + + # --- 3. Finalize or Rollback --- + if [ \$VERIFICATION_FAILED -eq 1 ]; then + echo_remote "VERIFICATION FAILED. Rolling back and re-refreshing." + if [ -n "\$OLD_RELEASE_DIR" ] && [ -d "\$OLD_RELEASE_DIR" ]; then + ln -sfn "\$OLD_RELEASE_DIR" "\$LIVE_DATA_SYMLINK" + curl -s -o /dev/null -X POST -H "Authorization: Bearer \$API_TOKEN" "\$ADMIN_URL" + echo_remote "Rollback to \$OLD_RELEASE_DIR complete. Faulty data in \$NEW_RELEASE_DIR is kept for inspection." + exit 1 + else + echo_remote "ERROR: Verification failed, but no previous version to roll back to!" + exit 1 + fi + else + echo_remote "VERIFICATION SUCCEEDED. Cleaning up old release and archive." + [ -n "\$OLD_RELEASE_DIR" ] && [ -d "\$OLD_RELEASE_DIR" ] && rm -rf "\$OLD_RELEASE_DIR" + rm "\$ZIP_FILENAME" + echo_remote "Deployment successful." + fi if [ \$VERIFICATION_FAILED -eq 0 ]; then echo "Success. Cleaning up old release..." From 5e45ae7354885547f22b7790f7b721ab7321e42b Mon Sep 17 00:00:00 2001 From: Daniel Graf Date: Tue, 3 Mar 2026 12:18:33 +0100 Subject: [PATCH 7/7] chore: remove redundant ZIP cleanup step in update.sh - Eliminated unnecessary `rm "$ZIP_FILENAME"` command after old release cleanup. --- scripts/update.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/update.sh b/scripts/update.sh index 0f79d3f..030d30c 100644 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -177,7 +177,7 @@ remote_deploy_and_verify() { [ -n "\$OLD_RELEASE_DIR" ] && ln -sfn "\$OLD_RELEASE_DIR" "\$LIVE_DATA_SYMLINK" exit 1 fi - # --- 2. Verify --- + # --- 2. Verify --- echo_remote "Verifying new data..." VERIFICATION_FAILED=0 for query in "\${!TESTS[@]}"; do @@ -205,7 +205,6 @@ remote_deploy_and_verify() { else echo_remote "VERIFICATION SUCCEEDED. Cleaning up old release and archive." [ -n "\$OLD_RELEASE_DIR" ] && [ -d "\$OLD_RELEASE_DIR" ] && rm -rf "\$OLD_RELEASE_DIR" - rm "\$ZIP_FILENAME" echo_remote "Deployment successful." fi