23 Commits

Author SHA1 Message Date
af6e89274d Added preprod rules
Some checks failed
Remote Deployment Pipeline / Prepare Context (pull_request) Successful in 2s
Remote Deployment Pipeline / Deploy (Staging) (pull_request) Has been skipped
Remote Deployment Pipeline / Deploy (Dev/Preview) (pull_request) Successful in 42s
Remote Deployment Pipeline / Cleanup Preview (pull_request) Has been skipped
Remote Deployment Pipeline / Deploy (Pre-Prod) (pull_request) Failing after 56s
Remote Deployment Pipeline / Deploy (Production) (pull_request) Has been skipped
2026-01-15 22:26:05 +01:00
ef6cf2999b Test domain
Some checks failed
Remote Deployment Pipeline / Prepare Context (pull_request) Successful in 2s
Remote Deployment Pipeline / Deploy (Staging) (pull_request) Has been skipped
Remote Deployment Pipeline / Deploy (Pre-Prod) (pull_request) Failing after 53s
Remote Deployment Pipeline / Deploy (Dev/Preview) (pull_request) Successful in 41s
Remote Deployment Pipeline / Cleanup Preview (pull_request) Has been skipped
Remote Deployment Pipeline / Deploy (Production) (pull_request) Has been skipped
2026-01-15 22:23:36 +01:00
1c9be2d57d Use preprod.env
Some checks failed
Remote Deployment Pipeline / Prepare Context (pull_request) Successful in 2s
Remote Deployment Pipeline / Deploy (Staging) (pull_request) Has been skipped
Remote Deployment Pipeline / Deploy (Pre-Prod) (pull_request) Failing after 56s
Remote Deployment Pipeline / Deploy (Dev/Preview) (pull_request) Successful in 39s
Remote Deployment Pipeline / Cleanup Preview (pull_request) Has been skipped
Remote Deployment Pipeline / Deploy (Production) (pull_request) Has been skipped
2026-01-15 22:03:44 +01:00
01c5229f26 refactor: Update CI workflow to ensure environment variables are loaded for E2E tests and add conditional cleanup.
Some checks failed
Remote Deployment Pipeline / Prepare Context (pull_request) Successful in 3s
Remote Deployment Pipeline / Deploy (Staging) (pull_request) Has been skipped
Remote Deployment Pipeline / Deploy (Pre-Prod) (pull_request) Failing after 46s
Remote Deployment Pipeline / Cleanup Preview (pull_request) Has been skipped
Remote Deployment Pipeline / Deploy (Production) (pull_request) Has been skipped
Remote Deployment Pipeline / Deploy (Dev/Preview) (pull_request) Failing after 14m14s
2026-01-15 21:55:03 +01:00
50aa276c37 Reapply "test: Update default PORT and HTTPS_PORT values for E2E tests."
All checks were successful
Remote Deployment Pipeline / Prepare Context (pull_request) Successful in 3s
Remote Deployment Pipeline / Deploy (Staging) (pull_request) Has been skipped
Remote Deployment Pipeline / Deploy (Pre-Prod) (pull_request) Successful in 1m18s
Remote Deployment Pipeline / Deploy (Dev/Preview) (pull_request) Successful in 42s
Remote Deployment Pipeline / Cleanup Preview (pull_request) Has been skipped
Remote Deployment Pipeline / Deploy (Production) (pull_request) Has been skipped
This reverts commit 5920529de7.
2026-01-15 21:48:18 +01:00
f5dc53dc96 Revert "Undid workflow changes"
All checks were successful
Remote Deployment Pipeline / Prepare Context (pull_request) Successful in 2s
Remote Deployment Pipeline / Deploy (Staging) (pull_request) Has been skipped
Remote Deployment Pipeline / Deploy (Pre-Prod) (pull_request) Successful in 56s
Remote Deployment Pipeline / Deploy (Dev/Preview) (pull_request) Successful in 1m16s
Remote Deployment Pipeline / Cleanup Preview (pull_request) Has been skipped
Remote Deployment Pipeline / Deploy (Production) (pull_request) Has been skipped
This reverts commit d415f0d82f.
2026-01-15 21:47:55 +01:00
d415f0d82f Undid workflow changes
All checks were successful
Remote Deployment Pipeline / Prepare Context (pull_request) Successful in 3s
Remote Deployment Pipeline / Deploy (Staging) (pull_request) Has been skipped
Remote Deployment Pipeline / Deploy (Dev/Preview) (pull_request) Successful in 41s
Remote Deployment Pipeline / Deploy (Production) (pull_request) Has been skipped
Remote Deployment Pipeline / Cleanup Preview (pull_request) Has been skipped
2026-01-15 21:42:20 +01:00
5920529de7 Revert "test: Update default PORT and HTTPS_PORT values for E2E tests."
All checks were successful
Remote Deployment Pipeline / Prepare Context (pull_request) Successful in 2s
Remote Deployment Pipeline / Deploy (Staging) (pull_request) Has been skipped
Remote Deployment Pipeline / Deploy (Pre-Prod) (pull_request) Successful in 56s
Remote Deployment Pipeline / Deploy (Dev/Preview) (pull_request) Successful in 41s
Remote Deployment Pipeline / Cleanup Preview (pull_request) Has been skipped
Remote Deployment Pipeline / Deploy (Production) (pull_request) Has been skipped
This reverts commit c2ef3a3160.
2026-01-15 21:40:41 +01:00
c2ef3a3160 test: Update default PORT and HTTPS_PORT values for E2E tests.
All checks were successful
Remote Deployment Pipeline / Prepare Context (pull_request) Successful in 2s
Remote Deployment Pipeline / Deploy (Staging) (pull_request) Has been skipped
Remote Deployment Pipeline / Deploy (Pre-Prod) (pull_request) Successful in 1m3s
Remote Deployment Pipeline / Deploy (Dev/Preview) (pull_request) Successful in 45s
Remote Deployment Pipeline / Cleanup Preview (pull_request) Has been skipped
Remote Deployment Pipeline / Deploy (Production) (pull_request) Has been skipped
2026-01-15 21:36:09 +01:00
f60d9bb66c Moved sourcing
Some checks failed
Remote Deployment Pipeline / Prepare Context (pull_request) Successful in 2s
Remote Deployment Pipeline / Deploy (Staging) (pull_request) Has been skipped
Remote Deployment Pipeline / Deploy (Pre-Prod) (pull_request) Successful in 1m9s
Remote Deployment Pipeline / Deploy (Dev/Preview) (pull_request) Failing after 42s
Remote Deployment Pipeline / Cleanup Preview (pull_request) Has been skipped
Remote Deployment Pipeline / Deploy (Production) (pull_request) Has been skipped
2026-01-15 21:30:00 +01:00
de03b9625c Added sourcing
All checks were successful
Remote Deployment Pipeline / Prepare Context (pull_request) Successful in 2s
Remote Deployment Pipeline / Deploy (Staging) (pull_request) Has been skipped
Remote Deployment Pipeline / Deploy (Pre-Prod) (pull_request) Successful in 1m14s
Remote Deployment Pipeline / Deploy (Dev/Preview) (pull_request) Successful in 1m4s
Remote Deployment Pipeline / Cleanup Preview (pull_request) Has been skipped
Remote Deployment Pipeline / Deploy (Production) (pull_request) Has been skipped
2026-01-15 21:26:30 +01:00
44d0093069 ci: Comment out the branch condition for the pre-production deployment workflow.
All checks were successful
Remote Deployment Pipeline / Prepare Context (pull_request) Successful in 3s
Remote Deployment Pipeline / Deploy (Staging) (pull_request) Has been skipped
Remote Deployment Pipeline / Deploy (Pre-Prod) (pull_request) Successful in 1m21s
Remote Deployment Pipeline / Deploy (Dev/Preview) (pull_request) Successful in 53s
Remote Deployment Pipeline / Cleanup Preview (pull_request) Has been skipped
Remote Deployment Pipeline / Deploy (Production) (pull_request) Has been skipped
2026-01-15 21:21:47 +01:00
fc2e0cb44e Uncommented needs
All checks were successful
Remote Deployment Pipeline / Prepare Context (pull_request) Successful in 3s
Remote Deployment Pipeline / Deploy (Staging) (pull_request) Has been skipped
Remote Deployment Pipeline / Deploy (Pre-Prod) (pull_request) Has been skipped
Remote Deployment Pipeline / Deploy (Dev/Preview) (pull_request) Successful in 53s
Remote Deployment Pipeline / Cleanup Preview (pull_request) Has been skipped
Remote Deployment Pipeline / Deploy (Production) (pull_request) Has been skipped
2026-01-15 21:20:17 +01:00
7121747d35 feat: Add pre-production deployment stage with E2E tests, a dedicated environment file, and update production deployment dependency.
All checks were successful
Remote Deployment Pipeline / Prepare Context (pull_request) Successful in 2s
Remote Deployment Pipeline / Deploy (Staging) (pull_request) Has been skipped
Remote Deployment Pipeline / Deploy (Dev/Preview) (pull_request) Successful in 1m33s
Remote Deployment Pipeline / Cleanup Preview (pull_request) Has been skipped
Remote Deployment Pipeline / Deploy (Pre-Prod) (pull_request) Has been skipped
Remote Deployment Pipeline / Deploy (Production) (pull_request) Has been skipped
2026-01-15 21:17:40 +01:00
b448b47b70 Merge pull request 'chore(deps): update traefik:v3.6 docker digest to 03650d0' (#29) from renovate/traefik-v3.6 into main
All checks were successful
Remote Deployment Pipeline / Prepare Context (push) Successful in 3s
Remote Deployment Pipeline / Deploy (Staging) (push) Successful in 1m0s
Remote Deployment Pipeline / Deploy (Dev/Preview) (push) Has been skipped
Remote Deployment Pipeline / Cleanup Preview (push) Has been skipped
Remote Deployment Pipeline / Deploy (Production) (push) Successful in 1m20s
Reviewed-on: #29
2026-01-15 20:42:37 +01:00
539341dc65 chore(deps): update traefik:v3.6 docker digest to 03650d0
All checks were successful
Remote Deployment Pipeline / Prepare Context (pull_request) Successful in 4s
Remote Deployment Pipeline / Deploy (Staging) (pull_request) Has been skipped
Remote Deployment Pipeline / Deploy (Dev/Preview) (pull_request) Has been skipped
Remote Deployment Pipeline / Cleanup Preview (pull_request) Successful in 13s
Remote Deployment Pipeline / Deploy (Production) (pull_request) Has been skipped
2026-01-15 03:28:58 +00:00
86e37ef551 Merge pull request 'Added route file back' (#28) from add-route-file-back into main
All checks were successful
Remote Deployment Pipeline / Prepare Context (push) Successful in 2s
Remote Deployment Pipeline / Deploy (Staging) (push) Successful in 49s
Remote Deployment Pipeline / Deploy (Dev/Preview) (push) Has been skipped
Remote Deployment Pipeline / Cleanup Preview (push) Has been skipped
Remote Deployment Pipeline / Deploy (Production) (push) Successful in 56s
Reviewed-on: #28
2025-12-25 21:22:07 +01:00
1d30d5afad Added route file back
All checks were successful
Remote Deployment Pipeline / Prepare Context (pull_request) Successful in 3s
Remote Deployment Pipeline / Deploy (Staging) (pull_request) Has been skipped
Remote Deployment Pipeline / Deploy (Dev/Preview) (pull_request) Has been skipped
Remote Deployment Pipeline / Cleanup Preview (pull_request) Successful in 10s
Remote Deployment Pipeline / Deploy (Production) (pull_request) Has been skipped
2025-12-25 21:20:32 +01:00
ef466353b8 Merge pull request 'fix-pipeline-fail' (#27) from fix-pipeline-fail into main
All checks were successful
Remote Deployment Pipeline / Prepare Context (push) Successful in 2s
Remote Deployment Pipeline / Deploy (Staging) (push) Successful in 49s
Remote Deployment Pipeline / Deploy (Dev/Preview) (push) Has been skipped
Remote Deployment Pipeline / Cleanup Preview (push) Has been skipped
Remote Deployment Pipeline / Deploy (Production) (push) Successful in 1m1s
Reviewed-on: #27
2025-12-25 21:13:47 +01:00
6e9c0f0442 Removed new file
All checks were successful
Remote Deployment Pipeline / Prepare Context (pull_request) Successful in 3s
Remote Deployment Pipeline / Deploy (Staging) (pull_request) Has been skipped
Remote Deployment Pipeline / Deploy (Dev/Preview) (pull_request) Has been skipped
Remote Deployment Pipeline / Deploy (Production) (pull_request) Has been skipped
Remote Deployment Pipeline / Cleanup Preview (pull_request) Successful in 14s
2025-12-25 21:11:27 +01:00
ba65f0609a chore: remove staging/dev routing configuration and associated extra host entries 2025-12-25 21:09:55 +01:00
38ed72b6de Testing whether folder works (#26)
Some checks failed
Remote Deployment Pipeline / Prepare Context (push) Successful in 3s
Remote Deployment Pipeline / Deploy (Staging) (push) Successful in 51s
Remote Deployment Pipeline / Deploy (Dev/Preview) (push) Has been skipped
Remote Deployment Pipeline / Cleanup Preview (push) Has been skipped
Remote Deployment Pipeline / Deploy (Production) (push) Failing after 23m6s
Reviewed-on: #26
Co-authored-by: kovagoadi <kovagoadi@gmail.com>
Co-committed-by: kovagoadi <kovagoadi@gmail.com>
2025-12-25 20:43:31 +01:00
8c6c01b916 Setup env (#24)
All checks were successful
Remote Deployment Pipeline / Prepare Context (push) Successful in 3s
Remote Deployment Pipeline / Deploy (Staging) (push) Successful in 51s
Remote Deployment Pipeline / Deploy (Dev/Preview) (push) Has been skipped
Remote Deployment Pipeline / Cleanup Preview (push) Has been skipped
Remote Deployment Pipeline / Deploy (Production) (push) Successful in 1m1s
Reviewed-on: #24
Co-authored-by: kovagoadi <kovagoadi@gmail.com>
Co-committed-by: kovagoadi <kovagoadi@gmail.com>
2025-12-20 15:12:51 +01:00
18 changed files with 538 additions and 25 deletions

View File

@@ -12,6 +12,7 @@ env:
REMOTE_DEPLOY_PATH: /var/app/traefik/test REMOTE_DEPLOY_PATH: /var/app/traefik/test
REMOTE_PROD_PATH: /var/app/traefik/prod REMOTE_PROD_PATH: /var/app/traefik/prod
REMOTE_STAGING_PATH: /var/app/traefik/staging REMOTE_STAGING_PATH: /var/app/traefik/staging
REMOTE_PREPROD_PATH: /var/app/traefik/preprod
# --- SECRETS --- # --- SECRETS ---
SSH_HOST: ${{ secrets.SSH_HOST }} SSH_HOST: ${{ secrets.SSH_HOST }}
@@ -65,7 +66,7 @@ jobs:
SCRIPT_AFTER: | SCRIPT_AFTER: |
set -e set -e
cd ${{ needs.prepare_context.outputs.pr_path }} cd ${{ needs.prepare_context.outputs.pr_path }}
docker compose --env-file dev.env -f docker-compose.yaml up -d --build --remove-orphans docker compose --env-file dev.env -f docker-compose.yaml up -d --build --remove-orphans --wait
# ------------------------------------------------------------------ # ------------------------------------------------------------------
# STAGE 3: DEPLOY STAGING # STAGE 3: DEPLOY STAGING
@@ -91,7 +92,69 @@ jobs:
SCRIPT_AFTER: | SCRIPT_AFTER: |
set -e set -e
cd ${{ env.REMOTE_STAGING_PATH }} cd ${{ env.REMOTE_STAGING_PATH }}
docker compose --env-file staging.env -f docker-compose.yaml up -d --build --remove-orphans docker compose --env-file staging.env -f docker-compose.yaml up -d --build --remove-orphans --wait
# ------------------------------------------------------------------
# STAGE 3.5: DEPLOY PRE-PROD
# ------------------------------------------------------------------
deploy_preprod:
name: Deploy (Pre-Prod)
runs-on: ubuntu-latest
# needs: [deploy_staging]
# if: github.ref == 'refs/heads/test_preprod'
steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
- name: Deploy via Rsync & Docker
uses: easingthemes/ssh-deploy@a1aa0b6cf96ce2406eef90faa35007a4a7bf0ac0 # v5.1.1
env:
SSH_PRIVATE_KEY: ${{ env.SSH_PRIVATE_KEY }}
REMOTE_HOST: ${{ env.SSH_HOST }}
REMOTE_USER: ${{ env.SSH_USER }}
REMOTE_PORT: ${{ env.SSH_PORT }}
TARGET: ${{ env.REMOTE_PREPROD_PATH }}
EXCLUDE: ".git/, .github/"
SCRIPT_BEFORE: |
mkdir -p ${{ env.REMOTE_PREPROD_PATH }}
SCRIPT_AFTER: |
set -e
cd ${{ env.REMOTE_PREPROD_PATH }}
docker compose --env-file preprod.env -f docker-compose.yaml -f docker-compose.prod.yaml up -d --build --remove-orphans --wait
- name: Run E2E Tests
uses: appleboy/ssh-action@823bd89e131d8d508129f9443cad5855e9ba96f0 # v1.2.4
with:
host: ${{ env.SSH_HOST }}
username: ${{ env.SSH_USER }}
key: ${{ env.SSH_PRIVATE_KEY }}
port: ${{ env.SSH_PORT }}
script: |
set -e
cd ${{ env.REMOTE_PREPROD_PATH }}
echo "Running E2E tests..."
python3 -m venv .venv
. .venv/bin/activate
# Export env vars
set -a
. preprod.env
set +a
pip install -r tests/e2e/requirements.txt
# Run tests
if pytest tests/e2e/; then
echo "Tests passed!"
# Cleanup on success
docker compose --env-file preprod.env -f docker-compose.yaml -f docker-compose.prod.yaml down --remove-orphans
else
echo "Tests failed!"
# Optional: Cleanup on failure? Or keep for debugging?
# User's previous script had it after, implying it runs if pytest succeeds (due to set -e).
# I will fail the step.
exit 1
fi
# ------------------------------------------------------------------ # ------------------------------------------------------------------
# STAGE 4: DEPLOY PRODUCTION # STAGE 4: DEPLOY PRODUCTION
@@ -99,7 +162,7 @@ jobs:
deploy_prod: deploy_prod:
name: Deploy (Production) name: Deploy (Production)
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [deploy_staging] needs: [deploy_preprod]
if: github.ref == 'refs/heads/main' if: github.ref == 'refs/heads/main'
steps: steps:
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6 - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
@@ -118,7 +181,20 @@ jobs:
SCRIPT_AFTER: | SCRIPT_AFTER: |
set -e set -e
cd ${{ env.REMOTE_PROD_PATH }} cd ${{ env.REMOTE_PROD_PATH }}
docker compose --env-file prod.env -f docker-compose.yaml -f docker-compose.prod.yaml up -d --build --remove-orphans docker compose --env-file prod.env -f docker-compose.yaml -f docker-compose.prod.yaml up -d --build --remove-orphans --wait
# Run E2E Tests
echo "Running E2E tests..."
export CI=true
# Create venv to avoid polluting system python
python3 -m venv .venv
. .venv/bin/activate
# Export env vars so pytest can see them
set -a
. prod.env
set +a
pip install -r tests/e2e/requirements.txt
pytest tests/e2e/
# ------------------------------------------------------------------ # ------------------------------------------------------------------
# CLEANUP (Using appleboy/ssh-action for pure command execution) # CLEANUP (Using appleboy/ssh-action for pure command execution)

View File

@@ -4,4 +4,6 @@ ENV=dev
NETWORK_NAME=proxy NETWORK_NAME=proxy
CERTBOT_CA_RESOLVER=https://acme-staging-v02.api.letsencrypt.org/directory CERTBOT_CA_RESOLVER=https://acme-staging-v02.api.letsencrypt.org/directory
DOMAIN=dev.kovagoadi.hu DOMAIN=dev.kovagoadi.hu
TRAEFIK_LEGACY_OPT="--providers.file.filename=/etc/traefik/forward-to-legacy-nginx.yaml" ACME_BYPASS=false
TRAEFIK_LEGACY_OPT=
# TRAEFIK_LEGACY_OPT="--providers.file.directory=/etc/traefik"

View File

@@ -1,12 +1,11 @@
services: services:
traefik9: traefik:
image: "traefik:v3.6@sha256:67622638cd88dbfcfba40159bc652ecf0aea0e032f8a3c7e3134ae7c037b9910" image: "traefik:v3.6@sha256:03650d05c2ce54959c1016c879371d20ad303ecbaecc1621f6ed231cd2e0b516"
restart: unless-stopped restart: unless-stopped
security_opt: security_opt:
- no-new-privileges:true - no-new-privileges:true
networks: networks:
- proxy - proxy
- legacy-nginx
command: command:
- "--providers.docker=true" - "--providers.docker=true"
- "--providers.docker.exposedbydefault=false" - "--providers.docker.exposedbydefault=false"
@@ -14,14 +13,17 @@ services:
- "--providers.docker.constraints=Label(`env`, `${ENV}`)" - "--providers.docker.constraints=Label(`env`, `${ENV}`)"
- "--entryPoints.web.address=:80" - "--entryPoints.web.address=:80"
- "--entryPoints.https.address=:443" - "--entryPoints.https.address=:443"
- "--entryPoints.web.allowACMEByPass=true" - "--entryPoints.web.allowACMEByPass=${ACME_BYPASS}"
- "--certificatesresolvers.letsencrypt.acme.httpchallenge=true" - "--certificatesresolvers.letsencrypt.acme.httpchallenge=true"
- "--certificatesresolvers.letsencrypt.acme.httpchallenge.entrypoint=web" - "--certificatesresolvers.letsencrypt.acme.httpchallenge.entrypoint=web"
- "--certificatesresolvers.letsencrypt.acme.email=kovagoadi@gmail.com" - "--certificatesresolvers.letsencrypt.acme.email=kovagoadi@gmail.com"
- "--certificatesresolvers.letsencrypt.acme.storage=/letsencrypt/acme.json" - "--certificatesresolvers.letsencrypt.acme.storage=/letsencrypt/acme.json"
- "--certificatesResolvers.letsencrypt.acme.caServer=${CERTBOT_CA_RESOLVER}" - "--certificatesResolvers.letsencrypt.acme.caServer=${CERTBOT_CA_RESOLVER}"
- "${TRAEFIK_LEGACY_OPT:-}" - "${TRAEFIK_LEGACY_OPT:-}"
- "--providers.file.watch=true" - "--providers.file.watch=true"
# extra_hosts:
# - "staging:${STAGING_IP:-192.168.1.85}"
# - "webserver:${LEGACY_IP:-192.168.1.85}"
ports: ports:
- "${PORT}:80" - "${PORT}:80"
- "${HTTPS_PORT}:443" - "${HTTPS_PORT}:443"
@@ -29,7 +31,7 @@ services:
volumes: volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro" - "/var/run/docker.sock:/var/run/docker.sock:ro"
- "letsencrypt:/letsencrypt" - "letsencrypt:/letsencrypt"
- "./${ENV}/forward-to-legacy-nginx.yaml:/etc/traefik/forward-to-legacy-nginx.yaml" - "./${ENV}:/etc/traefik"
whoami: whoami:
image: "traefik/whoami@sha256:200689790a0a0ea48ca45992e0450bc26ccab5307375b41c84dfc4f2475937ab" image: "traefik/whoami@sha256:200689790a0a0ea48ca45992e0450bc26ccab5307375b41c84dfc4f2475937ab"
@@ -49,8 +51,5 @@ services:
- traefik.http.routers.https.tls.certresolver=letsencrypt - traefik.http.routers.https.tls.certresolver=letsencrypt
networks: networks:
proxy: proxy:
legacy-nginx:
name: proxy
external: true
volumes: volumes:
letsencrypt: letsencrypt:

9
preprod.env Normal file
View File

@@ -0,0 +1,9 @@
PORT=8081
HTTPS_PORT=447
ENV=preprod
NETWORK_NAME=proxy
CERTBOT_CA_RESOLVER=https://acme-staging-v02.api.letsencrypt.org/directory
DOMAIN=preprod.kovagoadi.hu
ACME_BYPASS=false
TRAEFIK_LEGACY_OPT="--providers.file.directory=/etc/traefik"
CI=true

View File

@@ -2,12 +2,11 @@
tcp: tcp:
routers: routers:
# Router for LEGACY HTTPS (Passthrough) # Router for HTTPS (Passthrough)
nginx-legacy-router-secure: nginx-legacy-router-secure:
# DO NOT use "*". List the domains that Nginx manages itself. rule: "HostSNI(`*`)"
# If you use "*", Traefik's own HTTPS domains will not work.
rule: "HostSNI(`excali.kovagoadi.hu`) || HostSNI(`another-legacy.hu`)"
service: nginx-legacy-service-secure service: nginx-legacy-service-secure
# Passthrough must be true for SSL to reach Nginx encrypted
tls: tls:
passthrough: true passthrough: true
priority: 10 priority: 10
@@ -15,16 +14,18 @@ tcp:
- "https" - "https"
services: services:
# Service defining the external IP
nginx-legacy-service-secure: nginx-legacy-service-secure:
loadBalancer: loadBalancer:
servers: servers:
# This is the actual external IP and Port of your Nginx
- address: "webserver:443" - address: "webserver:443"
http: http:
routers: routers:
# 1. TRAEFIK-MANAGED ACME HANDLER (Removed manual router) # 1. TRAEFIK-MANAGED ACME HANDLER (Removed manual router)
traefik-acme-handler: traefik-acme-handler:
rule: "Host(`test-whoami.dev.kovagoadi.hu`) && PathPrefix(`/.well-known/acme-challenge/`)" rule: "Host(`test-whoami.kovagoadi.hu`) && PathPrefix(`/.well-known/acme-challenge/`)"
entryPoints: entryPoints:
- "web" - "web"
service: "acme-http@internal" # This is the internal service name service: "acme-http@internal" # This is the internal service name
@@ -34,9 +35,10 @@ http:
nginx-legacy-router: nginx-legacy-router:
rule: "HostRegexp(`^.+$`)" rule: "HostRegexp(`^.+$`)"
service: nginx-legacy-service service: nginx-legacy-service
# Low priority ensures specific containers are handled first, but before the default acme-handler
priority: 90
entryPoints: entryPoints:
- "web" - "web"
priority: 90
services: services:
nginx-legacy-service: nginx-legacy-service:

View File

@@ -0,0 +1,33 @@
http:
routers:
# Router for HTTP (Port 80)
staging:
rule: "HostRegexp(`^.+\\.staging\\.kovagoadi\\.hu$`) || HostRegexp(`^.+\\.dev\\.kovagoadi\\.hu$`)"
entryPoints:
- "web"
service: "dev-staging"
priority: 1000
services:
dev-staging:
loadBalancer:
servers:
- url: "http://staging:8080"
tcp:
routers:
# Router for HTTPS (Passthrough)
dev-staging-secure:
rule: "HostSNIRegexp(`^.+\\.staging\\.kovagoadi\\.hu$`) || HostSNIRegexp(`^.+\\.dev\\.kovagoadi\\.hu$`)"
service: "dev-staging-secure"
# Passthrough must be true for SSL to reach Nginx encrypted
tls:
passthrough: true
priority: 1000
entryPoints:
- "https"
services:
dev-staging-secure:
loadBalancer:
servers:
# Note: Ensure Traefik trusts the cert at .85 or set insecureSkipVerify
- address: "staging:445"

View File

@@ -4,4 +4,5 @@ ENV=prod
NETWORK_NAME=proxy NETWORK_NAME=proxy
CERTBOT_CA_RESOLVER=https://acme-v02.api.letsencrypt.org/directory CERTBOT_CA_RESOLVER=https://acme-v02.api.letsencrypt.org/directory
DOMAIN=kovagoadi.hu DOMAIN=kovagoadi.hu
TRAEFIK_LEGACY_OPT="--providers.file.filename=/etc/traefik/forward-to-legacy-nginx.yaml" ACME_BYPASS=true
TRAEFIK_LEGACY_OPT="--providers.file.directory=/etc/traefik"

View File

@@ -9,7 +9,7 @@ tcp:
# Passthrough must be true for SSL to reach Nginx encrypted # Passthrough must be true for SSL to reach Nginx encrypted
tls: tls:
passthrough: true passthrough: true
priority: 1 priority: 10
entryPoints: entryPoints:
- "https" - "https"
@@ -23,12 +23,20 @@ tcp:
http: http:
routers: routers:
# Router for HTTP # 1. TRAEFIK-MANAGED ACME HANDLER (Removed manual router)
traefik-acme-handler:
rule: "Host(`test-whoami.kovagoadi.hu`) && PathPrefix(`/.well-known/acme-challenge/`)"
entryPoints:
- "web"
service: "acme-http@internal" # This is the internal service name
priority: 1000 # High priority to ensure it wins
# 2. THE HTTP CATCH-ALL (Sends other ACME and HTTP to Nginx)
nginx-legacy-router: nginx-legacy-router:
rule: "HostRegexp(`^.+$`)" rule: "HostRegexp(`^.+$`)"
service: nginx-legacy-service service: nginx-legacy-service
# Low priority ensures specific containers are handled first # Low priority ensures specific containers are handled first, but before the default acme-handler
priority: 1 priority: 90
entryPoints: entryPoints:
- "web" - "web"

View File

@@ -0,0 +1,33 @@
http:
routers:
# Router for HTTP (Port 80)
staging:
rule: "HostRegexp(`^.+\\.staging\\.kovagoadi\\.hu$`) || HostRegexp(`^.+\\.dev\\.kovagoadi\\.hu$`)"
entryPoints:
- "web"
service: "dev-staging"
priority: 1000
services:
dev-staging:
loadBalancer:
servers:
- url: "http://staging:8080"
tcp:
routers:
# Router for HTTPS (Passthrough)
dev-staging-secure:
rule: "HostSNIRegexp(`^.+\\.staging\\.kovagoadi\\.hu$`) || HostSNIRegexp(`^.+\\.dev\\.kovagoadi\\.hu$`)"
service: "dev-staging-secure"
# Passthrough must be true for SSL to reach Nginx encrypted
tls:
passthrough: true
priority: 1000
entryPoints:
- "https"
services:
dev-staging-secure:
loadBalancer:
servers:
# Note: Ensure Traefik trusts the cert at .85 or set insecureSkipVerify
- address: "staging:445"

View File

@@ -4,4 +4,5 @@ ENV=staging
NETWORK_NAME=proxy NETWORK_NAME=proxy
CERTBOT_CA_RESOLVER=https://acme-staging-v02.api.letsencrypt.org/directory CERTBOT_CA_RESOLVER=https://acme-staging-v02.api.letsencrypt.org/directory
DOMAIN=staging.kovagoadi.hu DOMAIN=staging.kovagoadi.hu
ACME_BYPASS=false
TRAEFIK_LEGACY_OPT= TRAEFIK_LEGACY_OPT=

1
tests/e2e/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
__pycache__

View File

@@ -0,0 +1,2 @@
pytest
requests

221
tests/e2e/test_traefik.py Normal file
View File

@@ -0,0 +1,221 @@
import pytest
import requests
import os
# Configuration
DOMAIN = os.getenv("DOMAIN", "asdasd.kovagoadi.hu")
PORT = os.getenv("PORT", "10000")
HTTPS_PORT = os.getenv("HTTPS_PORT", "10001")
BASE_URL = f"http://127.0.0.1:{PORT}"
HTTPS_BASE_URL = f"https://127.0.0.1:{HTTPS_PORT}"
HOST_HEADER = f"test-whoami.{DOMAIN}"
@pytest.fixture(scope="session", autouse=True)
def mock_webserver():
"""Start ephemeral mock webserver containers and configure Traefik."""
import time
# Skip ephemeral mocks in CI environment; test against real services
if os.getenv("CI"):
print("CI environment detected. Skipping ephemeral mock setup; testing against real services.")
yield
return
# In CI (Docker-in-Docker), we need to use the HOST path for volumes, not the container path.
# The workflow mounts the project root to /app, but the Docker daemon is on the host.
# We pass PROJECT_ROOT env var to the test container to tell it where the files are on the HOST.
cwd = os.getenv("PROJECT_ROOT", os.getcwd())
certs_dir = os.path.join(cwd, "tests/mock_nginx/certs")
image = "nginx:alpine"
# Define mocks
mocks = [
{
"name": "mock-legacy-ephemeral",
"alias": "webserver",
"conf": os.path.join(cwd, "tests/mock_nginx/legacy.conf"),
"ports": ["80", "443"]
},
{
"name": "mock-staging-ephemeral",
"alias": "mock",
"conf": os.path.join(cwd, "tests/mock_nginx/staging.conf"),
"ports": ["8080", "445"]
}
]
# Cleanup and Start Mocks
mock_ips = {}
for mock in mocks:
subprocess.run(["docker", "rm", "-f", mock["name"]], capture_output=True)
cmd = [
"docker", "run", "-d", "--rm",
"--name", mock["name"],
"--network", "proxy",
"--network-alias", mock["alias"],
"-v", f"{mock['conf']}:/etc/nginx/nginx.conf:ro",
"-v", f"{certs_dir}:/etc/nginx/certs:ro",
image
]
print(f"Starting {mock['name']}...")
result = subprocess.run(cmd, capture_output=True, text=True)
if result.returncode != 0:
print(f"STDOUT: {result.stdout}")
print(f"STDERR: {result.stderr}")
pytest.fail(f"Failed to start {mock['name']}: {result.stderr}")
# Inspect container to get IP
inspect_cmd = ["docker", "inspect", "-f", "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}", mock["name"]]
inspect_res = subprocess.run(inspect_cmd, capture_output=True, text=True)
if inspect_res.returncode != 0:
pytest.fail(f"Failed to inspect {mock['name']}: {inspect_res.stderr}")
mock_ips[mock["alias"]] = inspect_res.stdout.strip()
print(f"{mock['name']} IP: {mock_ips[mock['alias']]}")
# Restart Traefik with IP env vars for extra_hosts
print(f"Restarting Traefik with STAGING_IP={mock_ips['mock']} and LEGACY_IP={mock_ips['webserver']}...")
env = os.environ.copy()
env["STAGING_IP"] = mock_ips["mock"]
env["LEGACY_IP"] = mock_ips["webserver"]
# In CI (Docker-in-Docker), we need to tell docker-compose that the project root
# is the HOST path (PROJECT_ROOT), not the container path (/app).
# This ensures volume mounts use the correct host paths.
if "PROJECT_ROOT" in os.environ:
env["COMPOSE_PROJECT_DIR"] = os.environ["PROJECT_ROOT"]
# We need to recreate the container to pick up extra_hosts changes
try:
subprocess.run(["docker-compose", "--env-file", "preprod.env", "up", "-d", "--force-recreate", "--no-deps", "traefik"], env=env, check=True, capture_output=True, text=True)
except subprocess.CalledProcessError as e:
print(f"Docker Compose STDOUT: {e.stdout}")
print(f"Docker Compose STDERR: {e.stderr}")
raise e
# Wait for everything to settle
time.sleep(5)
yield
print("Stopping mocks and restoring Traefik...")
for mock in mocks:
subprocess.run(["docker", "stop", mock["name"]], capture_output=True)
# Restore Traefik to default (optional)
subprocess.run(["docker-compose", "--env-file", "preprod.env", "up", "-d", "--force-recreate", "--no-deps", "traefik"], check=True)
def test_whoami_http_reachable():
"""Verify that the whoami service is reachable via HTTP."""
try:
response = requests.get(BASE_URL, headers={"Host": HOST_HEADER}, timeout=5)
assert response.status_code == 200
assert "Hostname:" in response.text
except requests.exceptions.RequestException as e:
pytest.fail(f"Failed to connect to {BASE_URL}: {e}")
import subprocess
def test_whoami_https_reachable():
"""Verify that the whoami service is reachable via HTTPS using curl (to handle SNI/DNS)."""
# We use curl because requests doesn't support --resolve easily to force SNI with custom IP
cmd = [
"curl", "-s", "-k", "--fail",
"--resolve", f"{HOST_HEADER}:{HTTPS_PORT}:127.0.0.1",
f"https://{HOST_HEADER}:{HTTPS_PORT}"
]
try:
result = subprocess.run(cmd, capture_output=True, text=True, timeout=10, check=True)
assert result.returncode == 0
except subprocess.CalledProcessError as e:
pytest.fail(f"Curl failed with exit code {e.returncode}: {e.stderr}")
except subprocess.TimeoutExpired:
pytest.fail("Curl timed out")
def test_https_redirect():
"""Verify that HTTP requests are NOT redirected to HTTPS (based on config, or check if they SHOULD be)."""
# Based on docker-compose, there is no global redirect middleware configured on the entrypoint.
# So HTTP should remain HTTP.
try:
response = requests.get(BASE_URL, headers={"Host": HOST_HEADER}, allow_redirects=False, timeout=5)
assert response.status_code == 200
except requests.exceptions.RequestException as e:
pytest.fail(f"Failed to connect to {BASE_URL}: {e}")
def test_unknown_host_404():
"""Verify that requests to an unknown host (hitting legacy-nginx catch-all) are routed to the mock."""
try:
# We use a domain that doesn't match the specific *.dev.kovagoadi.hu rules
# so it falls through to the catch-all 'nginx-legacy-router'
response = requests.get(BASE_URL + "/login", headers={"Host": "tar.kovagoadi.hu"}, timeout=5)
assert response.status_code == 200
except requests.exceptions.RequestException as e:
pytest.fail(f"Failed to connect to {BASE_URL}: {e}")
def test_unknown_host_https_passthrough():
"""Verify that HTTPS requests to an unknown host are passed through to the mock Nginx."""
# We use curl to handle SNI and self-signed certs
# unknown.com should hit the catch-all SNI router
cmd = [
"curl", "-s", "-k", "-i", "--fail",
"--resolve", f"tar.kovagoadi.hu:{HTTPS_PORT}:127.0.0.1",
f"https://tar.kovagoadi.hu:{HTTPS_PORT}/login"
]
try:
result = subprocess.run(cmd, capture_output=True, text=True, timeout=10, check=True)
assert result.returncode == 0
except subprocess.CalledProcessError as e:
pytest.fail(f"Curl failed with exit code {e.returncode}: {e.stderr}")
except subprocess.TimeoutExpired:
pytest.fail("Curl timed out")
def test_staging_http_routing():
"""Verify HTTP requests to *.staging.kovagoadi.hu are routed to the mock."""
host = "test-whoami.staging.kovagoadi.hu"
try:
response = requests.get(BASE_URL, headers={"Host": host}, timeout=5)
assert response.status_code == 200
except requests.exceptions.RequestException as e:
pytest.fail(f"Failed to connect to {BASE_URL} with host {host}: {e}")
def test_dev_http_routing():
"""Verify HTTP requests to *.dev.kovagoadi.hu are routed to the mock."""
host = "test-whoami.dev.kovagoadi.hu"
try:
response = requests.get(BASE_URL, headers={"Host": host}, timeout=5)
assert response.status_code == 200
except requests.exceptions.RequestException as e:
pytest.fail(f"Failed to connect to {BASE_URL} with host {host}: {e}")
def test_staging_https_routing():
"""Verify HTTPS requests to *.staging.kovagoadi.hu are routed to the mock."""
host = "test-whoami.staging.kovagoadi.hu"
cmd = [
"curl", "-s", "-k", "-i", "--fail",
"--resolve", f"{host}:{HTTPS_PORT}:127.0.0.1",
f"https://{host}:{HTTPS_PORT}"
]
try:
result = subprocess.run(cmd, capture_output=True, text=True, timeout=10, check=True)
assert result.returncode == 0
except subprocess.CalledProcessError as e:
pytest.fail(f"Curl failed with exit code {e.returncode}: {e.stderr}")
except subprocess.TimeoutExpired:
pytest.fail("Curl timed out")
def test_dev_https_routing():
"""Verify HTTPS requests to *.dev.kovagoadi.hu are routed to the mock."""
host = "test-whoami.dev.kovagoadi.hu"
cmd = [
"curl", "-s", "-k", "-i", "--fail",
"--resolve", f"{host}:{HTTPS_PORT}:127.0.0.1",
f"https://{host}:{HTTPS_PORT}"
]
try:
result = subprocess.run(cmd, capture_output=True, text=True, timeout=10, check=True)
assert result.returncode == 0
except subprocess.CalledProcessError as e:
pytest.fail(f"Curl failed with exit code {e.returncode}: {e.stderr}")
except subprocess.TimeoutExpired:
pytest.fail("Curl timed out")

View File

@@ -0,0 +1,19 @@
-----BEGIN CERTIFICATE-----
MIIDCzCCAfOgAwIBAgIUU5vuywVWaoDfFyee7NCy0BqXU3kwDQYJKoZIhvcNAQEL
BQAwFTETMBEGA1UEAwwKbW9jay1uZ2lueDAeFw0yNTEyMjUxNjAwMTNaFw0yNjEy
MjUxNjAwMTNaMBUxEzARBgNVBAMMCm1vY2stbmdpbngwggEiMA0GCSqGSIb3DQEB
AQUAA4IBDwAwggEKAoIBAQCaoLrs78+HbDFB/HsXTy5nqtP7V33Js0GDWxk6QkOq
qbCtd5e2fzjkFFWkFIuouLEL1+4xW5txToaCtIYhQUgwST/Wu4wLlzrueRmprTh2
oTLbpSVXn6kO7dvDinsfelcjnLNgjRkkKPRYVvnCsrr2O9gFhClWf+WKMuNP99/O
4Y7Na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x4fvw7PULgdR3hqld06E0v2qRhBV/eXFufET0nAoGAaXKncm7o2LnMIcJV3qrk
c0darLx+VWg0ILnE3/6kGSgGGnMm93tEwSX8h7Nq7QRNkVLUalVAcjm7jR9XGNsY
W8oXqsyqmntNSA2f9w4MqYO2/i/xtN830qW2nw/RLLV5avD6EkY2KrlFbrrZQr2y
q8oFyEAxJc8Kmo5ocnrPq1s=
-----END PRIVATE KEY-----

View File

@@ -0,0 +1,26 @@
events {}
http {
server {
listen 80;
server_name _;
location / {
add_header X-Mock-Service "legacy";
return 200 "Mock Nginx Legacy HTTP\n";
}
}
server {
listen 443 ssl;
server_name _;
ssl_certificate /etc/nginx/certs/server.crt;
ssl_certificate_key /etc/nginx/certs/server.key;
location / {
add_header X-Mock-Service "legacy";
return 200 "Mock Nginx Legacy HTTPS\n";
}
}
}

View File

@@ -0,0 +1,26 @@
events {}
http {
server {
listen 80;
server_name _;
location / {
add_header X-Mock-Service "true";
return 200 "Mock Nginx HTTP\n";
}
}
server {
listen 443 ssl;
server_name _;
ssl_certificate /etc/nginx/certs/server.crt;
ssl_certificate_key /etc/nginx/certs/server.key;
location / {
add_header X-Mock-Service "true";
return 200 "Mock Nginx HTTPS\n";
}
}
}

View File

@@ -0,0 +1,26 @@
events {}
http {
server {
listen 8080;
server_name _;
location / {
add_header X-Mock-Service "staging";
return 200 "Mock Nginx Staging HTTP\n";
}
}
server {
listen 445 ssl;
server_name _;
ssl_certificate /etc/nginx/certs/server.crt;
ssl_certificate_key /etc/nginx/certs/server.key;
location / {
add_header X-Mock-Service "staging";
return 200 "Mock Nginx Staging HTTPS\n";
}
}
}