From aa55cd9cd9c7046e435e72184564b7d885bf0afa Mon Sep 17 00:00:00 2001 From: "Ehsan.Asadi" Date: Tue, 30 Dec 2025 16:32:13 +0330 Subject: [PATCH] feat: improve CI/CD and make config environment-aware CI/CD Improvements (.woodpecker.yml): - Add build_args for VERSION, BUILD_DATE, PYTHON_VERSION, NODE_VERSION - Add OCI labels for better image metadata - Enable cache_from for faster builds - Enable provenance for supply chain security Configuration Improvements (rxconfig.py): - Make API_URL configurable via environment (was hardcoded localhost) - Make ports configurable via FRONTEND_PORT, BACKEND_PORT env vars - Make DATABASE_URL configurable via environment - Support both development (SQLite) and production (PostgreSQL) setups Benefits: - Better CI cache utilization - Proper image versioning and metadata - Easier deployment to different environments - No code changes needed for prod vs dev --- .woodpecker.yml | 19 +++++++++++++++++++ rxconfig.py | 15 +++++++++++---- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/.woodpecker.yml b/.woodpecker.yml index 9998022..24d0dd1 100644 --- a/.woodpecker.yml +++ b/.woodpecker.yml @@ -18,7 +18,26 @@ steps: dockerfile: Dockerfile context: . platforms: linux/amd64 + # Build arguments for Dockerfile + build_args: + - VERSION=${CI_COMMIT_SHA:0:8} + - BUILD_DATE=${CI_PIPELINE_CREATED} + - PYTHON_VERSION=3.11 + - NODE_VERSION=20 + # OCI labels for better metadata + labels: + - org.opencontainers.image.created=${CI_PIPELINE_CREATED} + - org.opencontainers.image.source=${CI_REPO_LINK} + - org.opencontainers.image.url=${CI_REPO_LINK} + - org.opencontainers.image.revision=${CI_COMMIT_SHA} + - org.opencontainers.image.version=${CI_COMMIT_SHA:0:8} + - org.opencontainers.image.title=Peikarband Landing + - org.opencontainers.image.description=Peikarband hosting platform landing page + # Cache optimization cache: true + cache_from: hub.peikarband.ir/peikarband/landing:latest + # Security & provenance + provenance: true insecure: false when: event: [push, tag, manual] diff --git a/rxconfig.py b/rxconfig.py index d854ae6..8e1e4e6 100644 --- a/rxconfig.py +++ b/rxconfig.py @@ -3,14 +3,21 @@ This file configures the Reflex application settings. """ +import os import reflex as rx +# Environment-aware configuration +API_URL = os.getenv("API_URL", "http://localhost:8000") +FRONTEND_PORT = int(os.getenv("FRONTEND_PORT", "3000")) +BACKEND_PORT = int(os.getenv("BACKEND_PORT", "8000")) +DB_URL = os.getenv("DATABASE_URL", "sqlite:///reflex.db") + config = rx.Config( app_name="peikarband", - api_url="http://localhost:8000", - frontend_port=3000, - backend_port=8000, - db_url="sqlite:///reflex.db", # Temporary, will use PostgreSQL + api_url=API_URL, + frontend_port=FRONTEND_PORT, + backend_port=BACKEND_PORT, + db_url=DB_URL, disable_plugins=["reflex.plugins.sitemap.SitemapPlugin"], stylesheets=[ "https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap",