From b527779919160d3d98c8420b166859b7aec60c74 Mon Sep 17 00:00:00 2001 From: dev Date: Sat, 14 Jun 2025 18:44:05 +0200 Subject: [PATCH 01/13] Prod modifications --- .env | 4 ++-- .github/workflows/releases.yml | 3 +-- aperisolve/app.py | 5 +++++ docker-compose.yml | 6 +++--- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/.env b/.env index bdea06b..68b1939 100644 --- a/.env +++ b/.env @@ -3,8 +3,8 @@ MAX_PENDING_TIME=600 MAX_STORE_TIME=259200 FLASK_DEBUG=0 FLASK_ENV=production -DB_URI=postgresql://aperiuser:aperipass@postgres:5432/aperisolve +DB_URI=postgresql://aperiuser:iacyANdLeUREonIuMPorpHySTaIsHEAn@postgres:5432/aperisolve RQ_DASHBOARD_REDIS_URL=redis://redis:6379/0 POSTGRES_DB=aperisolve POSTGRES_USER=aperiuser -POSTGRES_PASSWORD=aperipass \ No newline at end of file +POSTGRES_PASSWORD=iacyANdLeUREonIuMPorpHySTaIsHEAn \ No newline at end of file diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml index 6d780f8..42b1404 100644 --- a/.github/workflows/releases.yml +++ b/.github/workflows/releases.yml @@ -39,6 +39,5 @@ jobs: context: ./ push: true tags: | - ghcr.io/${{ env.lower_actor }}/aperisolve:latest - ghcr.io/${{ env.lower_actor }}/aperisolve:${{ env.RELEASE_VERSION }} + ghcr.io/${{ env.lower_actor }}/aperisolve:prod \ No newline at end of file diff --git a/aperisolve/app.py b/aperisolve/app.py index c409c11..2d4e924 100644 --- a/aperisolve/app.py +++ b/aperisolve/app.py @@ -246,6 +246,11 @@ def get_image( return send_file(output_file, as_attachment=True) +@app.route("/ads.txt") +def google_ads() -> str: + return "google.com, pub-2324718887045017, DIRECT, f08c47fec0942fa0" + + if __name__ == "__main__": debug_mode = os.environ.get("FLASK_DEBUG", "false").lower() == "true" app.run(host="0.0.0.0", port=5000, debug=debug_mode) diff --git a/docker-compose.yml b/docker-compose.yml index 777fef2..f1349a6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,11 +1,11 @@ services: web: - image: ghcr.io/zeecka/aperisolve:latest + image: ghcr.io/zeecka/aperisolve:prod #build: . container_name: aperisolve-web restart: always ports: - - "5000:5000" + - "80:5000" volumes: - apresults:/aperisolve/results depends_on: @@ -19,7 +19,7 @@ services: - .env worker: - image: ghcr.io/zeecka/aperisolve:latest + image: ghcr.io/zeecka/aperisolve:prod #build: . container_name: aperisolve-worker restart: always From b1dfa305d3926505ea76305964b7a61c0717c9bc Mon Sep 17 00:00:00 2001 From: dev Date: Sat, 14 Jun 2025 18:48:32 +0200 Subject: [PATCH 02/13] Fix linters --- aperisolve/app.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/aperisolve/app.py b/aperisolve/app.py index 2d4e924..9b4993b 100644 --- a/aperisolve/app.py +++ b/aperisolve/app.py @@ -31,7 +31,8 @@ queue = Queue(connection=redis_conn) @app.errorhandler(413) -def too_large(e): +def too_large(_) -> tuple[Response, int]: + """Error Handler for Max File Size.""" return jsonify({"error": "Image size exceeded"}), 413 @@ -248,6 +249,7 @@ def get_image( @app.route("/ads.txt") def google_ads() -> str: + """Google Ads required file""" return "google.com, pub-2324718887045017, DIRECT, f08c47fec0942fa0" From 277fbe7deaf74bfabe85e1a865c20fd687f01f08 Mon Sep 17 00:00:00 2001 From: dev Date: Sat, 14 Jun 2025 18:52:38 +0200 Subject: [PATCH 03/13] Fix MyPy --- aperisolve/app.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aperisolve/app.py b/aperisolve/app.py index 9b4993b..6e71f74 100644 --- a/aperisolve/app.py +++ b/aperisolve/app.py @@ -6,7 +6,7 @@ import os import time from datetime import datetime, timezone from pathlib import Path -from typing import Optional +from typing import Any, Optional from flask import Flask, Response, abort, jsonify, render_template, request, send_file from redis import Redis @@ -31,7 +31,7 @@ queue = Queue(connection=redis_conn) @app.errorhandler(413) -def too_large(_) -> tuple[Response, int]: +def too_large(_: Any) -> tuple[Response, int]: """Error Handler for Max File Size.""" return jsonify({"error": "Image size exceeded"}), 413 From b610ff6e4c13d5df8e51f6620f13e5f5c680df99 Mon Sep 17 00:00:00 2001 From: dev Date: Sat, 14 Jun 2025 20:11:38 +0200 Subject: [PATCH 04/13] Add Google script.js --- aperisolve/templates/base.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/aperisolve/templates/base.html b/aperisolve/templates/base.html index 5ec42eb..5ebc34b 100644 --- a/aperisolve/templates/base.html +++ b/aperisolve/templates/base.html @@ -9,6 +9,8 @@ + From d8b680ee2f9c1208fb80e357f644749c135d2e7a Mon Sep 17 00:00:00 2001 From: Zeecka Date: Sat, 14 Jun 2025 20:24:11 +0200 Subject: [PATCH 05/13] Fix max size bug --- aperisolve/app.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/aperisolve/app.py b/aperisolve/app.py index 6e71f74..a66cf9e 100644 --- a/aperisolve/app.py +++ b/aperisolve/app.py @@ -20,7 +20,9 @@ app: Flask = Flask(__name__) app.json.sort_keys = False # type: ignore app.config["SQLALCHEMY_DATABASE_URI"] = os.environ.get("DB_URI") app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False -app.config["MAX_CONTENT_LENGTH"] = os.environ.get("MAX_CONTENT_LENGTH") +app.config["MAX_CONTENT_LENGTH"] = int( + os.environ.get("MAX_CONTENT_LENGTH", 1024 * 1024) +) RESULT_FOLDER.mkdir(parents=True, exist_ok=True) From 0b86966b648728ab938922e58cb9d588c4bb7458 Mon Sep 17 00:00:00 2001 From: Zeecka <24873615+Zeecka@users.noreply.github.com> Date: Fri, 26 Dec 2025 12:39:58 +0100 Subject: [PATCH 06/13] Fix error handling in exiftool.py output --- aperisolve/analyzers/exiftool.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aperisolve/analyzers/exiftool.py b/aperisolve/analyzers/exiftool.py index 136931d..23ec7bd 100644 --- a/aperisolve/analyzers/exiftool.py +++ b/aperisolve/analyzers/exiftool.py @@ -20,7 +20,7 @@ def analyze_exiftool(input_img: Path, output_dir: Path) -> None: if data.stderr: update_data( - output_dir, {"strings": {"status": "error", "error": data.stderr}} + output_dir, {"exiftool": {"status": "error", "error": data.stderr}} ) return From caa5289ffd1f06d88f3b4804ee98296cc6d2ccff Mon Sep 17 00:00:00 2001 From: Zeecka Date: Sun, 4 Jan 2026 18:26:39 +0100 Subject: [PATCH 07/13] fix conflicts --- .env | 10 ---------- .github/workflows/releases.yml | 24 ++++++++++++++++++------ 2 files changed, 18 insertions(+), 16 deletions(-) delete mode 100644 .env diff --git a/.env b/.env deleted file mode 100644 index 68b1939..0000000 --- a/.env +++ /dev/null @@ -1,10 +0,0 @@ -MAX_CONTENT_LENGTH=1048576 -MAX_PENDING_TIME=600 -MAX_STORE_TIME=259200 -FLASK_DEBUG=0 -FLASK_ENV=production -DB_URI=postgresql://aperiuser:iacyANdLeUREonIuMPorpHySTaIsHEAn@postgres:5432/aperisolve -RQ_DASHBOARD_REDIS_URL=redis://redis:6379/0 -POSTGRES_DB=aperisolve -POSTGRES_USER=aperiuser -POSTGRES_PASSWORD=iacyANdLeUREonIuMPorpHySTaIsHEAn \ No newline at end of file diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml index 42b1404..561cabc 100644 --- a/.github/workflows/releases.yml +++ b/.github/workflows/releases.yml @@ -10,22 +10,24 @@ jobs: docker-releases: runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') && (github.ref_name == 'main' || github.ref_name == 'prod') + steps: - name: Get release version run: echo "RELEASE_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV - + - name: downcase username run: echo "lower_actor=${GITHUB_ACTOR,,}" >> $GITHUB_ENV - name: Checkout uses: actions/checkout@v4 - + - name: Set up QEMU uses: docker/setup-qemu-action@v3 - + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - + - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: @@ -33,11 +35,21 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Determine latest tag + run: | + if [[ "${GITHUB_REF_NAME}" == "main" ]]; then + echo "LATEST_TAG=latest" >> $GITHUB_ENV + elif [[ "${GITHUB_REF_NAME}" == "prod" ]]; then + echo "LATEST_TAG=latest-prod" >> $GITHUB_ENV + else + echo "LATEST_TAG=" >> $GITHUB_ENV + fi + - name: Build and push Docker images uses: docker/build-push-action@v6.9.0 with: context: ./ push: true tags: | - ghcr.io/${{ env.lower_actor }}/aperisolve:prod - \ No newline at end of file + ghcr.io/${{ env.lower_actor }}/aperisolve:${{ env.RELEASE_VERSION }} + ghcr.io/${{ env.lower_actor }}/aperisolve:${{ env.LATEST_TAG }} From 00f63fd3413d11d43c97bf4f848292a52e8bf452 Mon Sep 17 00:00:00 2001 From: Zeecka Date: Sun, 4 Jan 2026 18:31:19 +0100 Subject: [PATCH 08/13] Fix release job --- .github/workflows/releases.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml index 561cabc..bada2f7 100644 --- a/.github/workflows/releases.yml +++ b/.github/workflows/releases.yml @@ -10,7 +10,7 @@ jobs: docker-releases: runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/') && (github.ref_name == 'main' || github.ref_name == 'prod') + if: startsWith(github.ref, 'refs/tags/') && (github.ref_name == 'main' || github.ref_name == 'prod') steps: - name: Get release version From 2bdc99c8d9c1fc670dd6ff640777f06e020ce69d Mon Sep 17 00:00:00 2001 From: Zeecka Date: Sun, 4 Jan 2026 18:42:51 +0100 Subject: [PATCH 09/13] Fix release job --- .github/workflows/releases.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml index bada2f7..139bfec 100644 --- a/.github/workflows/releases.yml +++ b/.github/workflows/releases.yml @@ -10,7 +10,6 @@ jobs: docker-releases: runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/') && (github.ref_name == 'main' || github.ref_name == 'prod') steps: - name: Get release version From 0756a91c2ead7050f827cf5b21c57f95cb80093d Mon Sep 17 00:00:00 2001 From: Zeecka Date: Sun, 4 Jan 2026 19:03:44 +0100 Subject: [PATCH 10/13] Fix release job --- .github/workflows/deployement.yml | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/.github/workflows/deployement.yml b/.github/workflows/deployement.yml index cb0efdc..3915f8d 100644 --- a/.github/workflows/deployement.yml +++ b/.github/workflows/deployement.yml @@ -6,19 +6,40 @@ on: - Docker Image CI types: - completed - branches: - - prod # Only triggers for tags in the production branch jobs: - deploy: - # Deploys only if the build was successfuli + check-and-deploy: if: ${{ github.event.workflow_run.conclusion == 'success' }} - runs-on: ubuntu-latest environment: production steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ github.event.workflow_run.head_sha }} + fetch-depth: 0 + + - name: Check if tag is from prod branch + id: check + run: | + TAG_REF="${{ github.event.workflow_run.head_branch }}" + echo "Tag/Branch: $TAG_REF" + + # Récupère les branches contenant ce commit + BRANCHES=$(git branch -r --contains ${{ github.event.workflow_run.head_sha }}) + echo "Branches containing this commit: $BRANCHES" + + if echo "$BRANCHES" | grep -q "origin/prod"; then + echo "is_prod=true" >> $GITHUB_OUTPUT + echo "✅ Tag is from prod branch - will deploy" + else + echo "is_prod=false" >> $GITHUB_OUTPUT + echo "❌ Tag is not from prod branch - skipping deployment" + fi + - name: Deploy to production server + if: steps.check.outputs.is_prod == 'true' uses: appleboy/ssh-action@v1.0.3 with: host: ${{ secrets.PROD_SSH_HOST }} From 26022acb605f8c40b950bd12a1564ad8115c00f4 Mon Sep 17 00:00:00 2001 From: Zeecka Date: Sun, 4 Jan 2026 19:14:58 +0100 Subject: [PATCH 11/13] Fix release job --- .github/workflows/deployement.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deployement.yml b/.github/workflows/deployement.yml index 3915f8d..9bc4342 100644 --- a/.github/workflows/deployement.yml +++ b/.github/workflows/deployement.yml @@ -11,7 +11,7 @@ jobs: check-and-deploy: if: ${{ github.event.workflow_run.conclusion == 'success' }} runs-on: ubuntu-latest - environment: production + environment: prod steps: - name: Checkout From 8cb3639d370af218ae8f080536dd306f9e93eb17 Mon Sep 17 00:00:00 2001 From: Zeecka Date: Sun, 4 Jan 2026 23:41:58 +0100 Subject: [PATCH 12/13] Github CD --- .github/workflows/deployement.yml | 36 +++---------------- .../workflows/{releases.yml => release.yml} | 21 +---------- 2 files changed, 5 insertions(+), 52 deletions(-) rename .github/workflows/{releases.yml => release.yml} (54%) diff --git a/.github/workflows/deployement.yml b/.github/workflows/deployement.yml index 9bc4342..53a4f1c 100644 --- a/.github/workflows/deployement.yml +++ b/.github/workflows/deployement.yml @@ -1,45 +1,17 @@ name: Deploy to production on: - workflow_run: - workflows: - - Docker Image CI - types: - - completed + push: + tags: + - '*' jobs: - check-and-deploy: - if: ${{ github.event.workflow_run.conclusion == 'success' }} + deploy: runs-on: ubuntu-latest environment: prod steps: - - name: Checkout - uses: actions/checkout@v4 - with: - ref: ${{ github.event.workflow_run.head_sha }} - fetch-depth: 0 - - - name: Check if tag is from prod branch - id: check - run: | - TAG_REF="${{ github.event.workflow_run.head_branch }}" - echo "Tag/Branch: $TAG_REF" - - # Récupère les branches contenant ce commit - BRANCHES=$(git branch -r --contains ${{ github.event.workflow_run.head_sha }}) - echo "Branches containing this commit: $BRANCHES" - - if echo "$BRANCHES" | grep -q "origin/prod"; then - echo "is_prod=true" >> $GITHUB_OUTPUT - echo "✅ Tag is from prod branch - will deploy" - else - echo "is_prod=false" >> $GITHUB_OUTPUT - echo "❌ Tag is not from prod branch - skipping deployment" - fi - - name: Deploy to production server - if: steps.check.outputs.is_prod == 'true' uses: appleboy/ssh-action@v1.0.3 with: host: ${{ secrets.PROD_SSH_HOST }} diff --git a/.github/workflows/releases.yml b/.github/workflows/release.yml similarity index 54% rename from .github/workflows/releases.yml rename to .github/workflows/release.yml index cd82718..a1b2803 100644 --- a/.github/workflows/releases.yml +++ b/.github/workflows/release.yml @@ -18,25 +18,6 @@ jobs: - name: Checkout uses: actions/checkout@v4 - with: - fetch-depth: 0 # required to verify branch - - - name: Check which branch the tag belongs to - id: check_branch - run: | - # Trouve les branches qui contiennent ce tag - BRANCHES=$(git branch -r --contains ${{ github.ref }}) - - if echo "$BRANCHES" | grep -q "origin/main"; then - echo "branch=main" >> $GITHUB_OUTPUT - echo "LATEST_TAG=latest" >> $GITHUB_ENV - elif echo "$BRANCHES" | grep -q "origin/prod"; then - echo "branch=prod" >> $GITHUB_OUTPUT - echo "LATEST_TAG=latest-prod" >> $GITHUB_ENV - else - echo "branch=other" >> $GITHUB_OUTPUT - echo "LATEST_TAG=" >> $GITHUB_ENV - fi - name: Set up QEMU uses: docker/setup-qemu-action@v3 @@ -58,4 +39,4 @@ jobs: push: true tags: | ghcr.io/${{ env.lower_actor }}/aperisolve:${{ env.RELEASE_VERSION }} - ${{ env.LATEST_TAG && format('ghcr.io/{0}/aperisolve:{1}', env.lower_actor, env.LATEST_TAG) || '' }} + ghcr.io/${{ env.lower_actor }}/aperisolve:latest-prod From 80622f218fff4133ceff1c41a7b9cc30b84ffe3e Mon Sep 17 00:00:00 2001 From: Zeecka Date: Sun, 4 Jan 2026 23:52:17 +0100 Subject: [PATCH 13/13] Check prod --- .github/workflows/deployement.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/.github/workflows/deployement.yml b/.github/workflows/deployement.yml index 53a4f1c..53dbae1 100644 --- a/.github/workflows/deployement.yml +++ b/.github/workflows/deployement.yml @@ -6,7 +6,31 @@ on: - '*' jobs: + check-branch: + runs-on: ubuntu-latest + outputs: + is_prod: ${{ steps.check.outputs.is_prod }} + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Check if tag is from prod branch + id: check + run: | + BRANCHES=$(git branch -r --contains ${{ github.ref }}) + if echo "$BRANCHES" | grep -q "origin/prod"; then + echo "is_prod=true" >> $GITHUB_OUTPUT + echo "✅ Tag is from prod branch" + else + echo "is_prod=false" >> $GITHUB_OUTPUT + echo "❌ Tag is NOT from prod branch - skipping deployment" + fi + deploy: + needs: check-branch + if: needs.check-branch.outputs.is_prod == 'true' runs-on: ubuntu-latest environment: prod