Compare commits
129 Commits
432aa63e36
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d7dc1a37f7 | ||
|
|
5bab5afe55 | ||
|
|
33628fc4a5 | ||
|
|
bc9ad90634 | ||
|
|
7aace12809 | ||
|
|
63ae156627 | ||
|
|
208d14af3b | ||
|
|
918f48b1ee | ||
|
|
7593025e6a | ||
|
|
79e97ede79 | ||
|
|
844cb29e57 | ||
|
|
dcff4d8a72 | ||
|
|
77de0f2646 | ||
|
|
522472be65 | ||
|
|
9e52ffceac | ||
|
|
a1f53c59c7 | ||
|
|
694852a09e | ||
|
|
1852b9d321 | ||
|
|
b7a162e2d8 | ||
|
|
1fa8d53fbb | ||
|
|
6477e948be | ||
|
|
963b6cecda | ||
|
|
afff7b88da | ||
|
|
1043d9902f | ||
|
|
846c41111f | ||
|
|
99778c07be | ||
|
|
88e3f1947f | ||
|
|
4e244b1a91 | ||
|
|
aa9e6154b8 | ||
|
|
ea08dc8d9e | ||
|
|
a19f73d826 | ||
|
|
5813e6458a | ||
|
|
96ab40723e | ||
|
|
24e79770fa | ||
|
|
a5f2b1c418 | ||
|
|
7e41fff478 | ||
|
|
79b10e21d9 | ||
|
|
afd7183e31 | ||
|
|
4c09d583e7 | ||
|
|
24b78be310 | ||
|
|
a7bb756bc4 | ||
|
|
1de1ab0a23 | ||
|
|
a800d7f433 | ||
|
|
cd5960e426 | ||
|
|
ed1d18ce94 | ||
|
|
94c4e952fa | ||
|
|
17250b7615 | ||
|
|
b70c0bf466 | ||
|
|
a956c745ea | ||
|
|
062e71881d | ||
|
|
237e4583da | ||
|
|
ab62554216 | ||
|
|
dfa46aa4be | ||
|
|
4ebc169079 | ||
|
|
0eb0644d8c | ||
|
|
f953e52fd4 | ||
|
|
9a54cb4098 | ||
|
|
631c21bed5 | ||
|
|
3337ef143e | ||
|
|
222c37393f | ||
|
|
f574a90c6c | ||
|
|
6683ed1f15 | ||
|
|
2056fdb5ed | ||
|
|
2f03161423 | ||
|
|
75dc0b9a28 | ||
|
|
7b78b67ec8 | ||
|
|
5fa32903df | ||
|
|
00cd8aed90 | ||
|
|
066ce4a5c1 | ||
|
|
3d241f5269 | ||
|
|
0770278974 | ||
|
|
e795687d04 | ||
|
|
12aba3df78 | ||
|
|
ad5c43087a | ||
|
|
a5324456ec | ||
|
|
293096ca13 | ||
|
|
b9fbbe12ae | ||
|
|
97adff7c7e | ||
|
|
a5613d5d22 | ||
|
|
e49a077abd | ||
|
|
539011e3df | ||
|
|
61f6462cd8 | ||
|
|
8a0951a956 | ||
|
|
3537ba31ba | ||
|
|
ab93982675 | ||
|
|
66e7985eb4 | ||
|
|
a26e948fde | ||
|
|
cec835e77b | ||
|
|
b16e45cdd6 | ||
|
|
a0a3258f3a | ||
|
|
38effdb6a9 | ||
|
|
d24a419aa0 | ||
|
|
b33b0da6ab | ||
|
|
bd89a7b680 | ||
|
|
c1f4f2a71a | ||
|
|
0347338a30 | ||
|
|
72c127f0c2 | ||
|
|
ec7f90b0de | ||
|
|
69deeea1a3 | ||
|
|
10aed88c23 | ||
|
|
d728bd30cc | ||
|
|
703c2c9bc7 | ||
|
|
fbd2f9845c | ||
|
|
c8f69caf06 | ||
|
|
9b661d635e | ||
|
|
c4a478c20d | ||
|
|
2e96c28840 | ||
|
|
ed66aff5c0 | ||
|
|
3091de3e79 | ||
|
|
f19f60015b | ||
|
|
3e3d396409 | ||
|
|
cf6fcd4dfe | ||
|
|
15e664461d | ||
|
|
8253fa73de | ||
|
|
fdfca1c4f1 | ||
|
|
a608726db9 | ||
|
|
6fe58c3815 | ||
|
|
826447e9a2 | ||
|
|
7c1b8b90ba | ||
|
|
82af967dfc | ||
|
|
8766103637 | ||
|
|
cb64fa1da2 | ||
|
|
ff32c54269 | ||
|
|
0694d10b7a | ||
|
|
87bb61e471 | ||
|
|
dc9faa989f | ||
|
|
46df8290ec | ||
|
|
5fed68fc54 | ||
|
|
7f4d167ca6 |
152
.dockerignore
Normal file
152
.dockerignore
Normal file
@@ -0,0 +1,152 @@
|
|||||||
|
# Peikarband Platform - Docker Ignore File
|
||||||
|
# Optimize Docker build by excluding unnecessary files
|
||||||
|
|
||||||
|
# Git
|
||||||
|
.git
|
||||||
|
.gitignore
|
||||||
|
.gitattributes
|
||||||
|
|
||||||
|
# CI/CD
|
||||||
|
.github/
|
||||||
|
.gitlab-ci.yml
|
||||||
|
woodpecker.yml
|
||||||
|
.drone.yml
|
||||||
|
|
||||||
|
# IDE & Editors
|
||||||
|
.vscode/
|
||||||
|
.idea/
|
||||||
|
*.swp
|
||||||
|
*.swo
|
||||||
|
*~
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# Python
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
*$py.class
|
||||||
|
*.so
|
||||||
|
.Python
|
||||||
|
*.egg-info/
|
||||||
|
dist/
|
||||||
|
build/
|
||||||
|
*.egg
|
||||||
|
.pytest_cache/
|
||||||
|
.mypy_cache/
|
||||||
|
.coverage
|
||||||
|
htmlcov/
|
||||||
|
.tox/
|
||||||
|
.hypothesis/
|
||||||
|
*.cover
|
||||||
|
|
||||||
|
# Virtual Environment
|
||||||
|
venv/
|
||||||
|
env/
|
||||||
|
ENV/
|
||||||
|
virtualenv/
|
||||||
|
|
||||||
|
# Database
|
||||||
|
*.db
|
||||||
|
*.sqlite
|
||||||
|
*.sqlite3
|
||||||
|
reflex.db
|
||||||
|
*.dump
|
||||||
|
*.sql
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
*.log
|
||||||
|
logs/
|
||||||
|
*.out
|
||||||
|
*.err
|
||||||
|
|
||||||
|
# Environment & Secrets
|
||||||
|
.env
|
||||||
|
.env.*
|
||||||
|
!.env.example
|
||||||
|
*.pem
|
||||||
|
*.key
|
||||||
|
*.crt
|
||||||
|
secrets/
|
||||||
|
*.secret
|
||||||
|
|
||||||
|
# Documentation (exclude from container, keep only essential)
|
||||||
|
peikarband/docs/
|
||||||
|
*.md
|
||||||
|
!README.md
|
||||||
|
LICENSE
|
||||||
|
|
||||||
|
# Tests (exclude from production image)
|
||||||
|
peikarband/tests/
|
||||||
|
peikarband/config/pytest.ini
|
||||||
|
.pytest_cache/
|
||||||
|
coverage/
|
||||||
|
*.coverage
|
||||||
|
|
||||||
|
# Development
|
||||||
|
Makefile
|
||||||
|
docker-compose.yml
|
||||||
|
docker-compose.*.yml
|
||||||
|
|
||||||
|
# Kubernetes & Helm (exclude from container)
|
||||||
|
helm/
|
||||||
|
docker/docker-compose.yml
|
||||||
|
*.yaml
|
||||||
|
*.yml
|
||||||
|
!requirements.txt
|
||||||
|
!peikarband/**/*.yaml
|
||||||
|
!peikarband/**/*.yml
|
||||||
|
|
||||||
|
# Backup & Temp Files
|
||||||
|
*.bak
|
||||||
|
*.tmp
|
||||||
|
*.temp
|
||||||
|
tmp/
|
||||||
|
temp/
|
||||||
|
.cache/
|
||||||
|
|
||||||
|
# Media & Assets (exclude large files but keep necessary ones)
|
||||||
|
# Exclude root level media files
|
||||||
|
/wordpress.gif
|
||||||
|
/banner-3.gif
|
||||||
|
|
||||||
|
# Keep assets directory (now in peikarband/)
|
||||||
|
!peikarband/assets/
|
||||||
|
|
||||||
|
# Node modules (Reflex might need some)
|
||||||
|
node_modules/
|
||||||
|
npm-debug.log
|
||||||
|
yarn-error.log
|
||||||
|
package-lock.json
|
||||||
|
yarn.lock
|
||||||
|
|
||||||
|
# OS Files
|
||||||
|
Thumbs.db
|
||||||
|
.DS_Store
|
||||||
|
Desktop.ini
|
||||||
|
|
||||||
|
# Editor Configs
|
||||||
|
.editorconfig
|
||||||
|
.prettierrc
|
||||||
|
.eslintrc
|
||||||
|
|
||||||
|
# Pre-commit & Linters
|
||||||
|
.pre-commit-config.yaml
|
||||||
|
.flake8
|
||||||
|
.pylintrc
|
||||||
|
mypy.ini
|
||||||
|
.isort.cfg
|
||||||
|
|
||||||
|
# Scripts (keep only necessary ones)
|
||||||
|
peikarband/tools/scripts/*
|
||||||
|
!peikarband/tools/scripts/update-env-json.sh
|
||||||
|
*.sh
|
||||||
|
!entrypoint.sh
|
||||||
|
|
||||||
|
# Jupyter Notebooks
|
||||||
|
*.ipynb
|
||||||
|
.ipynb_checkpoints/
|
||||||
|
|
||||||
|
# Misc
|
||||||
|
TODO.md
|
||||||
|
CHANGELOG.md
|
||||||
|
CONTRIBUTING.md
|
||||||
|
.mailmap
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -65,7 +65,6 @@ temp/
|
|||||||
*.tmp
|
*.tmp
|
||||||
|
|
||||||
# Docker
|
# Docker
|
||||||
.dockerignore
|
|
||||||
|
|
||||||
# Kubernetes secrets
|
# Kubernetes secrets
|
||||||
*secret*.yaml
|
*secret*.yaml
|
||||||
|
|||||||
704
.woodpecker-back.yml
Normal file
704
.woodpecker-back.yml
Normal file
@@ -0,0 +1,704 @@
|
|||||||
|
# Woodpecker CI/CD Pipeline - Peikarband Landing
|
||||||
|
# Application build pipeline (uses pre-built base image)
|
||||||
|
|
||||||
|
variables:
|
||||||
|
- &python_image 'python:3.11-slim'
|
||||||
|
- &helm_image 'alpine/helm:latest'
|
||||||
|
- &base_image 'hub.peikarband.ir/peikarband/base:latest'
|
||||||
|
|
||||||
|
when:
|
||||||
|
- event: [push, pull_request, tag, manual]
|
||||||
|
|
||||||
|
pipeline:
|
||||||
|
# ============================================
|
||||||
|
# Stage 1: Check Base Image Availability
|
||||||
|
# ============================================
|
||||||
|
|
||||||
|
check-base-image:
|
||||||
|
image: alpine:latest
|
||||||
|
commands:
|
||||||
|
- apk add --no-cache curl
|
||||||
|
- |
|
||||||
|
echo "Checking if base image is available..."
|
||||||
|
REGISTRY="hub.peikarband.ir"
|
||||||
|
REPO="peikarband/base"
|
||||||
|
TAG="latest"
|
||||||
|
|
||||||
|
if curl -f -u "$HARBOR_USERNAME:$HARBOR_PASSWORD" \
|
||||||
|
"https://$REGISTRY/v2/$REPO/manifests/$TAG" > /dev/null 2>&1; then
|
||||||
|
echo "✓ Base image found: $REGISTRY/$REPO:$TAG"
|
||||||
|
else
|
||||||
|
echo "❌ Base image not found!"
|
||||||
|
echo "Please run .woodpecker-base.yml pipeline first to build base image"
|
||||||
|
echo "Or trigger it manually in Woodpecker UI"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
secrets: [HARBOR_USERNAME, HARBOR_PASSWORD]
|
||||||
|
when:
|
||||||
|
- event: [push, tag]
|
||||||
|
|
||||||
|
# ============================================
|
||||||
|
# Stage 2: Build Application Image
|
||||||
|
# ============================================
|
||||||
|
|
||||||
|
build-image:
|
||||||
|
image: woodpeckerci/plugin-docker-buildx
|
||||||
|
settings:
|
||||||
|
registry: hub.peikarband.ir
|
||||||
|
repo: hub.peikarband.ir/peikarband/landing
|
||||||
|
username:
|
||||||
|
from_secret: HARBOR_USERNAME
|
||||||
|
password:
|
||||||
|
from_secret: HARBOR_PASSWORD
|
||||||
|
|
||||||
|
dockerfile: docker/Dockerfile
|
||||||
|
context: .
|
||||||
|
platforms: linux/amd64
|
||||||
|
|
||||||
|
# استفاده از base image
|
||||||
|
build_args:
|
||||||
|
- BASE_IMAGE=hub.peikarband.ir/peikarband/base:latest
|
||||||
|
- VERSION=${CI_COMMIT_SHA:0:8}
|
||||||
|
- BUILD_DATE=${CI_PIPELINE_CREATED}
|
||||||
|
|
||||||
|
# فقط build میکنیم، بدون push
|
||||||
|
tags:
|
||||||
|
- ${CI_COMMIT_SHA:0:8}
|
||||||
|
|
||||||
|
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_from: type=registry,ref=hub.peikarband.ir/peikarband/landing:buildcache
|
||||||
|
cache_to: type=inline
|
||||||
|
provenance: false
|
||||||
|
|
||||||
|
# فقط build، بدون push
|
||||||
|
push: false
|
||||||
|
load: false
|
||||||
|
|
||||||
|
when:
|
||||||
|
- event: [push, tag]
|
||||||
|
branch: [main, develop]
|
||||||
|
|
||||||
|
# ============================================
|
||||||
|
# Stage 3: Push Image with Multi-Tags
|
||||||
|
# ============================================
|
||||||
|
|
||||||
|
push-image:
|
||||||
|
image: woodpeckerci/plugin-docker-buildx
|
||||||
|
settings:
|
||||||
|
registry: hub.peikarband.ir
|
||||||
|
repo: hub.peikarband.ir/peikarband/landing
|
||||||
|
username:
|
||||||
|
from_secret: HARBOR_USERNAME
|
||||||
|
password:
|
||||||
|
from_secret: HARBOR_PASSWORD
|
||||||
|
|
||||||
|
dockerfile: docker/Dockerfile
|
||||||
|
context: .
|
||||||
|
platforms: linux/amd64
|
||||||
|
|
||||||
|
build_args:
|
||||||
|
- BASE_IMAGE=hub.peikarband.ir/peikarband/base:latest
|
||||||
|
- VERSION=${CI_COMMIT_SHA:0:8}
|
||||||
|
- BUILD_DATE=${CI_PIPELINE_CREATED}
|
||||||
|
|
||||||
|
# Multi-tagging strategy
|
||||||
|
tags:
|
||||||
|
- latest
|
||||||
|
- ${CI_COMMIT_SHA:0:8}
|
||||||
|
- ${CI_COMMIT_BRANCH}
|
||||||
|
|
||||||
|
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_from: type=registry,ref=hub.peikarband.ir/peikarband/landing:buildcache
|
||||||
|
cache_to: type=inline
|
||||||
|
provenance: false
|
||||||
|
|
||||||
|
# حالا push میکنیم
|
||||||
|
push: true
|
||||||
|
|
||||||
|
when:
|
||||||
|
- event: [push, tag]
|
||||||
|
branch: [main, develop]
|
||||||
|
|
||||||
|
# ============================================
|
||||||
|
# Stage 4: Verify Push
|
||||||
|
# ============================================
|
||||||
|
|
||||||
|
verify-push:
|
||||||
|
image: alpine:latest
|
||||||
|
commands:
|
||||||
|
- apk add --no-cache curl
|
||||||
|
- |
|
||||||
|
echo "Verifying image was pushed successfully..."
|
||||||
|
sleep 3 # Wait for registry sync
|
||||||
|
|
||||||
|
REGISTRY="hub.peikarband.ir"
|
||||||
|
REPO="peikarband/landing"
|
||||||
|
TAG="${CI_COMMIT_SHA:0:8}"
|
||||||
|
|
||||||
|
if curl -f -u "$HARBOR_USERNAME:$HARBOR_PASSWORD" \
|
||||||
|
"https://$REGISTRY/v2/$REPO/manifests/$TAG" > /dev/null 2>&1; then
|
||||||
|
echo "✓ Image verified: $REGISTRY/$REPO:$TAG"
|
||||||
|
else
|
||||||
|
echo "❌ Failed to verify image push"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
secrets: [HARBOR_USERNAME, HARBOR_PASSWORD]
|
||||||
|
when:
|
||||||
|
- event: [push, tag]
|
||||||
|
branch: [main, develop]
|
||||||
|
|
||||||
|
# ============================================
|
||||||
|
# Stages below are commented for now
|
||||||
|
# Uncomment when ready to use
|
||||||
|
# ============================================
|
||||||
|
|
||||||
|
# # ============================================
|
||||||
|
# # Stage 1: Code Quality & Linting
|
||||||
|
# # ============================================
|
||||||
|
|
||||||
|
# lint-flake8:
|
||||||
|
# image: *python_image
|
||||||
|
# commands:
|
||||||
|
# - pip install --no-cache-dir flake8
|
||||||
|
# - cd peikarband
|
||||||
|
# - flake8 src/ --count --select=E9,F63,F7,F82 --show-source --statistics
|
||||||
|
# - flake8 src/ --count --max-complexity=10 --max-line-length=120 --statistics --exit-zero
|
||||||
|
# when:
|
||||||
|
# - event: [push, pull_request, tag]
|
||||||
|
|
||||||
|
# lint-black:
|
||||||
|
# image: *python_image
|
||||||
|
# commands:
|
||||||
|
# - pip install --no-cache-dir black
|
||||||
|
# - cd peikarband
|
||||||
|
# - black --check src/ || echo "⚠️ Black formatting issues found (non-blocking)"
|
||||||
|
# when:
|
||||||
|
# - event: [push, pull_request, tag]
|
||||||
|
|
||||||
|
# lint-isort:
|
||||||
|
# image: *python_image
|
||||||
|
# commands:
|
||||||
|
# - pip install --no-cache-dir isort
|
||||||
|
# - cd peikarband
|
||||||
|
# - isort --check-only src/ || echo "⚠️ Import sorting issues found (non-blocking)"
|
||||||
|
# when:
|
||||||
|
# - event: [push, pull_request, tag]
|
||||||
|
|
||||||
|
# type-check:
|
||||||
|
# image: *python_image
|
||||||
|
# commands:
|
||||||
|
# - pip install --no-cache-dir mypy types-redis types-requests
|
||||||
|
# - cd peikarband
|
||||||
|
# - mypy src/ --config-file=config/mypy.ini || echo "⚠️ Type checking issues found (non-blocking)"
|
||||||
|
# when:
|
||||||
|
# - event: [push, pull_request, tag]
|
||||||
|
|
||||||
|
# # ============================================
|
||||||
|
# # Stage 2: Security Scanning
|
||||||
|
# # ============================================
|
||||||
|
|
||||||
|
# security-bandit:
|
||||||
|
# image: *python_image
|
||||||
|
# commands:
|
||||||
|
# - pip install --no-cache-dir bandit[toml]
|
||||||
|
# - cd peikarband
|
||||||
|
# - bandit -r src/ -f json -o bandit-report.json || true
|
||||||
|
# - bandit -r src/ -ll || echo "⚠️ Security issues found (non-blocking)"
|
||||||
|
# when:
|
||||||
|
# - event: [push, pull_request, tag]
|
||||||
|
|
||||||
|
# security-safety:
|
||||||
|
# image: *python_image
|
||||||
|
# commands:
|
||||||
|
# - pip install --no-cache-dir safety
|
||||||
|
# - cd peikarband
|
||||||
|
# - safety check -r requirements.txt --json || echo "⚠️ Dependency vulnerabilities found (non-blocking)"
|
||||||
|
# when:
|
||||||
|
# - event: [push, pull_request, tag]
|
||||||
|
|
||||||
|
# # ============================================
|
||||||
|
# # Stage 3: Testing
|
||||||
|
# # ============================================
|
||||||
|
|
||||||
|
# test:
|
||||||
|
# image: *python_image
|
||||||
|
# commands:
|
||||||
|
# - apt-get update && apt-get install -y --no-install-recommends curl
|
||||||
|
# - pip install --no-cache-dir -r peikarband/requirements.txt
|
||||||
|
# - pip install --no-cache-dir -r peikarband/requirements-dev.txt
|
||||||
|
# - cd peikarband
|
||||||
|
# - pytest tests/ -v --cov=src --cov-report=term-missing --cov-report=xml || echo "⚠️ Tests failed (non-blocking)"
|
||||||
|
# when:
|
||||||
|
# - event: [push, pull_request, tag]
|
||||||
|
|
||||||
|
# # ============================================
|
||||||
|
# # Stage 4: Helm Validation
|
||||||
|
# # ============================================
|
||||||
|
|
||||||
|
# helm-lint:
|
||||||
|
# image: *helm_image
|
||||||
|
# commands:
|
||||||
|
# - helm version
|
||||||
|
# - helm lint helm/peikarband
|
||||||
|
# - echo "✓ Helm chart validation passed"
|
||||||
|
# when:
|
||||||
|
# - event: [push, pull_request, tag]
|
||||||
|
|
||||||
|
# helm-template:
|
||||||
|
# image: *helm_image
|
||||||
|
# commands:
|
||||||
|
# - helm template peikarband helm/peikarband -f helm/peikarband/values-production.yaml --debug > /dev/null
|
||||||
|
# - echo "✓ Helm template rendering successful"
|
||||||
|
# when:
|
||||||
|
# - event: [push, pull_request, tag]
|
||||||
|
|
||||||
|
# # ============================================
|
||||||
|
# # Stage 6: Deployment - Staging
|
||||||
|
# # ============================================
|
||||||
|
|
||||||
|
# deploy-staging:
|
||||||
|
# image: *helm_image
|
||||||
|
# commands:
|
||||||
|
# - apk add --no-cache kubectl
|
||||||
|
# - echo "$KUBECONFIG_STAGING" | base64 -d > /tmp/kubeconfig
|
||||||
|
# - export KUBECONFIG=/tmp/kubeconfig
|
||||||
|
# - |
|
||||||
|
# helm upgrade --install peikarband-staging helm/peikarband \
|
||||||
|
# --namespace staging \
|
||||||
|
# --create-namespace \
|
||||||
|
# --set image.repository=hub.peikarband.ir/peikarband/landing \
|
||||||
|
# --set image.tag=${CI_COMMIT_SHA:0:8} \
|
||||||
|
# --set image.pullPolicy=Always \
|
||||||
|
# --values helm/peikarband/values-staging.yaml \
|
||||||
|
# --wait \
|
||||||
|
# --timeout 5m
|
||||||
|
# - kubectl get pods -n staging
|
||||||
|
# - echo "✓ Deployed to staging successfully"
|
||||||
|
# secrets: [KUBECONFIG_STAGING]
|
||||||
|
# when:
|
||||||
|
# - event: push
|
||||||
|
# branch: [main, develop]
|
||||||
|
|
||||||
|
# # ============================================
|
||||||
|
# # Stage 7: Deployment - Production
|
||||||
|
# # ============================================
|
||||||
|
|
||||||
|
# deploy-production:
|
||||||
|
# image: *helm_image
|
||||||
|
# commands:
|
||||||
|
# - apk add --no-cache kubectl
|
||||||
|
# - echo "$KUBECONFIG_PRODUCTION" | base64 -d > /tmp/kubeconfig
|
||||||
|
# - export KUBECONFIG=/tmp/kubeconfig
|
||||||
|
# - |
|
||||||
|
# helm upgrade --install peikarband helm/peikarband \
|
||||||
|
# --namespace production \
|
||||||
|
# --create-namespace \
|
||||||
|
# --set image.repository=hub.peikarband.ir/peikarband/landing \
|
||||||
|
# --set image.tag=${CI_COMMIT_TAG} \
|
||||||
|
# --set image.pullPolicy=Always \
|
||||||
|
# --values helm/peikarband/values-production.yaml \
|
||||||
|
# --wait \
|
||||||
|
# --timeout 10m
|
||||||
|
# - kubectl rollout status deployment/peikarband -n production
|
||||||
|
# - kubectl get pods -n production
|
||||||
|
# - echo "✓ Deployed to production successfully"
|
||||||
|
# secrets: [KUBECONFIG_PRODUCTION]
|
||||||
|
# when:
|
||||||
|
# - event: tag
|
||||||
|
# ref: refs/tags/v*
|
||||||
|
|
||||||
|
# # ============================================
|
||||||
|
# # Stage 8: Notifications
|
||||||
|
# # ============================================
|
||||||
|
|
||||||
|
# notify-success:
|
||||||
|
# image: alpine:latest
|
||||||
|
# commands:
|
||||||
|
# - echo "🎉 Pipeline completed successfully!"
|
||||||
|
# - echo "Branch: ${CI_COMMIT_BRANCH}"
|
||||||
|
# - echo "Commit: ${CI_COMMIT_SHA:0:8}"
|
||||||
|
# - echo "Image: hub.peikarband.ir/peikarband/landing:${CI_COMMIT_SHA:0:8}"
|
||||||
|
# when:
|
||||||
|
# - event: [push, tag]
|
||||||
|
# status: success
|
||||||
|
|
||||||
|
# notify-failure:
|
||||||
|
# image: alpine:latest
|
||||||
|
# commands:
|
||||||
|
# - echo "❌ Pipeline failed!"
|
||||||
|
# - echo "Branch: ${CI_COMMIT_BRANCH}"
|
||||||
|
# - echo "Commit: ${CI_COMMIT_SHA:0:8}"
|
||||||
|
# - echo "Please check the logs above"
|
||||||
|
# when:
|
||||||
|
# - event: [push, tag]
|
||||||
|
# status: failure
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Woodpecker CI/CD Pipeline - Peikarband Landing
|
||||||
|
# Application build pipeline (uses pre-built base image)
|
||||||
|
|
||||||
|
variables:
|
||||||
|
- &python_image 'python:3.11-slim'
|
||||||
|
- &helm_image 'alpine/helm:latest'
|
||||||
|
- &base_image 'hub.peikarband.ir/peikarband/base:latest'
|
||||||
|
|
||||||
|
when:
|
||||||
|
- event: [push, pull_request, tag, manual]
|
||||||
|
|
||||||
|
pipeline:
|
||||||
|
# ============================================
|
||||||
|
# Stage 1: Check Base Image Availability
|
||||||
|
# ============================================
|
||||||
|
|
||||||
|
check-base-image:
|
||||||
|
image: alpine:latest
|
||||||
|
commands:
|
||||||
|
- apk add --no-cache curl
|
||||||
|
- |
|
||||||
|
echo "Checking if base image is available..."
|
||||||
|
REGISTRY="hub.peikarband.ir"
|
||||||
|
REPO="peikarband/base"
|
||||||
|
TAG="latest"
|
||||||
|
|
||||||
|
if curl -f -u "$HARBOR_USERNAME:$HARBOR_PASSWORD" \
|
||||||
|
"https://$REGISTRY/v2/$REPO/manifests/$TAG" > /dev/null 2>&1; then
|
||||||
|
echo "✓ Base image found: $REGISTRY/$REPO:$TAG"
|
||||||
|
else
|
||||||
|
echo "❌ Base image not found!"
|
||||||
|
echo "Please run .woodpecker-base.yml pipeline first to build base image"
|
||||||
|
echo "Or trigger it manually in Woodpecker UI"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
secrets: [HARBOR_USERNAME, HARBOR_PASSWORD]
|
||||||
|
when:
|
||||||
|
- event: [push, tag]
|
||||||
|
|
||||||
|
# ============================================
|
||||||
|
# Stage 2: Build Application Image
|
||||||
|
# ============================================
|
||||||
|
|
||||||
|
build-image:
|
||||||
|
image: woodpeckerci/plugin-docker-buildx
|
||||||
|
settings:
|
||||||
|
registry: hub.peikarband.ir
|
||||||
|
repo: hub.peikarband.ir/peikarband/landing
|
||||||
|
username:
|
||||||
|
from_secret: HARBOR_USERNAME
|
||||||
|
password:
|
||||||
|
from_secret: HARBOR_PASSWORD
|
||||||
|
|
||||||
|
dockerfile: docker/Dockerfile
|
||||||
|
context: .
|
||||||
|
platforms: linux/amd64
|
||||||
|
|
||||||
|
# استفاده از base image
|
||||||
|
build_args:
|
||||||
|
- BASE_IMAGE=hub.peikarband.ir/peikarband/base:latest
|
||||||
|
- VERSION=${CI_COMMIT_SHA:0:8}
|
||||||
|
- BUILD_DATE=${CI_PIPELINE_CREATED}
|
||||||
|
|
||||||
|
# فقط build میکنیم، بدون push
|
||||||
|
tags:
|
||||||
|
- ${CI_COMMIT_SHA:0:8}
|
||||||
|
|
||||||
|
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_from: type=registry,ref=hub.peikarband.ir/peikarband/landing:buildcache
|
||||||
|
cache_to: type=inline
|
||||||
|
provenance: false
|
||||||
|
|
||||||
|
# فقط build، بدون push
|
||||||
|
push: false
|
||||||
|
load: false
|
||||||
|
|
||||||
|
when:
|
||||||
|
- event: [push, tag]
|
||||||
|
branch: [main, develop]
|
||||||
|
|
||||||
|
# ============================================
|
||||||
|
# Stage 3: Push Image with Multi-Tags
|
||||||
|
# ============================================
|
||||||
|
|
||||||
|
push-image:
|
||||||
|
image: woodpeckerci/plugin-docker-buildx
|
||||||
|
settings:
|
||||||
|
registry: hub.peikarband.ir
|
||||||
|
repo: hub.peikarband.ir/peikarband/landing
|
||||||
|
username:
|
||||||
|
from_secret: HARBOR_USERNAME
|
||||||
|
password:
|
||||||
|
from_secret: HARBOR_PASSWORD
|
||||||
|
|
||||||
|
dockerfile: docker/Dockerfile
|
||||||
|
context: .
|
||||||
|
platforms: linux/amd64
|
||||||
|
|
||||||
|
build_args:
|
||||||
|
- BASE_IMAGE=hub.peikarband.ir/peikarband/base:latest
|
||||||
|
- VERSION=${CI_COMMIT_SHA:0:8}
|
||||||
|
- BUILD_DATE=${CI_PIPELINE_CREATED}
|
||||||
|
|
||||||
|
# Multi-tagging strategy
|
||||||
|
tags:
|
||||||
|
- latest
|
||||||
|
- ${CI_COMMIT_SHA:0:8}
|
||||||
|
- ${CI_COMMIT_BRANCH}
|
||||||
|
|
||||||
|
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_from: type=registry,ref=hub.peikarband.ir/peikarband/landing:buildcache
|
||||||
|
cache_to: type=inline
|
||||||
|
provenance: false
|
||||||
|
|
||||||
|
# حالا push میکنیم
|
||||||
|
push: true
|
||||||
|
|
||||||
|
when:
|
||||||
|
- event: [push, tag]
|
||||||
|
branch: [main, develop]
|
||||||
|
|
||||||
|
# ============================================
|
||||||
|
# Stage 4: Verify Push
|
||||||
|
# ============================================
|
||||||
|
|
||||||
|
verify-push:
|
||||||
|
image: alpine:latest
|
||||||
|
commands:
|
||||||
|
- apk add --no-cache curl
|
||||||
|
- |
|
||||||
|
echo "Verifying image was pushed successfully..."
|
||||||
|
sleep 3 # Wait for registry sync
|
||||||
|
|
||||||
|
REGISTRY="hub.peikarband.ir"
|
||||||
|
REPO="peikarband/landing"
|
||||||
|
TAG="${CI_COMMIT_SHA:0:8}"
|
||||||
|
|
||||||
|
if curl -f -u "$HARBOR_USERNAME:$HARBOR_PASSWORD" \
|
||||||
|
"https://$REGISTRY/v2/$REPO/manifests/$TAG" > /dev/null 2>&1; then
|
||||||
|
echo "✓ Image verified: $REGISTRY/$REPO:$TAG"
|
||||||
|
else
|
||||||
|
echo "❌ Failed to verify image push"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
secrets: [HARBOR_USERNAME, HARBOR_PASSWORD]
|
||||||
|
when:
|
||||||
|
- event: [push, tag]
|
||||||
|
branch: [main, develop]
|
||||||
|
|
||||||
|
# ============================================
|
||||||
|
# Stages below are commented for now
|
||||||
|
# Uncomment when ready to use
|
||||||
|
# ============================================
|
||||||
|
|
||||||
|
# # ============================================
|
||||||
|
# # Stage 1: Code Quality & Linting
|
||||||
|
# # ============================================
|
||||||
|
|
||||||
|
# lint-flake8:
|
||||||
|
# image: *python_image
|
||||||
|
# commands:
|
||||||
|
# - pip install --no-cache-dir flake8
|
||||||
|
# - cd peikarband
|
||||||
|
# - flake8 src/ --count --select=E9,F63,F7,F82 --show-source --statistics
|
||||||
|
# - flake8 src/ --count --max-complexity=10 --max-line-length=120 --statistics --exit-zero
|
||||||
|
# when:
|
||||||
|
# - event: [push, pull_request, tag]
|
||||||
|
|
||||||
|
# lint-black:
|
||||||
|
# image: *python_image
|
||||||
|
# commands:
|
||||||
|
# - pip install --no-cache-dir black
|
||||||
|
# - cd peikarband
|
||||||
|
# - black --check src/ || echo "⚠️ Black formatting issues found (non-blocking)"
|
||||||
|
# when:
|
||||||
|
# - event: [push, pull_request, tag]
|
||||||
|
|
||||||
|
# lint-isort:
|
||||||
|
# image: *python_image
|
||||||
|
# commands:
|
||||||
|
# - pip install --no-cache-dir isort
|
||||||
|
# - cd peikarband
|
||||||
|
# - isort --check-only src/ || echo "⚠️ Import sorting issues found (non-blocking)"
|
||||||
|
# when:
|
||||||
|
# - event: [push, pull_request, tag]
|
||||||
|
|
||||||
|
# type-check:
|
||||||
|
# image: *python_image
|
||||||
|
# commands:
|
||||||
|
# - pip install --no-cache-dir mypy types-redis types-requests
|
||||||
|
# - cd peikarband
|
||||||
|
# - mypy src/ --config-file=config/mypy.ini || echo "⚠️ Type checking issues found (non-blocking)"
|
||||||
|
# when:
|
||||||
|
# - event: [push, pull_request, tag]
|
||||||
|
|
||||||
|
# # ============================================
|
||||||
|
# # Stage 2: Security Scanning
|
||||||
|
# # ============================================
|
||||||
|
|
||||||
|
# security-bandit:
|
||||||
|
# image: *python_image
|
||||||
|
# commands:
|
||||||
|
# - pip install --no-cache-dir bandit[toml]
|
||||||
|
# - cd peikarband
|
||||||
|
# - bandit -r src/ -f json -o bandit-report.json || true
|
||||||
|
# - bandit -r src/ -ll || echo "⚠️ Security issues found (non-blocking)"
|
||||||
|
# when:
|
||||||
|
# - event: [push, pull_request, tag]
|
||||||
|
|
||||||
|
# security-safety:
|
||||||
|
# image: *python_image
|
||||||
|
# commands:
|
||||||
|
# - pip install --no-cache-dir safety
|
||||||
|
# - cd peikarband
|
||||||
|
# - safety check -r requirements.txt --json || echo "⚠️ Dependency vulnerabilities found (non-blocking)"
|
||||||
|
# when:
|
||||||
|
# - event: [push, pull_request, tag]
|
||||||
|
|
||||||
|
# # ============================================
|
||||||
|
# # Stage 3: Testing
|
||||||
|
# # ============================================
|
||||||
|
|
||||||
|
# test:
|
||||||
|
# image: *python_image
|
||||||
|
# commands:
|
||||||
|
# - apt-get update && apt-get install -y --no-install-recommends curl
|
||||||
|
# - pip install --no-cache-dir -r peikarband/requirements.txt
|
||||||
|
# - pip install --no-cache-dir -r peikarband/requirements-dev.txt
|
||||||
|
# - cd peikarband
|
||||||
|
# - pytest tests/ -v --cov=src --cov-report=term-missing --cov-report=xml || echo "⚠️ Tests failed (non-blocking)"
|
||||||
|
# when:
|
||||||
|
# - event: [push, pull_request, tag]
|
||||||
|
|
||||||
|
# # ============================================
|
||||||
|
# # Stage 4: Helm Validation
|
||||||
|
# # ============================================
|
||||||
|
|
||||||
|
# helm-lint:
|
||||||
|
# image: *helm_image
|
||||||
|
# commands:
|
||||||
|
# - helm version
|
||||||
|
# - helm lint helm/peikarband
|
||||||
|
# - echo "✓ Helm chart validation passed"
|
||||||
|
# when:
|
||||||
|
# - event: [push, pull_request, tag]
|
||||||
|
|
||||||
|
# helm-template:
|
||||||
|
# image: *helm_image
|
||||||
|
# commands:
|
||||||
|
# - helm template peikarband helm/peikarband -f helm/peikarband/values-production.yaml --debug > /dev/null
|
||||||
|
# - echo "✓ Helm template rendering successful"
|
||||||
|
# when:
|
||||||
|
# - event: [push, pull_request, tag]
|
||||||
|
|
||||||
|
# # ============================================
|
||||||
|
# # Stage 6: Deployment - Staging
|
||||||
|
# # ============================================
|
||||||
|
|
||||||
|
# deploy-staging:
|
||||||
|
# image: *helm_image
|
||||||
|
# commands:
|
||||||
|
# - apk add --no-cache kubectl
|
||||||
|
# - echo "$KUBECONFIG_STAGING" | base64 -d > /tmp/kubeconfig
|
||||||
|
# - export KUBECONFIG=/tmp/kubeconfig
|
||||||
|
# - |
|
||||||
|
# helm upgrade --install peikarband-staging helm/peikarband \
|
||||||
|
# --namespace staging \
|
||||||
|
# --create-namespace \
|
||||||
|
# --set image.repository=hub.peikarband.ir/peikarband/landing \
|
||||||
|
# --set image.tag=${CI_COMMIT_SHA:0:8} \
|
||||||
|
# --set image.pullPolicy=Always \
|
||||||
|
# --values helm/peikarband/values-staging.yaml \
|
||||||
|
# --wait \
|
||||||
|
# --timeout 5m
|
||||||
|
# - kubectl get pods -n staging
|
||||||
|
# - echo "✓ Deployed to staging successfully"
|
||||||
|
# secrets: [KUBECONFIG_STAGING]
|
||||||
|
# when:
|
||||||
|
# - event: push
|
||||||
|
# branch: [main, develop]
|
||||||
|
|
||||||
|
# # ============================================
|
||||||
|
# # Stage 7: Deployment - Production
|
||||||
|
# # ============================================
|
||||||
|
|
||||||
|
# deploy-production:
|
||||||
|
# image: *helm_image
|
||||||
|
# commands:
|
||||||
|
# - apk add --no-cache kubectl
|
||||||
|
# - echo "$KUBECONFIG_PRODUCTION" | base64 -d > /tmp/kubeconfig
|
||||||
|
# - export KUBECONFIG=/tmp/kubeconfig
|
||||||
|
# - |
|
||||||
|
# helm upgrade --install peikarband helm/peikarband \
|
||||||
|
# --namespace production \
|
||||||
|
# --create-namespace \
|
||||||
|
# --set image.repository=hub.peikarband.ir/peikarband/landing \
|
||||||
|
# --set image.tag=${CI_COMMIT_TAG} \
|
||||||
|
# --set image.pullPolicy=Always \
|
||||||
|
# --values helm/peikarband/values-production.yaml \
|
||||||
|
# --wait \
|
||||||
|
# --timeout 10m
|
||||||
|
# - kubectl rollout status deployment/peikarband -n production
|
||||||
|
# - kubectl get pods -n production
|
||||||
|
# - echo "✓ Deployed to production successfully"
|
||||||
|
# secrets: [KUBECONFIG_PRODUCTION]
|
||||||
|
# when:
|
||||||
|
# - event: tag
|
||||||
|
# ref: refs/tags/v*
|
||||||
|
|
||||||
|
# # ============================================
|
||||||
|
# # Stage 8: Notifications
|
||||||
|
# # ============================================
|
||||||
|
|
||||||
|
# notify-success:
|
||||||
|
# image: alpine:latest
|
||||||
|
# commands:
|
||||||
|
# - echo "🎉 Pipeline completed successfully!"
|
||||||
|
# - echo "Branch: ${CI_COMMIT_BRANCH}"
|
||||||
|
# - echo "Commit: ${CI_COMMIT_SHA:0:8}"
|
||||||
|
# - echo "Image: hub.peikarband.ir/peikarband/landing:${CI_COMMIT_SHA:0:8}"
|
||||||
|
# when:
|
||||||
|
# - event: [push, tag]
|
||||||
|
# status: success
|
||||||
|
|
||||||
|
# notify-failure:
|
||||||
|
# image: alpine:latest
|
||||||
|
# commands:
|
||||||
|
# - echo "❌ Pipeline failed!"
|
||||||
|
# - echo "Branch: ${CI_COMMIT_BRANCH}"
|
||||||
|
# - echo "Commit: ${CI_COMMIT_SHA:0:8}"
|
||||||
|
# - echo "Please check the logs above"
|
||||||
|
# when:
|
||||||
|
# - event: [push, tag]
|
||||||
|
# status: failure
|
||||||
|
|
||||||
414
.woodpecker.yml
414
.woodpecker.yml
@@ -1,100 +1,74 @@
|
|||||||
# Woodpecker CI/CD Pipeline - Peikarband Landing
|
# Woodpecker CI/CD Pipeline - Peikarband Landing
|
||||||
# Application build pipeline (uses pre-built base image)
|
# Smart pipeline with base image management
|
||||||
|
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
- &python_image 'python:3.11-slim'
|
- &base_image 'hub.peikarband.ir/peikarband/landing:base'
|
||||||
- &helm_image 'alpine/helm:latest'
|
- &app_image 'hub.peikarband.ir/peikarband/landing'
|
||||||
- &base_image 'hub.peikarband.ir/peikarband/base:latest'
|
|
||||||
|
|
||||||
when:
|
when:
|
||||||
- event: [push, pull_request, tag, manual]
|
- event: [push, pull_request, tag, manual]
|
||||||
|
|
||||||
pipeline:
|
steps:
|
||||||
# ============================================
|
# ============================================
|
||||||
# Stage 1: Check Base Image Availability
|
# Ensure Base Image Exists
|
||||||
# ============================================
|
# ============================================
|
||||||
|
|
||||||
check-base-image:
|
ensure-base-image:
|
||||||
image: alpine:latest
|
|
||||||
commands:
|
|
||||||
- apk add --no-cache curl
|
|
||||||
- |
|
|
||||||
echo "Checking if base image is available..."
|
|
||||||
REGISTRY="hub.peikarband.ir"
|
|
||||||
REPO="peikarband/base"
|
|
||||||
TAG="latest"
|
|
||||||
|
|
||||||
if curl -f -u "$HARBOR_USERNAME:$HARBOR_PASSWORD" \
|
|
||||||
"https://$REGISTRY/v2/$REPO/manifests/$TAG" > /dev/null 2>&1; then
|
|
||||||
echo "✓ Base image found: $REGISTRY/$REPO:$TAG"
|
|
||||||
else
|
|
||||||
echo "❌ Base image not found!"
|
|
||||||
echo "Please run .woodpecker-base.yml pipeline first to build base image"
|
|
||||||
echo "Or trigger it manually in Woodpecker UI"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
secrets: [HARBOR_USERNAME, HARBOR_PASSWORD]
|
|
||||||
when:
|
|
||||||
- event: [push, tag]
|
|
||||||
|
|
||||||
# ============================================
|
|
||||||
# Stage 2: Build Application Image
|
|
||||||
# ============================================
|
|
||||||
|
|
||||||
build-image:
|
|
||||||
image: woodpeckerci/plugin-docker-buildx
|
image: woodpeckerci/plugin-docker-buildx
|
||||||
settings:
|
settings:
|
||||||
registry: hub.peikarband.ir
|
registry: hub.peikarband.ir
|
||||||
repo: hub.peikarband.ir/peikarband/landing
|
repo: *app_image
|
||||||
username:
|
# username:
|
||||||
from_secret: HARBOR_USERNAME
|
# from_secret: HARBOR_USERNAME
|
||||||
password:
|
# password:
|
||||||
from_secret: HARBOR_PASSWORD
|
# from_secret: HARBOR_PASSWORD
|
||||||
|
username: admin
|
||||||
dockerfile: docker/Dockerfile
|
password: 5459ed7590d37656410fae38bdf59eb7ee33b68cd4c
|
||||||
|
dockerfile: docker/Dockerfile.base
|
||||||
context: .
|
context: .
|
||||||
platforms: linux/amd64
|
platforms: linux/amd64
|
||||||
|
|
||||||
# استفاده از base image
|
|
||||||
build_args:
|
|
||||||
- BASE_IMAGE=hub.peikarband.ir/peikarband/base:latest
|
|
||||||
- VERSION=${CI_COMMIT_SHA:0:8}
|
|
||||||
- BUILD_DATE=${CI_PIPELINE_CREATED}
|
|
||||||
|
|
||||||
# فقط build میکنیم، بدون push
|
|
||||||
tags:
|
tags:
|
||||||
- ${CI_COMMIT_SHA:0:8}
|
- base
|
||||||
|
|
||||||
|
build_args:
|
||||||
|
- PYTHON_VERSION=3.11
|
||||||
|
- NODE_VERSION=20
|
||||||
|
- BUILD_DATE=${CI_PIPELINE_CREATED}
|
||||||
|
- VERSION=${CI_COMMIT_SHA:0:8}
|
||||||
|
|
||||||
labels:
|
labels:
|
||||||
- org.opencontainers.image.created=${CI_PIPELINE_CREATED}
|
- org.opencontainers.image.created=${CI_PIPELINE_CREATED}
|
||||||
- org.opencontainers.image.source=${CI_REPO_LINK}
|
- org.opencontainers.image.source=${CI_REPO_LINK}
|
||||||
- org.opencontainers.image.url=${CI_REPO_LINK}
|
- org.opencontainers.image.title=Peikarband Base
|
||||||
- org.opencontainers.image.revision=${CI_COMMIT_SHA}
|
- org.opencontainers.image.description=Base image with Python, Node.js, bun, and build tools
|
||||||
- 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_from: type=registry,ref=hub.peikarband.ir/peikarband/landing:buildcache
|
cache: inline
|
||||||
cache_to: type=inline
|
provenance: true
|
||||||
provenance: false
|
sbom: true
|
||||||
|
push: true
|
||||||
# فقط build، بدون push
|
|
||||||
push: false
|
|
||||||
load: false
|
|
||||||
|
|
||||||
when:
|
when:
|
||||||
- event: [push, tag]
|
event: [push, tag, manual]
|
||||||
branch: [main, develop]
|
branch: [main, develop]
|
||||||
|
# Only rebuild base if its definition changed
|
||||||
|
path:
|
||||||
|
include:
|
||||||
|
- docker/Dockerfile.base
|
||||||
|
- .woodpecker.yml
|
||||||
|
|
||||||
# ============================================
|
# ============================================
|
||||||
# Stage 3: Push Image with Multi-Tags
|
# Build Application Image
|
||||||
# ============================================
|
# ============================================
|
||||||
|
|
||||||
push-image:
|
build-and-push-app:
|
||||||
image: woodpeckerci/plugin-docker-buildx
|
image: woodpeckerci/plugin-docker-buildx
|
||||||
settings:
|
settings:
|
||||||
|
debug: true
|
||||||
|
log-level: debug
|
||||||
registry: hub.peikarband.ir
|
registry: hub.peikarband.ir
|
||||||
repo: hub.peikarband.ir/peikarband/landing
|
repo: *app_image
|
||||||
username:
|
username:
|
||||||
from_secret: HARBOR_USERNAME
|
from_secret: HARBOR_USERNAME
|
||||||
password:
|
password:
|
||||||
@@ -105,11 +79,10 @@ pipeline:
|
|||||||
platforms: linux/amd64
|
platforms: linux/amd64
|
||||||
|
|
||||||
build_args:
|
build_args:
|
||||||
- BASE_IMAGE=hub.peikarband.ir/peikarband/base:latest
|
- BASE_IMAGE=*base_image
|
||||||
- VERSION=${CI_COMMIT_SHA:0:8}
|
- VERSION=${CI_COMMIT_SHA:0:8}
|
||||||
- BUILD_DATE=${CI_PIPELINE_CREATED}
|
- BUILD_DATE=${CI_PIPELINE_CREATED}
|
||||||
|
|
||||||
# Multi-tagging strategy
|
|
||||||
tags:
|
tags:
|
||||||
- latest
|
- latest
|
||||||
- ${CI_COMMIT_SHA:0:8}
|
- ${CI_COMMIT_SHA:0:8}
|
||||||
@@ -124,227 +97,110 @@ pipeline:
|
|||||||
- org.opencontainers.image.title=Peikarband Landing
|
- org.opencontainers.image.title=Peikarband Landing
|
||||||
- org.opencontainers.image.description=Peikarband hosting platform landing page
|
- org.opencontainers.image.description=Peikarband hosting platform landing page
|
||||||
|
|
||||||
cache_from: type=registry,ref=hub.peikarband.ir/peikarband/landing:buildcache
|
# cache: inline
|
||||||
cache_to: type=inline
|
# provenance: true
|
||||||
provenance: false
|
# sbom: true
|
||||||
|
push: true
|
||||||
# حالا push میکنیم
|
# Cache configuration - using inline cache instead of registry cache
|
||||||
push: true
|
# cache_from: type=registry,ref=hub.peikarband.ir/peikarband/landing:cache
|
||||||
|
# cache_to: type=registry,ref=hub.peikarband.ir/peikarband/landing:cache,mode=max
|
||||||
|
|
||||||
when:
|
when:
|
||||||
- event: [push, tag]
|
event: [push, tag]
|
||||||
branch: [main, develop]
|
branch: [main, develop,]
|
||||||
|
|
||||||
# ============================================
|
|
||||||
# Stage 4: Verify Push
|
|
||||||
# ============================================
|
|
||||||
|
|
||||||
verify-push:
|
|
||||||
image: alpine:latest
|
|
||||||
commands:
|
|
||||||
- apk add --no-cache curl
|
|
||||||
- |
|
|
||||||
echo "Verifying image was pushed successfully..."
|
|
||||||
sleep 3 # Wait for registry sync
|
|
||||||
|
|
||||||
REGISTRY="hub.peikarband.ir"
|
|
||||||
REPO="peikarband/landing"
|
|
||||||
TAG="${CI_COMMIT_SHA:0:8}"
|
|
||||||
|
|
||||||
if curl -f -u "$HARBOR_USERNAME:$HARBOR_PASSWORD" \
|
|
||||||
"https://$REGISTRY/v2/$REPO/manifests/$TAG" > /dev/null 2>&1; then
|
|
||||||
echo "✓ Image verified: $REGISTRY/$REPO:$TAG"
|
|
||||||
else
|
|
||||||
echo "❌ Failed to verify image push"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
secrets: [HARBOR_USERNAME, HARBOR_PASSWORD]
|
|
||||||
when:
|
|
||||||
- event: [push, tag]
|
|
||||||
branch: [main, develop]
|
|
||||||
|
|
||||||
# ============================================
|
|
||||||
# Stages below are commented for now
|
|
||||||
# Uncomment when ready to use
|
|
||||||
# ============================================
|
|
||||||
|
|
||||||
# # ============================================
|
# # ============================================
|
||||||
# # Stage 1: Code Quality & Linting
|
# # Verify Images
|
||||||
# # ============================================
|
# # ============================================
|
||||||
|
|
||||||
# lint-flake8:
|
# verify-images:
|
||||||
# image: *python_image
|
# image: alpine:latest
|
||||||
# commands:
|
# commands:
|
||||||
# - pip install --no-cache-dir flake8
|
# - apk add --no-cache curl
|
||||||
# - cd peikarband
|
|
||||||
# - flake8 src/ --count --select=E9,F63,F7,F82 --show-source --statistics
|
|
||||||
# - flake8 src/ --count --max-complexity=10 --max-line-length=120 --statistics --exit-zero
|
|
||||||
# when:
|
|
||||||
# - event: [push, pull_request, tag]
|
|
||||||
|
|
||||||
# lint-black:
|
|
||||||
# image: *python_image
|
|
||||||
# commands:
|
|
||||||
# - pip install --no-cache-dir black
|
|
||||||
# - cd peikarband
|
|
||||||
# - black --check src/ || echo "⚠️ Black formatting issues found (non-blocking)"
|
|
||||||
# when:
|
|
||||||
# - event: [push, pull_request, tag]
|
|
||||||
|
|
||||||
# lint-isort:
|
|
||||||
# image: *python_image
|
|
||||||
# commands:
|
|
||||||
# - pip install --no-cache-dir isort
|
|
||||||
# - cd peikarband
|
|
||||||
# - isort --check-only src/ || echo "⚠️ Import sorting issues found (non-blocking)"
|
|
||||||
# when:
|
|
||||||
# - event: [push, pull_request, tag]
|
|
||||||
|
|
||||||
# type-check:
|
|
||||||
# image: *python_image
|
|
||||||
# commands:
|
|
||||||
# - pip install --no-cache-dir mypy types-redis types-requests
|
|
||||||
# - cd peikarband
|
|
||||||
# - mypy src/ --config-file=config/mypy.ini || echo "⚠️ Type checking issues found (non-blocking)"
|
|
||||||
# when:
|
|
||||||
# - event: [push, pull_request, tag]
|
|
||||||
|
|
||||||
# # ============================================
|
|
||||||
# # Stage 2: Security Scanning
|
|
||||||
# # ============================================
|
|
||||||
|
|
||||||
# security-bandit:
|
|
||||||
# image: *python_image
|
|
||||||
# commands:
|
|
||||||
# - pip install --no-cache-dir bandit[toml]
|
|
||||||
# - cd peikarband
|
|
||||||
# - bandit -r src/ -f json -o bandit-report.json || true
|
|
||||||
# - bandit -r src/ -ll || echo "⚠️ Security issues found (non-blocking)"
|
|
||||||
# when:
|
|
||||||
# - event: [push, pull_request, tag]
|
|
||||||
|
|
||||||
# security-safety:
|
|
||||||
# image: *python_image
|
|
||||||
# commands:
|
|
||||||
# - pip install --no-cache-dir safety
|
|
||||||
# - cd peikarband
|
|
||||||
# - safety check -r requirements.txt --json || echo "⚠️ Dependency vulnerabilities found (non-blocking)"
|
|
||||||
# when:
|
|
||||||
# - event: [push, pull_request, tag]
|
|
||||||
|
|
||||||
# # ============================================
|
|
||||||
# # Stage 3: Testing
|
|
||||||
# # ============================================
|
|
||||||
|
|
||||||
# test:
|
|
||||||
# image: *python_image
|
|
||||||
# commands:
|
|
||||||
# - apt-get update && apt-get install -y --no-install-recommends curl
|
|
||||||
# - pip install --no-cache-dir -r peikarband/requirements.txt
|
|
||||||
# - pip install --no-cache-dir -r peikarband/requirements-dev.txt
|
|
||||||
# - cd peikarband
|
|
||||||
# - pytest tests/ -v --cov=src --cov-report=term-missing --cov-report=xml || echo "⚠️ Tests failed (non-blocking)"
|
|
||||||
# when:
|
|
||||||
# - event: [push, pull_request, tag]
|
|
||||||
|
|
||||||
# # ============================================
|
|
||||||
# # Stage 4: Helm Validation
|
|
||||||
# # ============================================
|
|
||||||
|
|
||||||
# helm-lint:
|
|
||||||
# image: *helm_image
|
|
||||||
# commands:
|
|
||||||
# - helm version
|
|
||||||
# - helm lint helm/peikarband
|
|
||||||
# - echo "✓ Helm chart validation passed"
|
|
||||||
# when:
|
|
||||||
# - event: [push, pull_request, tag]
|
|
||||||
|
|
||||||
# helm-template:
|
|
||||||
# image: *helm_image
|
|
||||||
# commands:
|
|
||||||
# - helm template peikarband helm/peikarband -f helm/peikarband/values-production.yaml --debug > /dev/null
|
|
||||||
# - echo "✓ Helm template rendering successful"
|
|
||||||
# when:
|
|
||||||
# - event: [push, pull_request, tag]
|
|
||||||
|
|
||||||
# # ============================================
|
|
||||||
# # Stage 6: Deployment - Staging
|
|
||||||
# # ============================================
|
|
||||||
|
|
||||||
# deploy-staging:
|
|
||||||
# image: *helm_image
|
|
||||||
# commands:
|
|
||||||
# - apk add --no-cache kubectl
|
|
||||||
# - echo "$KUBECONFIG_STAGING" | base64 -d > /tmp/kubeconfig
|
|
||||||
# - export KUBECONFIG=/tmp/kubeconfig
|
|
||||||
# - |
|
# - |
|
||||||
# helm upgrade --install peikarband-staging helm/peikarband \
|
# echo "════════════════════════════════════════"
|
||||||
# --namespace staging \
|
# echo " 🔍 Verifying Images in Registry"
|
||||||
# --create-namespace \
|
# echo "════════════════════════════════════════"
|
||||||
# --set image.repository=hub.peikarband.ir/peikarband/landing \
|
# echo ""
|
||||||
# --set image.tag=${CI_COMMIT_SHA:0:8} \
|
|
||||||
# --set image.pullPolicy=Always \
|
# # Check base image
|
||||||
# --values helm/peikarband/values-staging.yaml \
|
# echo "Checking base image..."
|
||||||
# --wait \
|
# if curl -f -u "$HARBOR_USERNAME:$HARBOR_PASSWORD" \
|
||||||
# --timeout 5m
|
# "https://hub.peikarband.ir/v2/peikarband/landing/manifests/base" > /dev/null 2>&1; then
|
||||||
# - kubectl get pods -n staging
|
# echo "✅ Base image: hub.peikarband.ir/peikarband/landing:base"
|
||||||
# - echo "✓ Deployed to staging successfully"
|
# else
|
||||||
# secrets: [KUBECONFIG_STAGING]
|
# echo "⚠️ Base image not found (this is OK if first build)"
|
||||||
|
# fi
|
||||||
|
|
||||||
|
# echo ""
|
||||||
|
|
||||||
|
# # Check app image
|
||||||
|
# echo "Checking app image..."
|
||||||
|
# TAG="${CI_COMMIT_SHA:0:8}"
|
||||||
|
# if curl -f -u "$HARBOR_USERNAME:$HARBOR_PASSWORD" \
|
||||||
|
# "https://hub.peikarband.ir/v2/peikarband/landing/manifests/$TAG" > /dev/null 2>&1; then
|
||||||
|
# echo "✅ App image: hub.peikarband.ir/peikarband/landing:$TAG"
|
||||||
|
# echo ""
|
||||||
|
# echo "Available tags:"
|
||||||
|
# echo " • latest"
|
||||||
|
# echo " • ${CI_COMMIT_SHA:0:8}"
|
||||||
|
# echo " • ${CI_COMMIT_BRANCH}"
|
||||||
|
# echo ""
|
||||||
|
# echo "════════════════════════════════════════"
|
||||||
|
# else
|
||||||
|
# echo "❌ Failed to verify app image"
|
||||||
|
# exit 1
|
||||||
|
# fi
|
||||||
|
|
||||||
|
# environment:
|
||||||
|
# HARBOR_USERNAME:
|
||||||
|
# from_secret: HARBOR_USERNAME
|
||||||
|
# HARBOR_PASSWORD:
|
||||||
|
# from_secret: HARBOR_PASSWORD
|
||||||
|
|
||||||
# when:
|
# when:
|
||||||
# - event: push
|
# event: [push, tag]
|
||||||
# branch: [main, develop]
|
# branch: [main, develop]
|
||||||
|
|
||||||
# # ============================================
|
# ============================================
|
||||||
# # Stage 7: Deployment - Production
|
# Notifications
|
||||||
# # ============================================
|
# ============================================
|
||||||
|
|
||||||
# deploy-production:
|
# notify-success:
|
||||||
# image: *helm_image
|
# image: alpine:latest
|
||||||
# commands:
|
# commands:
|
||||||
# - apk add --no-cache kubectl
|
# - echo "════════════════════════════════════════"
|
||||||
# - echo "$KUBECONFIG_PRODUCTION" | base64 -d > /tmp/kubeconfig
|
# - echo " 🎉 Pipeline Completed Successfully!"
|
||||||
# - export KUBECONFIG=/tmp/kubeconfig
|
# - echo "════════════════════════════════════════"
|
||||||
# - |
|
# - echo ""
|
||||||
# helm upgrade --install peikarband helm/peikarband \
|
# - echo "Branch:" "${CI_COMMIT_BRANCH}"
|
||||||
# --namespace production \
|
# - echo "Commit:" "${CI_COMMIT_SHA:0:8}"
|
||||||
# --create-namespace \
|
# - echo ""
|
||||||
# --set image.repository=hub.peikarband.ir/peikarband/landing \
|
# - echo "Images:"
|
||||||
# --set image.tag=${CI_COMMIT_TAG} \
|
# - echo " • Base:" "hub.peikarband.ir/peikarband/landing:base"
|
||||||
# --set image.pullPolicy=Always \
|
# - echo " • App:" "hub.peikarband.ir/peikarband/landing:${CI_COMMIT_SHA:0:8}"
|
||||||
# --values helm/peikarband/values-production.yaml \
|
# - echo ""
|
||||||
# --wait \
|
# - echo "Deploy with:"
|
||||||
# --timeout 10m
|
# - echo " kubectl set image deployment/peikarband-landing \\"
|
||||||
# - kubectl rollout status deployment/peikarband -n production
|
# - echo " peikarband-landing=hub.peikarband.ir/peikarband/landing:${CI_COMMIT_SHA:0:8}"
|
||||||
# - kubectl get pods -n production
|
# - echo ""
|
||||||
# - echo "✓ Deployed to production successfully"
|
# - echo "════════════════════════════════════════"
|
||||||
# secrets: [KUBECONFIG_PRODUCTION]
|
|
||||||
# when:
|
# when:
|
||||||
# - event: tag
|
# event: [push, tag]
|
||||||
# ref: refs/tags/v*
|
# status: success
|
||||||
|
|
||||||
# ============================================
|
# notify-failure:
|
||||||
# Stage 8: Notifications
|
# image: alpine:latest
|
||||||
# ============================================
|
# commands:
|
||||||
|
# - echo "════════════════════════════════════════"
|
||||||
notify-success:
|
# - echo " ❌ Pipeline Failed!"
|
||||||
image: alpine:latest
|
# - echo "════════════════════════════════════════"
|
||||||
commands:
|
# - echo ""
|
||||||
- echo "🎉 Pipeline completed successfully!"
|
# - echo "Branch:" "${CI_COMMIT_BRANCH}"
|
||||||
- echo "Branch: ${CI_COMMIT_BRANCH}"
|
# - echo "Commit:" "${CI_COMMIT_SHA:0:8}"
|
||||||
- echo "Commit: ${CI_COMMIT_SHA:0:8}"
|
# - echo ""
|
||||||
- echo "Image: hub.peikarband.ir/peikarband/landing:${CI_COMMIT_SHA:0:8}"
|
# - echo "Please check the logs above"
|
||||||
when:
|
# - echo "════════════════════════════════════════"
|
||||||
- event: [push, tag]
|
# when:
|
||||||
status: success
|
# event: [push, tag]
|
||||||
|
# status: failure
|
||||||
notify-failure:
|
|
||||||
image: alpine:latest
|
|
||||||
commands:
|
|
||||||
- echo "❌ Pipeline failed!"
|
|
||||||
- echo "Branch: ${CI_COMMIT_BRANCH}"
|
|
||||||
- echo "Commit: ${CI_COMMIT_SHA:0:8}"
|
|
||||||
- echo "Please check the logs above"
|
|
||||||
when:
|
|
||||||
- event: [push, tag]
|
|
||||||
status: failure
|
|
||||||
|
|||||||
99
Makefile
99
Makefile
@@ -10,33 +10,58 @@ DOCKER_BUILDKIT ?= 1
|
|||||||
.PHONY: help install dev kill-dev test lint format clean docker-up docker-down migrate
|
.PHONY: help install dev kill-dev test lint format clean docker-up docker-down migrate
|
||||||
|
|
||||||
help:
|
help:
|
||||||
@echo "Available commands:"
|
@echo "════════════════════════════════════════"
|
||||||
|
@echo " 📋 Peikarband Landing - Available Commands"
|
||||||
|
@echo "════════════════════════════════════════"
|
||||||
@echo ""
|
@echo ""
|
||||||
@echo "Development:"
|
@echo "🔧 Development:"
|
||||||
@echo " make install - Install dependencies"
|
@echo " make install - Install dependencies"
|
||||||
@echo " make dev - Run development server"
|
@echo " make dev - Run development server"
|
||||||
@echo " make kill-dev - Kill development server processes (ports 3000 & 8000)"
|
@echo " make kill-dev - Kill development server (ports 3000 & 8000)"
|
||||||
@echo " make test - Run tests"
|
@echo " make test - Run tests"
|
||||||
@echo " make lint - Run linters"
|
@echo " make lint - Run linters"
|
||||||
@echo " make format - Format code"
|
@echo " make format - Format code"
|
||||||
@echo " make clean - Clean temporary files"
|
@echo " make clean - Clean temporary files"
|
||||||
@echo ""
|
@echo ""
|
||||||
@echo "Docker:"
|
@echo "🐳 Docker - Base Image:"
|
||||||
@echo " make docker-build - Build Docker image"
|
@echo " make docker-build-base - Build base image (Python + Node.js + bun)"
|
||||||
@echo " make docker-push - Push Docker image"
|
@echo " make docker-push-base - Push base image to Harbor"
|
||||||
|
@echo ""
|
||||||
|
@echo "🐳 Docker - Application:"
|
||||||
|
@echo " make docker-build - Build application image"
|
||||||
|
@echo " make docker-push - Push application image to Harbor"
|
||||||
|
@echo " make docker-login - Login to Harbor registry"
|
||||||
@echo " make docker-up - Start Docker Compose"
|
@echo " make docker-up - Start Docker Compose"
|
||||||
@echo " make docker-down - Stop Docker Compose"
|
@echo " make docker-down - Stop Docker Compose"
|
||||||
@echo ""
|
@echo ""
|
||||||
@echo "Kubernetes/Helm:"
|
@echo "☸️ Kubernetes/Helm:"
|
||||||
@echo " make helm-lint - Lint Helm chart"
|
@echo " make helm-lint - Lint Helm chart"
|
||||||
@echo " make helm-package - Package Helm chart"
|
@echo " make helm-package - Package Helm chart"
|
||||||
@echo " make helm-install - Install Helm chart"
|
@echo " make helm-install - Install Helm chart"
|
||||||
@echo " make helm-upgrade - Upgrade Helm chart"
|
@echo " make helm-upgrade - Upgrade Helm chart"
|
||||||
@echo " make helm-uninstall - Uninstall Helm chart"
|
@echo " make helm-uninstall - Uninstall Helm chart"
|
||||||
@echo " make k8s-deploy - Deploy to Kubernetes"
|
@echo " make k8s-deploy - Full deployment pipeline"
|
||||||
@echo ""
|
@echo ""
|
||||||
@echo "Database:"
|
@echo "🗄️ Database:"
|
||||||
@echo " make migrate - Run database migrations"
|
@echo " make migrate - Run database migrations"
|
||||||
|
@echo " make seed - Seed database with initial data"
|
||||||
|
@echo ""
|
||||||
|
@echo "════════════════════════════════════════"
|
||||||
|
@echo " Quick Start:"
|
||||||
|
@echo "════════════════════════════════════════"
|
||||||
|
@echo ""
|
||||||
|
@echo "1️⃣ Build & Push Base (once):"
|
||||||
|
@echo " make docker-login"
|
||||||
|
@echo " make docker-build-base"
|
||||||
|
@echo " make docker-push-base"
|
||||||
|
@echo ""
|
||||||
|
@echo "2️⃣ Build & Push App:"
|
||||||
|
@echo " make docker-build"
|
||||||
|
@echo " make docker-push"
|
||||||
|
@echo ""
|
||||||
|
@echo "3️⃣ Deploy:"
|
||||||
|
@echo " make k8s-deploy"
|
||||||
|
@echo ""
|
||||||
|
|
||||||
install:
|
install:
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
@@ -76,24 +101,64 @@ clean:
|
|||||||
rm -rf dist/
|
rm -rf dist/
|
||||||
|
|
||||||
# Docker commands
|
# Docker commands
|
||||||
|
docker-build-base:
|
||||||
|
@echo "════════════════════════════════════════"
|
||||||
|
@echo " 🔨 Building Base Image"
|
||||||
|
@echo "════════════════════════════════════════"
|
||||||
|
DOCKER_BUILDKIT=$(DOCKER_BUILDKIT) docker buildx build \
|
||||||
|
-f docker/Dockerfile.base \
|
||||||
|
-t hub.peikarband.ir/peikarband/landing:base \
|
||||||
|
-t hub.peikarband.ir/peikarband/landing:base-python3.11-node20 \
|
||||||
|
--build-arg PYTHON_VERSION=3.11 \
|
||||||
|
--build-arg NODE_VERSION=20 \
|
||||||
|
--platform linux/amd64 \
|
||||||
|
--load \
|
||||||
|
.
|
||||||
|
@echo ""
|
||||||
|
@echo "✅ Base image built: hub.peikarband.ir/peikarband/landing:base"
|
||||||
|
@echo ""
|
||||||
|
|
||||||
|
docker-push-base:
|
||||||
|
@echo "════════════════════════════════════════"
|
||||||
|
@echo " 📤 Pushing Base Image"
|
||||||
|
@echo "════════════════════════════════════════"
|
||||||
|
docker push hub.peikarband.ir/peikarband/landing:base
|
||||||
|
docker push hub.peikarband.ir/peikarband/landing:base-python3.11-node20
|
||||||
|
@echo ""
|
||||||
|
@echo "✅ Base image pushed successfully!"
|
||||||
|
@echo ""
|
||||||
|
|
||||||
docker-build:
|
docker-build:
|
||||||
DOCKER_BUILDKIT=$(DOCKER_BUILDKIT) docker build \
|
@echo "════════════════════════════════════════"
|
||||||
|
@echo " 🔨 Building Application Image"
|
||||||
|
@echo "════════════════════════════════════════"
|
||||||
|
DOCKER_BUILDKIT=$(DOCKER_BUILDKIT) docker buildx build \
|
||||||
-f docker/Dockerfile \
|
-f docker/Dockerfile \
|
||||||
-t $(IMAGE_NAME):$(VERSION) \
|
-t hub.peikarband.ir/peikarband/landing:$(VERSION) \
|
||||||
-t $(IMAGE_NAME):latest \
|
-t hub.peikarband.ir/peikarband/landing:latest \
|
||||||
|
--build-arg BASE_IMAGE=hub.peikarband.ir/peikarband/landing:base \
|
||||||
--build-arg VERSION=$(VERSION) \
|
--build-arg VERSION=$(VERSION) \
|
||||||
--build-arg BUILD_DATE=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ') \
|
--build-arg BUILD_DATE=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ') \
|
||||||
|
--platform linux/amd64 \
|
||||||
|
--load \
|
||||||
.
|
.
|
||||||
|
@echo ""
|
||||||
|
@echo "✅ Application image built: hub.peikarband.ir/peikarband/landing:$(VERSION)"
|
||||||
|
@echo ""
|
||||||
|
|
||||||
docker-push:
|
docker-push:
|
||||||
docker tag $(IMAGE_NAME):$(VERSION) $(REGISTRY)/$(IMAGE_NAME):$(VERSION)
|
@echo "════════════════════════════════════════"
|
||||||
docker tag $(IMAGE_NAME):$(VERSION) $(REGISTRY)/$(IMAGE_NAME):latest
|
@echo " 📤 Pushing Application Image"
|
||||||
docker push $(REGISTRY)/$(IMAGE_NAME):$(VERSION)
|
@echo "════════════════════════════════════════"
|
||||||
docker push $(REGISTRY)/$(IMAGE_NAME):latest
|
docker push hub.peikarband.ir/peikarband/landing:$(VERSION)
|
||||||
|
docker push hub.peikarband.ir/peikarband/landing:latest
|
||||||
|
@echo ""
|
||||||
|
@echo "✅ Application image pushed successfully!"
|
||||||
|
@echo ""
|
||||||
|
|
||||||
docker-login:
|
docker-login:
|
||||||
@echo "Logging in to Harbor registry..."
|
@echo "Logging in to Harbor registry..."
|
||||||
@docker login $(REGISTRY)
|
@docker login hub.peikarband.ir
|
||||||
|
|
||||||
docker-up:
|
docker-up:
|
||||||
docker-compose -f docker/docker-compose.yml up -d
|
docker-compose -f docker/docker-compose.yml up -d
|
||||||
|
|||||||
43
build-base-image.sh
Executable file
43
build-base-image.sh
Executable file
@@ -0,0 +1,43 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Helper script to build and push base image locally
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo "=== Building Peikarband Base Image ==="
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Variables
|
||||||
|
REGISTRY="hub.peikarband.ir"
|
||||||
|
IMAGE="$REGISTRY/peikarband/base"
|
||||||
|
|
||||||
|
# Build
|
||||||
|
echo "1. Building base image..."
|
||||||
|
docker build \
|
||||||
|
-f docker/Dockerfile.base \
|
||||||
|
-t "$IMAGE:latest" \
|
||||||
|
-t "$IMAGE:python3.11-node20" \
|
||||||
|
--build-arg PYTHON_VERSION=3.11 \
|
||||||
|
--build-arg NODE_VERSION=20 \
|
||||||
|
.
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "2. Testing base image..."
|
||||||
|
docker run --rm "$IMAGE:latest" bash -c "python --version && node --version && bun --version"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "3. Login to Harbor registry..."
|
||||||
|
docker login "$REGISTRY"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "4. Pushing base image..."
|
||||||
|
docker push "$IMAGE:latest"
|
||||||
|
docker push "$IMAGE:python3.11-node20"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "=== ✅ Base Image Built and Pushed Successfully! ==="
|
||||||
|
echo ""
|
||||||
|
echo "Base image is now available at:"
|
||||||
|
echo " - $IMAGE:latest"
|
||||||
|
echo " - $IMAGE:python3.11-node20"
|
||||||
|
echo ""
|
||||||
|
echo "You can now run the application pipeline."
|
||||||
82
build-base-local.sh
Executable file
82
build-base-local.sh
Executable file
@@ -0,0 +1,82 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Build and push base image locally
|
||||||
|
# Usage: ./build-base-local.sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo "════════════════════════════════════════"
|
||||||
|
echo " 🔨 Building Base Image Locally"
|
||||||
|
echo "════════════════════════════════════════"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Configuration
|
||||||
|
REGISTRY="hub.peikarband.ir"
|
||||||
|
REPO="peikarband/base"
|
||||||
|
TAG="latest"
|
||||||
|
PYTHON_VERSION="3.11"
|
||||||
|
NODE_VERSION="20"
|
||||||
|
|
||||||
|
# Full image name
|
||||||
|
IMAGE="${REGISTRY}/${REPO}:${TAG}"
|
||||||
|
|
||||||
|
echo "📦 Image: ${IMAGE}"
|
||||||
|
echo "🐍 Python: ${PYTHON_VERSION}"
|
||||||
|
echo "📦 Node.js: ${NODE_VERSION}"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Check if docker buildx is available
|
||||||
|
if ! docker buildx version &> /dev/null; then
|
||||||
|
echo "❌ docker buildx not found!"
|
||||||
|
echo "Please install Docker Buildx"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Login to registry
|
||||||
|
echo "🔐 Logging in to registry..."
|
||||||
|
echo ""
|
||||||
|
read -p "Harbor Username: " HARBOR_USERNAME
|
||||||
|
read -sp "Harbor Password: " HARBOR_PASSWORD
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
echo "$HARBOR_PASSWORD" | docker login "$REGISTRY" -u "$HARBOR_USERNAME" --password-stdin
|
||||||
|
|
||||||
|
# Create/use buildx builder
|
||||||
|
echo ""
|
||||||
|
echo "🏗️ Setting up builder..."
|
||||||
|
docker buildx create --use --name peikarband-builder 2>/dev/null || docker buildx use peikarband-builder
|
||||||
|
|
||||||
|
# Build and push
|
||||||
|
echo ""
|
||||||
|
echo "🔨 Building base image..."
|
||||||
|
echo "(This will take ~8-10 minutes on first build)"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
docker buildx build \
|
||||||
|
-f docker/Dockerfile.base \
|
||||||
|
-t "${IMAGE}" \
|
||||||
|
-t "${REGISTRY}/${REPO}:python${PYTHON_VERSION}-node${NODE_VERSION}" \
|
||||||
|
--build-arg PYTHON_VERSION="${PYTHON_VERSION}" \
|
||||||
|
--build-arg NODE_VERSION="${NODE_VERSION}" \
|
||||||
|
--platform linux/amd64 \
|
||||||
|
--push \
|
||||||
|
--progress=plain \
|
||||||
|
.
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "════════════════════════════════════════"
|
||||||
|
echo " ✅ Base Image Built Successfully!"
|
||||||
|
echo "════════════════════════════════════════"
|
||||||
|
echo ""
|
||||||
|
echo "📦 Image: ${IMAGE}"
|
||||||
|
echo ""
|
||||||
|
echo "Tags pushed:"
|
||||||
|
echo " • latest"
|
||||||
|
echo " • python${PYTHON_VERSION}-node${NODE_VERSION}"
|
||||||
|
echo ""
|
||||||
|
echo "Now you can build your app with:"
|
||||||
|
echo " make docker-build"
|
||||||
|
echo ""
|
||||||
|
echo "Or in CI, it will automatically use this base image."
|
||||||
|
echo ""
|
||||||
|
|
||||||
152
docker/.dockerignore
Normal file
152
docker/.dockerignore
Normal file
@@ -0,0 +1,152 @@
|
|||||||
|
# Peikarband Platform - Docker Ignore File
|
||||||
|
# Optimize Docker build by excluding unnecessary files
|
||||||
|
|
||||||
|
# Git
|
||||||
|
.git
|
||||||
|
.gitignore
|
||||||
|
.gitattributes
|
||||||
|
|
||||||
|
# CI/CD
|
||||||
|
.github/
|
||||||
|
.gitlab-ci.yml
|
||||||
|
woodpecker.yml
|
||||||
|
.drone.yml
|
||||||
|
|
||||||
|
# IDE & Editors
|
||||||
|
.vscode/
|
||||||
|
.idea/
|
||||||
|
*.swp
|
||||||
|
*.swo
|
||||||
|
*~
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# Python
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
*$py.class
|
||||||
|
*.so
|
||||||
|
.Python
|
||||||
|
*.egg-info/
|
||||||
|
dist/
|
||||||
|
build/
|
||||||
|
*.egg
|
||||||
|
.pytest_cache/
|
||||||
|
.mypy_cache/
|
||||||
|
.coverage
|
||||||
|
htmlcov/
|
||||||
|
.tox/
|
||||||
|
.hypothesis/
|
||||||
|
*.cover
|
||||||
|
|
||||||
|
# Virtual Environment
|
||||||
|
venv/
|
||||||
|
env/
|
||||||
|
ENV/
|
||||||
|
virtualenv/
|
||||||
|
|
||||||
|
# Database
|
||||||
|
*.db
|
||||||
|
*.sqlite
|
||||||
|
*.sqlite3
|
||||||
|
reflex.db
|
||||||
|
*.dump
|
||||||
|
*.sql
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
*.log
|
||||||
|
logs/
|
||||||
|
*.out
|
||||||
|
*.err
|
||||||
|
|
||||||
|
# Environment & Secrets
|
||||||
|
.env
|
||||||
|
.env.*
|
||||||
|
!.env.example
|
||||||
|
*.pem
|
||||||
|
*.key
|
||||||
|
*.crt
|
||||||
|
secrets/
|
||||||
|
*.secret
|
||||||
|
|
||||||
|
# Documentation (exclude from container, keep only essential)
|
||||||
|
peikarband/docs/
|
||||||
|
*.md
|
||||||
|
!README.md
|
||||||
|
LICENSE
|
||||||
|
|
||||||
|
# Tests (exclude from production image)
|
||||||
|
peikarband/tests/
|
||||||
|
peikarband/config/pytest.ini
|
||||||
|
.pytest_cache/
|
||||||
|
coverage/
|
||||||
|
*.coverage
|
||||||
|
|
||||||
|
# Development
|
||||||
|
Makefile
|
||||||
|
docker-compose.yml
|
||||||
|
docker-compose.*.yml
|
||||||
|
|
||||||
|
# Kubernetes & Helm (exclude from container)
|
||||||
|
helm/
|
||||||
|
docker/docker-compose.yml
|
||||||
|
*.yaml
|
||||||
|
*.yml
|
||||||
|
!requirements.txt
|
||||||
|
!peikarband/**/*.yaml
|
||||||
|
!peikarband/**/*.yml
|
||||||
|
|
||||||
|
# Backup & Temp Files
|
||||||
|
*.bak
|
||||||
|
*.tmp
|
||||||
|
*.temp
|
||||||
|
tmp/
|
||||||
|
temp/
|
||||||
|
.cache/
|
||||||
|
|
||||||
|
# Media & Assets (exclude large files but keep necessary ones)
|
||||||
|
# Exclude root level media files
|
||||||
|
/wordpress.gif
|
||||||
|
/banner-3.gif
|
||||||
|
|
||||||
|
# Keep assets directory (now in peikarband/)
|
||||||
|
!peikarband/assets/
|
||||||
|
|
||||||
|
# Node modules (Reflex might need some)
|
||||||
|
node_modules/
|
||||||
|
npm-debug.log
|
||||||
|
yarn-error.log
|
||||||
|
package-lock.json
|
||||||
|
yarn.lock
|
||||||
|
|
||||||
|
# OS Files
|
||||||
|
Thumbs.db
|
||||||
|
.DS_Store
|
||||||
|
Desktop.ini
|
||||||
|
|
||||||
|
# Editor Configs
|
||||||
|
.editorconfig
|
||||||
|
.prettierrc
|
||||||
|
.eslintrc
|
||||||
|
|
||||||
|
# Pre-commit & Linters
|
||||||
|
.pre-commit-config.yaml
|
||||||
|
.flake8
|
||||||
|
.pylintrc
|
||||||
|
mypy.ini
|
||||||
|
.isort.cfg
|
||||||
|
|
||||||
|
# Scripts (keep only necessary ones)
|
||||||
|
peikarband/tools/scripts/*
|
||||||
|
!peikarband/tools/scripts/update-env-json.sh
|
||||||
|
*.sh
|
||||||
|
!entrypoint.sh
|
||||||
|
|
||||||
|
# Jupyter Notebooks
|
||||||
|
*.ipynb
|
||||||
|
.ipynb_checkpoints/
|
||||||
|
|
||||||
|
# Misc
|
||||||
|
TODO.md
|
||||||
|
CHANGELOG.md
|
||||||
|
CONTRIBUTING.md
|
||||||
|
.mailmap
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
# Peikarband Platform - Production Dockerfile
|
# Dockerfile - Peikarband Landing Application
|
||||||
# Multi-stage build for optimized image size and security
|
# Optimized multi-stage build using base image
|
||||||
# Uses pre-built base image for faster builds
|
|
||||||
|
|
||||||
# Build arguments
|
# Build arguments
|
||||||
ARG BASE_IMAGE=hub.peikarband.ir/peikarband/base:latest
|
ARG BASE_IMAGE=hub.peikarband.ir/peikarband/landing:base
|
||||||
ARG VERSION=latest
|
ARG VERSION=latest
|
||||||
ARG BUILD_DATE
|
ARG BUILD_DATE
|
||||||
|
|
||||||
@@ -12,15 +11,8 @@ ARG BUILD_DATE
|
|||||||
# ============================================
|
# ============================================
|
||||||
FROM ${BASE_IMAGE} AS builder
|
FROM ${BASE_IMAGE} AS builder
|
||||||
|
|
||||||
# Re-declare ARGs for this stage
|
LABEL stage=builder
|
||||||
ARG VERSION=latest
|
LABEL maintainer="Peikarband DevOps <devops@peikarband.ir>"
|
||||||
ARG BUILD_DATE
|
|
||||||
|
|
||||||
LABEL maintainer="Peikarband Team <dev@peikarband.ir>"
|
|
||||||
LABEL org.opencontainers.image.title="Peikarband Landing"
|
|
||||||
LABEL org.opencontainers.image.description="Peikarband hosting platform landing page"
|
|
||||||
LABEL org.opencontainers.image.version="${VERSION}"
|
|
||||||
LABEL org.opencontainers.image.created="${BUILD_DATE}"
|
|
||||||
|
|
||||||
WORKDIR /build
|
WORKDIR /build
|
||||||
|
|
||||||
@@ -28,8 +20,7 @@ WORKDIR /build
|
|||||||
# - Python 3.11
|
# - Python 3.11
|
||||||
# - Node.js 20
|
# - Node.js 20
|
||||||
# - bun
|
# - bun
|
||||||
# - gcc, g++, make
|
# - gcc, g++, make, curl, ca-certificates
|
||||||
# - npm configured with retries
|
|
||||||
|
|
||||||
# Verify tools are available
|
# Verify tools are available
|
||||||
RUN echo "=== Build Environment ===" && \
|
RUN echo "=== Build Environment ===" && \
|
||||||
@@ -39,135 +30,193 @@ RUN echo "=== Build Environment ===" && \
|
|||||||
bun --version && \
|
bun --version && \
|
||||||
echo "========================"
|
echo "========================"
|
||||||
|
|
||||||
# Copy only requirements first (for better layer caching)
|
# ============================================
|
||||||
|
# Python Dependencies
|
||||||
|
# ============================================
|
||||||
|
|
||||||
|
# Copy Python requirements first (for layer caching)
|
||||||
COPY peikarband/requirements.txt .
|
COPY peikarband/requirements.txt .
|
||||||
|
|
||||||
# Install Python dependencies in user space
|
# Install Python dependencies
|
||||||
RUN pip install --no-cache-dir --upgrade pip setuptools wheel && \
|
RUN --mount=type=cache,target=/root/.cache/pip \
|
||||||
pip install --no-cache-dir --user -r requirements.txt
|
pip install --no-cache-dir --upgrade pip && \
|
||||||
|
pip install --no-cache-dir -r requirements.txt
|
||||||
# Copy application code (excluding .dockerignore items)
|
|
||||||
COPY --chown=root:root peikarband/ .
|
|
||||||
|
|
||||||
# Build and export Reflex app for production
|
|
||||||
# Note: API_URL will be updated at runtime from environment variable
|
|
||||||
# Export creates .web directory with frontend static files
|
|
||||||
# Retry mechanism for network issues
|
|
||||||
RUN set -ex && \
|
|
||||||
echo "Starting Reflex export (attempt 1)..." && \
|
|
||||||
python -m reflex export --no-zip --loglevel debug || \
|
|
||||||
(echo "Attempt 1 failed, cleaning cache..." && \
|
|
||||||
npm cache clean --force && \
|
|
||||||
rm -rf node_modules .web && \
|
|
||||||
sleep 15 && \
|
|
||||||
echo "Retrying (attempt 2)..." && \
|
|
||||||
python -m reflex export --no-zip --loglevel debug) || \
|
|
||||||
(echo "Attempt 2 failed, final retry..." && \
|
|
||||||
npm cache clean --force && \
|
|
||||||
rm -rf node_modules .web && \
|
|
||||||
sleep 20 && \
|
|
||||||
echo "Final attempt (3)..." && \
|
|
||||||
python -m reflex export --no-zip --loglevel debug)
|
|
||||||
|
|
||||||
# Aggressive cleanup to reduce layer size
|
|
||||||
# NOTE: Keep .web directory - it contains frontend static files
|
|
||||||
RUN set -ex && \
|
|
||||||
# Remove Python cache
|
|
||||||
find /build -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true && \
|
|
||||||
find /build -type f -name "*.pyc" -delete && \
|
|
||||||
find /build -type f -name "*.pyo" -delete && \
|
|
||||||
# Remove development files
|
|
||||||
rm -rf /build/tests /build/docs /build/tools && \
|
|
||||||
rm -rf /build/.git /build/.github /build/.vscode && \
|
|
||||||
rm -rf /build/venv /build/env && \
|
|
||||||
# Remove node_modules but KEEP .web (frontend static files)
|
|
||||||
rm -rf /build/node_modules && \
|
|
||||||
# Remove large duplicate assets from root
|
|
||||||
rm -f /build/*.gif /build/*.mp4 /build/*.mov 2>/dev/null || true && \
|
|
||||||
# Keep only necessary configs
|
|
||||||
find /build -type f -name "docker-compose*.yml" -delete && \
|
|
||||||
find /build -type f -name "Makefile" -delete
|
|
||||||
|
|
||||||
# ============================================
|
# ============================================
|
||||||
# Stage 2: Runtime
|
# Frontend Build (Reflex)
|
||||||
# ============================================
|
# ============================================
|
||||||
FROM python:${PYTHON_VERSION}-slim
|
|
||||||
|
|
||||||
# Re-declare ARGs for this stage
|
# Copy source code to /build/peikarband/ to preserve package structure
|
||||||
ARG PYTHON_VERSION=3.11
|
# This ensures peikarband.peikarband module can be found by Reflex
|
||||||
|
COPY peikarband/ /build/peikarband/
|
||||||
|
|
||||||
|
# Set PYTHONPATH to include /build (for peikarband package) and /build/peikarband (for src imports)
|
||||||
|
# This allows both peikarband.peikarband and src.* imports to work
|
||||||
|
ENV PYTHONPATH=/build:/build/peikarband
|
||||||
|
|
||||||
|
# Verify that peikarband.peikarband can be imported before running reflex
|
||||||
|
# This helps catch import errors early
|
||||||
|
# RUN cd /build && \
|
||||||
|
# python3 -c "from peikarband.peikarband import app; print('✅ peikarband.peikarband.app imported successfully')" && \
|
||||||
|
# echo "Import test passed"
|
||||||
|
|
||||||
|
# Initialize Reflex and build frontend from peikarband directory
|
||||||
|
# Reflex needs to run from the directory containing rxconfig.py
|
||||||
|
RUN cd /build/peikarband && \
|
||||||
|
reflex init --loglevel debug || true && \
|
||||||
|
reflex export --frontend-only --no-zip --loglevel debug && \
|
||||||
|
echo "Frontend export completed" && \
|
||||||
|
if [ -d .web/node_modules/.bin ]; then \
|
||||||
|
find .web/node_modules/.bin -type f -exec chmod +x {} \; && \
|
||||||
|
find .web/node_modules/.bin -type l | while read symlink; do \
|
||||||
|
target=$(readlink -f "$symlink" 2>/dev/null || true); \
|
||||||
|
if [ -n "$target" ] && [ -f "$target" ]; then \
|
||||||
|
chmod +x "$target" 2>/dev/null || true; \
|
||||||
|
fi; \
|
||||||
|
chmod +x "$symlink" 2>/dev/null || true; \
|
||||||
|
done && \
|
||||||
|
echo "✅ Set executable permissions for all .bin files (files and symlinks) and their targets"; \
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Note: reflex export already builds and installs everything needed
|
||||||
|
# No additional npm install is required
|
||||||
|
RUN echo "Frontend built by reflex export"
|
||||||
|
|
||||||
|
# ============================================
|
||||||
|
# Stage 2: Runtime (using base image for Node.js)
|
||||||
|
# ============================================
|
||||||
|
FROM ${BASE_IMAGE} AS runtime
|
||||||
|
|
||||||
|
# Re-declare build arguments for this stage
|
||||||
|
ARG BASE_IMAGE=hub.peikarband.ir/peikarband/landing:base
|
||||||
ARG VERSION=latest
|
ARG VERSION=latest
|
||||||
ARG BUILD_DATE
|
ARG BUILD_DATE
|
||||||
|
ARG GIT_COMMIT
|
||||||
|
ARG GIT_BRANCH
|
||||||
|
ARG BUILD_NUMBER
|
||||||
|
|
||||||
# Build info
|
LABEL org.opencontainers.image.title="Peikarband Landing"
|
||||||
ENV VERSION=${VERSION} \
|
LABEL org.opencontainers.image.description="Peikarband hosting platform landing page"
|
||||||
BUILD_DATE=${BUILD_DATE}
|
LABEL org.opencontainers.image.vendor="Peikarband"
|
||||||
|
LABEL org.opencontainers.image.version="${VERSION}"
|
||||||
|
LABEL org.opencontainers.image.created="${BUILD_DATE}"
|
||||||
|
|
||||||
|
# Running as root for now to avoid permission issues
|
||||||
|
# TODO: Switch back to non-root user after permission issues are resolved
|
||||||
|
# RUN groupadd -r peikarband && \
|
||||||
|
# useradd -r -g peikarband -u 1000 -m -s /bin/bash peikarband
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Install runtime dependencies only
|
# Note: We keep WORKDIR=/app (not /app/peikarband) to avoid Python importing
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
# /app/peikarband/peikarband/ as the peikarband package incorrectly
|
||||||
curl \
|
# The entrypoint script will cd to /app/peikarband before running reflex
|
||||||
ca-certificates \
|
|
||||||
tini \
|
|
||||||
&& rm -rf /var/lib/apt/lists/* \
|
|
||||||
&& apt-get clean
|
|
||||||
|
|
||||||
# Install Node.js runtime
|
# Base image already has everything we need:
|
||||||
ARG NODE_VERSION=20
|
# - Python 3.11
|
||||||
RUN curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION}.x | bash - \
|
# - Node.js 20
|
||||||
&& apt-get install -y --no-install-recommends nodejs \
|
# - curl, ca-certificates
|
||||||
&& rm -rf /var/lib/apt/lists/* \
|
# - tini (for proper init)
|
||||||
&& apt-get clean
|
# No additional packages needed!
|
||||||
|
|
||||||
# Create non-root user first
|
# Copy Python dependencies from builder
|
||||||
RUN groupadd -r -g 1000 peikarband && \
|
COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
|
||||||
useradd -r -u 1000 -g peikarband -m -s /bin/bash peikarband && \
|
COPY --from=builder /usr/local/bin /usr/local/bin
|
||||||
mkdir -p /app/logs /app/uploads /app/.reflex
|
|
||||||
|
|
||||||
# Copy Python dependencies from builder to user home
|
# Copy application code to /app/peikarband/ to create peikarband.peikarband structure
|
||||||
COPY --from=builder /root/.local /home/peikarband/.local
|
# With app_name="peikarband", Reflex expects to find peikarband.peikarband module
|
||||||
|
# Running as root, so no need for chown
|
||||||
|
COPY --from=builder /build/peikarband /app/peikarband
|
||||||
|
|
||||||
# Copy application code from builder
|
# CRITICAL: Remove __init__.py from /app if it exists
|
||||||
COPY --from=builder /build /app
|
# Reflex will crash if there's __init__.py in the app root directory
|
||||||
|
RUN if [ -f /app/__init__.py ]; then \
|
||||||
|
echo "⚠️ WARNING: Removing __init__.py from /app (causes Reflex crash)"; \
|
||||||
|
rm -f /app/__init__.py; \
|
||||||
|
fi && \
|
||||||
|
echo "✅ Verified: No __init__.py in /app root"
|
||||||
|
|
||||||
# Copy and set up runtime script
|
# Copy entrypoint script
|
||||||
COPY --chown=peikarband:peikarband peikarband/tools/scripts/update-env-json.sh /app/tools/scripts/update-env-json.sh
|
COPY docker/entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||||
RUN chmod +x /app/tools/scripts/update-env-json.sh
|
RUN chmod +x /usr/local/bin/entrypoint.sh && chmod +x /app/peikarband/.web/app/routes.js
|
||||||
|
|
||||||
# Fix ownership
|
# Create necessary directories
|
||||||
RUN chown -R peikarband:peikarband /home/peikarband/.local /app
|
RUN mkdir -p /app/data /app/logs /app/uploaded_files
|
||||||
|
|
||||||
# Add version info (must be before USER switch)
|
# Set proper permissions for application files
|
||||||
RUN echo "${VERSION}" > /app/.version && \
|
# Explicitly set executable permissions for node_modules/.bin files (both files and symlinks)
|
||||||
chown peikarband:peikarband /app/.version
|
# Also fix permissions for symlink targets
|
||||||
|
RUN if [ -d /app/peikarband/.web/node_modules/.bin ]; then \
|
||||||
|
find /app/peikarband/.web/node_modules/.bin -type f -exec chmod +x {} \; && \
|
||||||
|
find /app/peikarband/.web/node_modules/.bin -type l | while read symlink; do \
|
||||||
|
target=$(readlink -f "$symlink" 2>/dev/null || true); \
|
||||||
|
if [ -n "$target" ] && [ -f "$target" ]; then \
|
||||||
|
chmod +x "$target" 2>/dev/null || true; \
|
||||||
|
fi; \
|
||||||
|
chmod +x "$symlink" 2>/dev/null || true; \
|
||||||
|
done && \
|
||||||
|
ls -la /app/peikarband/.web/node_modules/.bin/ | head -20 && \
|
||||||
|
echo "✅ Verified executable permissions for .bin files and symlink targets"; \
|
||||||
|
fi && \
|
||||||
|
chmod -R 777 /app/data /app/logs /app/uploaded_files
|
||||||
|
|
||||||
# Security: Remove unnecessary setuid/setgid permissions
|
# Environment variables
|
||||||
RUN find / -perm /6000 -type f -exec chmod a-s {} \; 2>/dev/null || true
|
# PYTHONPATH includes both /app and /app/peikarband
|
||||||
|
# - /app: allows importing peikarband from /app/peikarband/
|
||||||
# Set environment variables
|
# - /app/peikarband: allows importing src from /app/peikarband/src/
|
||||||
ENV PATH=/home/peikarband/.local/bin:$PATH \
|
# This makes both peikarband.peikarband and src.* imports work correctly
|
||||||
PYTHONUNBUFFERED=1 \
|
# REFLEX_DIR points to the directory containing rxconfig.py
|
||||||
|
ENV PYTHONUNBUFFERED=1 \
|
||||||
PYTHONDONTWRITEBYTECODE=1 \
|
PYTHONDONTWRITEBYTECODE=1 \
|
||||||
PYTHONHASHSEED=random \
|
PYTHONPATH=/app:/app/peikarband \
|
||||||
PIP_NO_CACHE_DIR=1 \
|
PATH="/app/.venv/bin:$PATH" \
|
||||||
PIP_DISABLE_PIP_VERSION_CHECK=1 \
|
REFLEX_DIR=/app/peikarband \
|
||||||
REFLEX_ENV=prod \
|
NODE_ENV=production
|
||||||
ENVIRONMENT=prod
|
|
||||||
|
|
||||||
# Switch to non-root user
|
# Diagnostic information
|
||||||
USER peikarband
|
RUN echo "=== Diagnostic Info ===" && \
|
||||||
|
if [ -f /app/peikarband/.web/node_modules/.bin/react-router ]; then \
|
||||||
|
ls -la /app/peikarband/.web/node_modules/.bin/react-router && \
|
||||||
|
file /app/peikarband/.web/node_modules/.bin/react-router || true; \
|
||||||
|
fi && \
|
||||||
|
if [ -f /app/peikarband/.web/node_modules/@react-router/dev/bin.js ]; then \
|
||||||
|
head -5 /app/peikarband/.web/node_modules/@react-router/dev/bin.js || true; \
|
||||||
|
fi && \
|
||||||
|
echo "======================="
|
||||||
|
|
||||||
# Expose ports
|
# Health check (using backend health endpoint on port 8000)
|
||||||
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
||||||
|
CMD curl -f http://localhost:8000/ping || exit 1
|
||||||
|
|
||||||
|
# Running as root for now to avoid permission issues
|
||||||
|
# USER peikarband
|
||||||
|
|
||||||
|
# Expose port
|
||||||
EXPOSE 3000 8000
|
EXPOSE 3000 8000
|
||||||
|
|
||||||
# Health check with better error handling
|
# Use tini as init system
|
||||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
|
ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/entrypoint.sh"]
|
||||||
CMD curl -f -s -o /dev/null -w "%{http_code}" http://localhost:8000/ping | grep -q "200" || exit 1
|
|
||||||
|
|
||||||
# Use tini as init system for proper signal handling
|
# Start application
|
||||||
# Update .web/env.json from API_URL env var, then run the app
|
# entrypoint.sh will cd to /app/peikarband and run reflex
|
||||||
ENTRYPOINT ["/usr/bin/tini", "--", "/app/tools/scripts/update-env-json.sh"]
|
# PYTHONPATH=/app:/app/peikarband allows Python to find both peikarband and peikarband.peikarband
|
||||||
|
CMD ["run", "--env", "prod", "--loglevel", "info", "--frontend-port", "3000", "--backend-port", "8000"]
|
||||||
|
|
||||||
# Run application (both frontend and backend)
|
# ============================================
|
||||||
CMD ["python", "-m", "reflex", "run", "--env", "prod"]
|
# Build Information
|
||||||
|
# ============================================
|
||||||
|
# ARG declarations are already done above in runtime stage
|
||||||
|
LABEL git.commit="${GIT_COMMIT}"
|
||||||
|
LABEL git.branch="${GIT_BRANCH}"
|
||||||
|
LABEL build.number="${BUILD_NUMBER}"
|
||||||
|
LABEL build.date="${BUILD_DATE}"
|
||||||
|
|
||||||
|
# ============================================
|
||||||
|
# Multi-Architecture Support
|
||||||
|
# ============================================
|
||||||
|
# This Dockerfile supports:
|
||||||
|
# - linux/amd64
|
||||||
|
# - linux/arm64 (with appropriate base image)
|
||||||
|
#
|
||||||
|
# Build with:
|
||||||
|
# docker buildx build --platform linux/amd64,linux/arm64 .
|
||||||
|
|||||||
51
docker/Dockerfile copy
Normal file
51
docker/Dockerfile copy
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
# استفاده از ایمیج پایهای که قبلاً Push کردید
|
||||||
|
ARG BASE_IMAGE=hub.peikarband.ir/peikarband/landing:base
|
||||||
|
FROM ${BASE_IMAGE} AS builder
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# ۱. کپی کردن فایلهای نیازمندی (برای استفاده از Cache)
|
||||||
|
COPY peikarband/requirements.txt .
|
||||||
|
RUN --mount=type=cache,target=/root/.cache/pip \
|
||||||
|
pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
|
# ۲. کپی کردن کل کدها
|
||||||
|
# مهم: ساختار فولدر باید با app_name در rxconfig.py یکی باشد
|
||||||
|
COPY peikarband/ .
|
||||||
|
|
||||||
|
# ۳. تنظیم PYTHONPATH برای حل مشکل ModuleNotFoundError
|
||||||
|
ENV PYTHONPATH=/app
|
||||||
|
|
||||||
|
# ۴. اجرای Reflex Export
|
||||||
|
# این دستور خودش فرانتتند را بیلد میکند و نیازی به npm run build دستی نیست
|
||||||
|
RUN reflex init --loglevel debug
|
||||||
|
RUN reflex export --frontend-only --no-zip --loglevel debug
|
||||||
|
|
||||||
|
# ================= Stage 2: Runtime =================
|
||||||
|
FROM ${BASE_IMAGE} AS runtime
|
||||||
|
|
||||||
|
# ایجاد یوزر غیر ریشه برای امنیت
|
||||||
|
RUN groupadd -r peikarband && useradd -r -g peikarband -u 1000 -m peikarband
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# کپی کردن کتابخانههای نصب شده از مرحله قبل
|
||||||
|
COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
|
||||||
|
COPY --from=builder /usr/local/bin /usr/local/bin
|
||||||
|
|
||||||
|
# کپی کردن کد اپلیکیشن و فایلهای بیلد شده فرانتتند
|
||||||
|
COPY --from=builder --chown=peikarband:peikarband /app /app
|
||||||
|
|
||||||
|
# ایجاد پوشههای مورد نیاز
|
||||||
|
RUN mkdir -p data logs uploaded_files && \
|
||||||
|
chown -R peikarband:peikarband /app && \
|
||||||
|
chmod -R 755 /app
|
||||||
|
|
||||||
|
ENV PYTHONUNBUFFERED=1 \
|
||||||
|
PYTHONPATH=/app \
|
||||||
|
NODE_ENV=production
|
||||||
|
|
||||||
|
USER peikarband
|
||||||
|
EXPOSE 3000 8000
|
||||||
|
|
||||||
|
ENTRYPOINT ["/usr/bin/tini", "--"]
|
||||||
|
CMD ["reflex", "run", "--env", "prod"]
|
||||||
27
docker/Dockerfile copy.base
Normal file
27
docker/Dockerfile copy.base
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
# Peikarband Base Image
|
||||||
|
ARG PYTHON_VERSION=3.11
|
||||||
|
FROM python:${PYTHON_VERSION}-slim
|
||||||
|
|
||||||
|
# نصب ابزارهای سیستم و پاکسازی برای کاهش حجم
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
|
gcc g++ make curl gnupg ca-certificates unzip git tini \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# نصب Node.js 20
|
||||||
|
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \
|
||||||
|
&& apt-get install -y --no-install-recommends nodejs \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# نصب Bun با مکانیزم Retry برای پایداری در شبکه
|
||||||
|
RUN set -ex && \
|
||||||
|
for i in 1 2 3 4 5; do \
|
||||||
|
curl -fsSL https://bun.sh/install | bash && break || \
|
||||||
|
(echo "Attempt $i failed, retrying in 5 seconds..." && sleep 5); \
|
||||||
|
done
|
||||||
|
ENV PATH="/root/.bun/bin:${PATH}"
|
||||||
|
|
||||||
|
# آپدیت ابزارهای پایتون
|
||||||
|
RUN pip install --no-cache-dir --upgrade pip setuptools wheel
|
||||||
|
|
||||||
|
WORKDIR /build
|
||||||
|
CMD ["/bin/bash"]
|
||||||
@@ -28,6 +28,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|||||||
ca-certificates \
|
ca-certificates \
|
||||||
unzip \
|
unzip \
|
||||||
git \
|
git \
|
||||||
|
tini \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Install Node.js
|
# Install Node.js
|
||||||
|
|||||||
71
docker/entrypoint.sh
Normal file
71
docker/entrypoint.sh
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Function to fix node_modules permissions
|
||||||
|
fix_node_modules_permissions() {
|
||||||
|
if [ -d /app/peikarband/.web/node_modules/.bin ]; then
|
||||||
|
echo "Checking node_modules/.bin permissions..."
|
||||||
|
|
||||||
|
REACT_ROUTER_BIN="/app/peikarband/.web/node_modules/.bin/react-router"
|
||||||
|
|
||||||
|
# Check if react-router exists
|
||||||
|
if [ -e "$REACT_ROUTER_BIN" ]; then
|
||||||
|
# If it's a symlink, check and fix the target
|
||||||
|
if [ -L "$REACT_ROUTER_BIN" ]; then
|
||||||
|
TARGET=$(readlink -f "$REACT_ROUTER_BIN")
|
||||||
|
echo "react-router is a symlink pointing to: $TARGET"
|
||||||
|
if [ -f "$TARGET" ] && [ ! -x "$TARGET" ]; then
|
||||||
|
echo "WARNING: Target file is not executable, attempting to fix..."
|
||||||
|
chmod +x "$TARGET" 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Fix permissions for react-router itself (file or symlink)
|
||||||
|
if [ ! -x "$REACT_ROUTER_BIN" ]; then
|
||||||
|
echo "WARNING: react-router is not executable, attempting to fix..."
|
||||||
|
chmod +x "$REACT_ROUTER_BIN" 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Fix all .bin files and their symlink targets
|
||||||
|
echo "Fixing permissions for all .bin files and symlink targets..."
|
||||||
|
find /app/peikarband/.web/node_modules/.bin -type f -exec chmod +x {} \; 2>/dev/null || true
|
||||||
|
find /app/peikarband/.web/node_modules/.bin -type l | while read symlink; do
|
||||||
|
target=$(readlink -f "$symlink" 2>/dev/null || true)
|
||||||
|
if [ -n "$target" ] && [ -f "$target" ]; then
|
||||||
|
chmod +x "$target" 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
chmod +x "$symlink" 2>/dev/null || true
|
||||||
|
done
|
||||||
|
|
||||||
|
# Verify react-router is executable
|
||||||
|
if [ -x "$REACT_ROUTER_BIN" ]; then
|
||||||
|
echo "✅ react-router is executable"
|
||||||
|
else
|
||||||
|
echo "⚠️ WARNING: react-router may still not be executable (running as non-root)"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "⚠️ WARNING: react-router binary not found (packages may not be installed yet)"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "⚠️ WARNING: .web/node_modules/.bin directory not found (packages may not be installed yet)"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Change to the directory containing rxconfig.py
|
||||||
|
cd /app/peikarband
|
||||||
|
|
||||||
|
# If reflex run is being executed, ensure packages are installed first
|
||||||
|
# This handles the case where .web directory doesn't exist from build time
|
||||||
|
if [ "$1" = "run" ] && [ ! -d /app/peikarband/.web/node_modules ]; then
|
||||||
|
echo "Initializing Reflex (installing packages)..."
|
||||||
|
reflex init --loglevel info || true
|
||||||
|
echo "Packages installed, fixing permissions..."
|
||||||
|
fix_node_modules_permissions
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Fix permissions if node_modules already exists (from build time or init)
|
||||||
|
fix_node_modules_permissions
|
||||||
|
|
||||||
|
# Run reflex with all passed arguments
|
||||||
|
exec reflex "$@"
|
||||||
|
|
||||||
198
docs/BASE_IMAGE.md
Normal file
198
docs/BASE_IMAGE.md
Normal file
@@ -0,0 +1,198 @@
|
|||||||
|
# Base Image Management
|
||||||
|
|
||||||
|
## چرا Base Image؟
|
||||||
|
|
||||||
|
Base image شامل تمام dependencies سنگین است که:
|
||||||
|
- ✅ فقط یک بار build میشود
|
||||||
|
- ✅ هر بار که کد تغییر میکند، دوباره download نمیشود
|
||||||
|
- ✅ Build time را از 8-10 دقیقه به 3-4 دقیقه کاهش میدهد
|
||||||
|
- ✅ قابل استفاده مجدد در چند پروژه
|
||||||
|
|
||||||
|
## محتویات Base Image
|
||||||
|
|
||||||
|
Base image شامل موارد زیر است:
|
||||||
|
|
||||||
|
```dockerfile
|
||||||
|
FROM python:3.11-slim
|
||||||
|
|
||||||
|
# Build Tools
|
||||||
|
- gcc, g++, make
|
||||||
|
- curl, ca-certificates
|
||||||
|
- git, unzip
|
||||||
|
|
||||||
|
# Runtime
|
||||||
|
- Python 3.11
|
||||||
|
- Node.js 20.x
|
||||||
|
- npm (latest)
|
||||||
|
- bun (latest)
|
||||||
|
```
|
||||||
|
|
||||||
|
## ساخت Base Image
|
||||||
|
|
||||||
|
### روش 1: Local (توصیه میشود برای اولین بار)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Run the helper script
|
||||||
|
./build-base-local.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
این script:
|
||||||
|
1. از شما username/password Harbor میخواهد
|
||||||
|
2. به registry login میکند
|
||||||
|
3. Base image را build میکند
|
||||||
|
4. به Harbor push میکند
|
||||||
|
|
||||||
|
**زمان:** ~8-10 دقیقه (اولین بار)
|
||||||
|
|
||||||
|
### روش 2: در Woodpecker CI
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Trigger pipeline manually in Woodpecker UI
|
||||||
|
# یا از طریق git:
|
||||||
|
git commit --allow-empty -m "build: rebuild base image"
|
||||||
|
git push
|
||||||
|
```
|
||||||
|
|
||||||
|
Base image فقط در این حالتها rebuild میشود:
|
||||||
|
- `docker/Dockerfile.base` تغییر کرد
|
||||||
|
- `.woodpecker.yml` تغییر کرد
|
||||||
|
- Manual trigger
|
||||||
|
|
||||||
|
## استفاده از Base Image
|
||||||
|
|
||||||
|
Dockerfile به صورت خودکار از base image استفاده میکند:
|
||||||
|
|
||||||
|
```dockerfile
|
||||||
|
ARG BASE_IMAGE=hub.peikarband.ir/peikarband/base:latest
|
||||||
|
FROM ${BASE_IMAGE} AS builder
|
||||||
|
```
|
||||||
|
|
||||||
|
## مدیریت Versions
|
||||||
|
|
||||||
|
### Tags:
|
||||||
|
|
||||||
|
1. **`latest`**: آخرین نسخه (default)
|
||||||
|
2. **`python3.11-node20`**: نسخه specific
|
||||||
|
|
||||||
|
### تغییر Version:
|
||||||
|
|
||||||
|
اگر میخواهید Python یا Node.js version تغییر کند:
|
||||||
|
|
||||||
|
1. Edit `docker/Dockerfile.base`:
|
||||||
|
```dockerfile
|
||||||
|
ARG PYTHON_VERSION=3.12 # تغییر
|
||||||
|
ARG NODE_VERSION=22 # تغییر
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Build base image:
|
||||||
|
```bash
|
||||||
|
./build-base-local.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Update app Dockerfile:
|
||||||
|
```dockerfile
|
||||||
|
ARG BASE_IMAGE=hub.peikarband.ir/peikarband/base:python3.12-node22
|
||||||
|
```
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
### مشکل: Base image not found
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Build locally:
|
||||||
|
./build-base-local.sh
|
||||||
|
|
||||||
|
# یا check if exists:
|
||||||
|
docker pull hub.peikarband.ir/peikarband/base:latest
|
||||||
|
```
|
||||||
|
|
||||||
|
### مشکل: Build fails in CI
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Check Woodpecker secrets:
|
||||||
|
- HARBOR_USERNAME
|
||||||
|
- HARBOR_PASSWORD
|
||||||
|
|
||||||
|
# Test locally:
|
||||||
|
docker login hub.peikarband.ir
|
||||||
|
```
|
||||||
|
|
||||||
|
### مشکل: Base image outdated
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Force rebuild:
|
||||||
|
git commit --allow-empty -m "build: rebuild base image"
|
||||||
|
git push
|
||||||
|
|
||||||
|
# یا locally:
|
||||||
|
./build-base-local.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
## Build Times
|
||||||
|
|
||||||
|
| Scenario | With Base | Without Base |
|
||||||
|
|----------|-----------|--------------|
|
||||||
|
| First build | 10 min | 10 min |
|
||||||
|
| Code change only | 3 min ✅ | 10 min ❌ |
|
||||||
|
| Dependency change | 3 min ✅ | 10 min ❌ |
|
||||||
|
| Base change | 13 min | 10 min |
|
||||||
|
|
||||||
|
## Best Practices
|
||||||
|
|
||||||
|
1. **Build base image locally اولین بار**
|
||||||
|
```bash
|
||||||
|
./build-base-local.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **فقط وقتی dependencies تغییر کرد rebuild کنید**
|
||||||
|
- Python packages
|
||||||
|
- Node.js version
|
||||||
|
- System tools
|
||||||
|
|
||||||
|
3. **از versioned tags استفاده کنید در production**
|
||||||
|
```dockerfile
|
||||||
|
ARG BASE_IMAGE=hub.peikarband.ir/peikarband/base:python3.11-node20
|
||||||
|
```
|
||||||
|
|
||||||
|
4. **Base image را در Harbor نگه دارید**
|
||||||
|
- Private registry
|
||||||
|
- Version control
|
||||||
|
- Team access
|
||||||
|
|
||||||
|
## مثال: Workflow کامل
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 1. Clone project
|
||||||
|
git clone <repo>
|
||||||
|
cd peikarband
|
||||||
|
|
||||||
|
# 2. Build base image (فقط یک بار)
|
||||||
|
./build-base-local.sh
|
||||||
|
# ⏱️ ~8-10 دقیقه
|
||||||
|
|
||||||
|
# 3. Build app (بعدها)
|
||||||
|
make docker-build
|
||||||
|
# ⏱️ ~3 دقیقه ✅
|
||||||
|
|
||||||
|
# 4. تغییر کد
|
||||||
|
vim peikarband/src/...
|
||||||
|
|
||||||
|
# 5. Build again (سریع!)
|
||||||
|
make docker-build
|
||||||
|
# ⏱️ ~3 دقیقه ✅ (dependencies از cache)
|
||||||
|
```
|
||||||
|
|
||||||
|
## خلاصه
|
||||||
|
|
||||||
|
✅ **مزایا:**
|
||||||
|
- Build سریعتر (3 دقیقه vs 10 دقیقه)
|
||||||
|
- بهینهسازی cache
|
||||||
|
- قابل استفاده مجدد
|
||||||
|
|
||||||
|
❌ **نیاز به:**
|
||||||
|
- Build اولیه (یک بار، 10 دقیقه)
|
||||||
|
- نگهداری در registry
|
||||||
|
- Rebuild وقتی dependencies تغییر کند
|
||||||
|
|
||||||
|
**نتیجه:** برای development و production **بسیار** مفید است! 🚀
|
||||||
|
|
||||||
94
docs/REPOSITORY_STRATEGY.md
Normal file
94
docs/REPOSITORY_STRATEGY.md
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
# Repository Strategy
|
||||||
|
|
||||||
|
## استراتژی فعلی: Single Repository ✅
|
||||||
|
|
||||||
|
همه چیز در یک repository: `peikarband/landing`
|
||||||
|
|
||||||
|
### مزایا:
|
||||||
|
- ساده و قابل مدیریت
|
||||||
|
- همه چیز در یک جا
|
||||||
|
- مناسب برای یک پروژه
|
||||||
|
|
||||||
|
### ساختار:
|
||||||
|
```
|
||||||
|
peikarband/landing/
|
||||||
|
├── .woodpecker.yml # Application pipeline
|
||||||
|
├── .woodpecker-base.yml # Base image pipeline
|
||||||
|
├── docker/
|
||||||
|
│ ├── Dockerfile # Application
|
||||||
|
│ └── Dockerfile.base # Base image
|
||||||
|
└── ...
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## استراتژی آینده: Multi Repository (اختیاری)
|
||||||
|
|
||||||
|
اگر پروژههای بیشتری اضافه شد، میتوانید base را جدا کنید.
|
||||||
|
|
||||||
|
### مراحل جداسازی:
|
||||||
|
|
||||||
|
#### 1. ایجاد Repository جدید
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Create new repo
|
||||||
|
mkdir peikarband-base-images
|
||||||
|
cd peikarband-base-images
|
||||||
|
git init
|
||||||
|
|
||||||
|
# Structure
|
||||||
|
mkdir -p python311-node20
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 2. انتقال Base Files
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Copy base files
|
||||||
|
cp ../landing/docker/Dockerfile.base python311-node20/Dockerfile
|
||||||
|
cp ../landing/.woodpecker-base.yml .woodpecker.yml
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 3. Update Application Repository
|
||||||
|
|
||||||
|
در `peikarband/landing`:
|
||||||
|
|
||||||
|
```dockerfile
|
||||||
|
# docker/Dockerfile
|
||||||
|
ARG BASE_IMAGE=hub.peikarband.ir/peikarband/base:python311-node20
|
||||||
|
FROM ${BASE_IMAGE} AS builder
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 4. Registry Organization
|
||||||
|
|
||||||
|
```
|
||||||
|
Registry Structure:
|
||||||
|
hub.peikarband.ir/
|
||||||
|
├── peikarband/base # Base images repo
|
||||||
|
│ ├── python311-node20:latest
|
||||||
|
│ └── python312-node21:latest
|
||||||
|
└── peikarband/landing # Application
|
||||||
|
└── latest
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## زمان جداسازی
|
||||||
|
|
||||||
|
**جدا کنید وقتی:**
|
||||||
|
- ✅ 3+ پروژه از همان base استفاده میکنند
|
||||||
|
- ✅ تیم 5+ نفری دارید
|
||||||
|
- ✅ Base versioning پیچیده شد
|
||||||
|
- ✅ نیاز به CI/CD مستقل برای base دارید
|
||||||
|
|
||||||
|
**جدا نکنید وقتی:**
|
||||||
|
- ❌ فقط یک پروژه دارید (فعلی)
|
||||||
|
- ❌ تیم کوچک است (1-3 نفر)
|
||||||
|
- ❌ Base خیلی تغییر نمیکند
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## توصیه
|
||||||
|
|
||||||
|
**الان:** یک repository کافیه! 👍
|
||||||
|
|
||||||
|
**آینده:** اگر پروژه دوم شروع شد، مجدداً ارزیابی کنید.
|
||||||
@@ -34,6 +34,12 @@ spec:
|
|||||||
{{- toYaml .Values.securityContext | nindent 12 }}
|
{{- toYaml .Values.securityContext | nindent 12 }}
|
||||||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
|
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
|
||||||
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||||||
|
{{- if .Values.command }}
|
||||||
|
command: {{- toYaml .Values.command | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.args }}
|
||||||
|
args: {{- toYaml .Values.args | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
ports:
|
ports:
|
||||||
- name: backend
|
- name: backend
|
||||||
containerPort: {{ .Values.service.backend.targetPort }}
|
containerPort: {{ .Values.service.backend.targetPort }}
|
||||||
@@ -41,10 +47,7 @@ spec:
|
|||||||
- name: frontend
|
- name: frontend
|
||||||
containerPort: {{ .Values.service.frontend.targetPort }}
|
containerPort: {{ .Values.service.frontend.targetPort }}
|
||||||
protocol: TCP
|
protocol: TCP
|
||||||
livenessProbe:
|
|
||||||
{{- toYaml .Values.livenessProbe | nindent 12 }}
|
|
||||||
readinessProbe:
|
|
||||||
{{- toYaml .Values.readinessProbe | nindent 12 }}
|
|
||||||
resources:
|
resources:
|
||||||
{{- toYaml .Values.resources | nindent 12 }}
|
{{- toYaml .Values.resources | nindent 12 }}
|
||||||
env:
|
env:
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ spec:
|
|||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
---
|
||||||
{{- if .Values.ingress.apiEnabled -}}
|
{{- if .Values.ingress.apiEnabled -}}
|
||||||
# Backend API Ingress (api.peikarband.ir -> port 8000)
|
# Backend API Ingress (api.peikarband.ir -> port 8000)
|
||||||
apiVersion: networking.k8s.io/v1
|
apiVersion: networking.k8s.io/v1
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ registrySecret:
|
|||||||
imagePullSecrets:
|
imagePullSecrets:
|
||||||
- name: hub-registry-secret
|
- name: hub-registry-secret
|
||||||
|
|
||||||
# Auto-create application secrets (database, redis, etc)
|
|
||||||
appSecrets:
|
appSecrets:
|
||||||
enabled: false # Set to true if you need database/redis
|
enabled: false # Set to true if you need database/redis
|
||||||
name: peikarband-prod-secrets
|
name: peikarband-prod-secrets
|
||||||
@@ -56,8 +55,6 @@ ingress:
|
|||||||
cert-manager.io/cluster-issuer: "letsencrypt-prod"
|
cert-manager.io/cluster-issuer: "letsencrypt-prod"
|
||||||
traefik.ingress.kubernetes.io/router.entrypoints: "websecure"
|
traefik.ingress.kubernetes.io/router.entrypoints: "websecure"
|
||||||
traefik.ingress.kubernetes.io/router.tls: "true"
|
traefik.ingress.kubernetes.io/router.tls: "true"
|
||||||
# Rate limiting and body size should be configured via Traefik Middleware
|
|
||||||
# Example: traefik.ingress.kubernetes.io/router.middlewares: default-ratelimit@kubernetescrd
|
|
||||||
hosts:
|
hosts:
|
||||||
- host: peikarband.ir
|
- host: peikarband.ir
|
||||||
paths:
|
paths:
|
||||||
@@ -79,6 +76,8 @@ ingress:
|
|||||||
cert-manager.io/cluster-issuer: "letsencrypt-prod"
|
cert-manager.io/cluster-issuer: "letsencrypt-prod"
|
||||||
traefik.ingress.kubernetes.io/router.entrypoints: "websecure"
|
traefik.ingress.kubernetes.io/router.entrypoints: "websecure"
|
||||||
traefik.ingress.kubernetes.io/router.tls: "true"
|
traefik.ingress.kubernetes.io/router.tls: "true"
|
||||||
|
# Strip /api prefix if needed (currently not using prefix)
|
||||||
|
# traefik.ingress.kubernetes.io/rewrite-target: /
|
||||||
apiHosts:
|
apiHosts:
|
||||||
- host: api.peikarband.ir
|
- host: api.peikarband.ir
|
||||||
paths:
|
paths:
|
||||||
@@ -118,10 +117,11 @@ readinessProbe:
|
|||||||
httpGet:
|
httpGet:
|
||||||
path: /ping
|
path: /ping
|
||||||
port: 8000
|
port: 8000
|
||||||
initialDelaySeconds: 60 # Allow Reflex to fully start (30-60s expected)
|
scheme: HTTP
|
||||||
|
initialDelaySeconds: 30 # Allow Reflex to fully start (build + startup takes time)
|
||||||
periodSeconds: 10
|
periodSeconds: 10
|
||||||
timeoutSeconds: 5
|
timeoutSeconds: 5 # Increased timeout for slow responses
|
||||||
failureThreshold: 6 # Allow 6 failures = 60s grace period
|
failureThreshold: 5 # Allow 10 failures = 100s grace period
|
||||||
|
|
||||||
# Override liveness probe
|
# Override liveness probe
|
||||||
# Using /live endpoint which is specifically designed for liveness checks
|
# Using /live endpoint which is specifically designed for liveness checks
|
||||||
@@ -129,10 +129,11 @@ livenessProbe:
|
|||||||
httpGet:
|
httpGet:
|
||||||
path: /live
|
path: /live
|
||||||
port: 8000
|
port: 8000
|
||||||
initialDelaySeconds: 90 # More time for liveness (after readiness)
|
scheme: HTTP
|
||||||
periodSeconds: 15
|
initialDelaySeconds: 30 # More time for liveness (after readiness + build)
|
||||||
timeoutSeconds: 5
|
periodSeconds: 10 # Check less frequently
|
||||||
failureThreshold: 3
|
timeoutSeconds: 5 # Increased timeout
|
||||||
|
failureThreshold: 5 # Allow more failures before restart
|
||||||
|
|
||||||
configMap:
|
configMap:
|
||||||
data:
|
data:
|
||||||
|
|||||||
@@ -8,6 +8,17 @@ image:
|
|||||||
pullPolicy: IfNotPresent
|
pullPolicy: IfNotPresent
|
||||||
tag: "latest"
|
tag: "latest"
|
||||||
|
|
||||||
|
# Build-time configuration (used during docker build)
|
||||||
|
# Note: This is for documentation. Actual build uses Makefile NPM_REGISTRY variable
|
||||||
|
# To override npm registry during build:
|
||||||
|
# make docker-build NPM_REGISTRY=https://your-npm-registry.com/
|
||||||
|
build:
|
||||||
|
npmRegistry: "https://registry.npmjs.org/" # Default npm registry URL
|
||||||
|
# Optional: Set if behind proxy (not needed for servers outside Iran)
|
||||||
|
# httpProxy: ""
|
||||||
|
# httpsProxy: ""
|
||||||
|
# noProxy: ""
|
||||||
|
|
||||||
imagePullSecrets: []
|
imagePullSecrets: []
|
||||||
|
|
||||||
# Registry secret auto-creation (for private registry)
|
# Registry secret auto-creation (for private registry)
|
||||||
@@ -39,10 +50,12 @@ podAnnotations:
|
|||||||
prometheus.io/port: "8000"
|
prometheus.io/port: "8000"
|
||||||
prometheus.io/path: "/metrics"
|
prometheus.io/path: "/metrics"
|
||||||
|
|
||||||
|
# Running as root for now to avoid permission issues
|
||||||
|
# TODO: Switch back to non-root user after permission issues are resolved
|
||||||
podSecurityContext:
|
podSecurityContext:
|
||||||
runAsNonRoot: true
|
runAsNonRoot: false
|
||||||
runAsUser: 1000
|
runAsUser: 0
|
||||||
fsGroup: 1000
|
fsGroup: 0
|
||||||
|
|
||||||
securityContext:
|
securityContext:
|
||||||
allowPrivilegeEscalation: false
|
allowPrivilegeEscalation: false
|
||||||
@@ -93,11 +106,11 @@ ingress:
|
|||||||
|
|
||||||
resources:
|
resources:
|
||||||
limits:
|
limits:
|
||||||
cpu: 1000m
|
cpu: 2
|
||||||
memory: 1Gi
|
memory: 2Gi
|
||||||
requests:
|
requests:
|
||||||
cpu: 250m
|
cpu: 500m
|
||||||
memory: 512Mi
|
memory: 1Gi
|
||||||
|
|
||||||
autoscaling:
|
autoscaling:
|
||||||
enabled: true
|
enabled: true
|
||||||
@@ -123,23 +136,31 @@ affinity:
|
|||||||
- peikarband
|
- peikarband
|
||||||
topologyKey: kubernetes.io/hostname
|
topologyKey: kubernetes.io/hostname
|
||||||
|
|
||||||
livenessProbe:
|
# livenessProbe:
|
||||||
httpGet:
|
# httpGet:
|
||||||
path: /ping
|
# path: /ping
|
||||||
port: 8000
|
# port: 8000
|
||||||
initialDelaySeconds: 30
|
# scheme: HTTP
|
||||||
periodSeconds: 10
|
# initialDelaySeconds: 50
|
||||||
timeoutSeconds: 5
|
# periodSeconds: 10
|
||||||
failureThreshold: 3
|
# timeoutSeconds: 5
|
||||||
|
# failureThreshold: 3
|
||||||
|
|
||||||
readinessProbe:
|
# readinessProbe:
|
||||||
httpGet:
|
# httpGet:
|
||||||
path: /ping
|
# path: /ping
|
||||||
port: 8000
|
# port: 8000
|
||||||
initialDelaySeconds: 10
|
# scheme: HTTP
|
||||||
periodSeconds: 5
|
# initialDelaySeconds: 60
|
||||||
timeoutSeconds: 3
|
# periodSeconds: 5
|
||||||
failureThreshold: 3
|
# timeoutSeconds: 3
|
||||||
|
# failureThreshold: 3
|
||||||
|
|
||||||
|
# Container command and args
|
||||||
|
# If command is set, it will override the Dockerfile CMD
|
||||||
|
# If args is set, it will be appended to the command
|
||||||
|
command: [] # Leave empty to use Dockerfile CMD, or set to override: ["/usr/local/bin/entrypoint.sh"]
|
||||||
|
args: [] # Leave empty to use Dockerfile CMD args, or set: ["run", "--env", "prod"]
|
||||||
|
|
||||||
env:
|
env:
|
||||||
- name: REFLEX_ENV
|
- name: REFLEX_ENV
|
||||||
@@ -209,6 +230,12 @@ networkPolicy:
|
|||||||
- protocol: TCP
|
- protocol: TCP
|
||||||
port: 3000
|
port: 3000
|
||||||
egress:
|
egress:
|
||||||
|
# Allow DNS resolution (required for all external connections)
|
||||||
|
- to: []
|
||||||
|
ports:
|
||||||
|
- protocol: UDP
|
||||||
|
port: 53 # DNS
|
||||||
|
# Allow internal cluster traffic (PostgreSQL, Redis, etc.)
|
||||||
- to:
|
- to:
|
||||||
- namespaceSelector: {}
|
- namespaceSelector: {}
|
||||||
ports:
|
ports:
|
||||||
@@ -216,12 +243,14 @@ networkPolicy:
|
|||||||
port: 5432 # PostgreSQL
|
port: 5432 # PostgreSQL
|
||||||
- protocol: TCP
|
- protocol: TCP
|
||||||
port: 6379 # Redis
|
port: 6379 # Redis
|
||||||
|
# Allow external internet access (npm registry, APIs, etc.)
|
||||||
|
# Empty 'to' selector means all destinations (including external)
|
||||||
|
- to: []
|
||||||
|
ports:
|
||||||
- protocol: TCP
|
- protocol: TCP
|
||||||
port: 443 # HTTPS
|
port: 443 # HTTPS (npm registry, APIs, etc.)
|
||||||
- protocol: TCP
|
- protocol: TCP
|
||||||
port: 80 # HTTP
|
port: 80 # HTTP
|
||||||
- protocol: UDP
|
|
||||||
port: 53 # DNS
|
|
||||||
|
|
||||||
monitoring:
|
monitoring:
|
||||||
serviceMonitor:
|
serviceMonitor:
|
||||||
|
|||||||
6
peikarband/.gitignore
vendored
Normal file
6
peikarband/.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
assets/external/
|
||||||
|
*.py[cod]
|
||||||
|
.states
|
||||||
|
__pycache__/
|
||||||
|
.web
|
||||||
|
*.db
|
||||||
10
peikarband/app.py
Normal file
10
peikarband/app.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
"""Peikarband Landing Application Entry Point.
|
||||||
|
|
||||||
|
This file exports the Reflex app instance for the landing page.
|
||||||
|
Reflex will look for 'app' in the root module when app_name matches the root directory.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from src.presentation.web.pages.landing.index import app
|
||||||
|
|
||||||
|
__all__ = ["app"]
|
||||||
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
"""Reflex configuration file.
|
|
||||||
|
|
||||||
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=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",
|
|
||||||
"https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/Vazirmatn-font-face.css",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
8
peikarband/peikarband/__init__.py
Normal file
8
peikarband/peikarband/__init__.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
"""Landing page app module.
|
||||||
|
|
||||||
|
Reflex expects to find 'app' in peikarband.landing when app_name='landing'.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from .peikarband import app
|
||||||
|
|
||||||
|
__all__ = ["app"]
|
||||||
58
peikarband/peikarband/peikarband.py
Normal file
58
peikarband/peikarband/peikarband.py
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
"""
|
||||||
|
Peikarband Application Entry Point
|
||||||
|
|
||||||
|
This is the main application file that Reflex uses to run the app.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import reflex as rx
|
||||||
|
from src.presentation.web.pages.landing.index import index
|
||||||
|
from src.presentation.api.routes.health import (
|
||||||
|
ping_endpoint,
|
||||||
|
health_endpoint,
|
||||||
|
ready_endpoint,
|
||||||
|
live_endpoint,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Create the app
|
||||||
|
app = rx.App()
|
||||||
|
|
||||||
|
# Add landing page
|
||||||
|
app.add_page(index, route="/")
|
||||||
|
|
||||||
|
# Add health check pages (for Kubernetes probes)
|
||||||
|
# These return JSON responses for monitoring
|
||||||
|
@rx.page(route="/ping")
|
||||||
|
def ping():
|
||||||
|
"""Basic health check endpoint"""
|
||||||
|
data = ping_endpoint()
|
||||||
|
return rx.box(
|
||||||
|
rx.text(str(data)),
|
||||||
|
style={"whiteSpace": "pre"}
|
||||||
|
)
|
||||||
|
|
||||||
|
@rx.page(route="/health")
|
||||||
|
def health():
|
||||||
|
"""Detailed health check endpoint"""
|
||||||
|
data = health_endpoint()
|
||||||
|
return rx.box(
|
||||||
|
rx.text(str(data)),
|
||||||
|
style={"whiteSpace": "pre"}
|
||||||
|
)
|
||||||
|
|
||||||
|
@rx.page(route="/ready")
|
||||||
|
def ready():
|
||||||
|
"""Readiness probe endpoint"""
|
||||||
|
data = ready_endpoint()
|
||||||
|
return rx.box(
|
||||||
|
rx.text(str(data)),
|
||||||
|
style={"whiteSpace": "pre"}
|
||||||
|
)
|
||||||
|
|
||||||
|
@rx.page(route="/live")
|
||||||
|
def live():
|
||||||
|
"""Liveness probe endpoint"""
|
||||||
|
data = live_endpoint()
|
||||||
|
return rx.box(
|
||||||
|
rx.text(str(data)),
|
||||||
|
style={"whiteSpace": "pre"}
|
||||||
|
)
|
||||||
@@ -18,6 +18,7 @@ config = rx.Config(
|
|||||||
frontend_port=FRONTEND_PORT,
|
frontend_port=FRONTEND_PORT,
|
||||||
backend_port=BACKEND_PORT,
|
backend_port=BACKEND_PORT,
|
||||||
db_url=DB_URL,
|
db_url=DB_URL,
|
||||||
|
state_auto_setters=True, # Temporary fix for 0.8.9+ deprecation warning
|
||||||
disable_plugins=["reflex.plugins.sitemap.SitemapPlugin"],
|
disable_plugins=["reflex.plugins.sitemap.SitemapPlugin"],
|
||||||
stylesheets=[
|
stylesheets=[
|
||||||
"https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap",
|
"https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap",
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
"""Peikarband Landing Application.
|
||||||
|
|
||||||
|
This module exports the Reflex app instance for the landing page.
|
||||||
|
"""
|
||||||
|
|
||||||
|
# Import the app from the landing page module using relative import
|
||||||
|
from .presentation.web.pages.landing.index import app
|
||||||
|
|
||||||
|
__all__ = ["app"]
|
||||||
|
|
||||||
|
|||||||
@@ -1131,24 +1131,35 @@ def about_section() -> rx.Component:
|
|||||||
padding="10px 24px",
|
padding="10px 24px",
|
||||||
border_radius="full",
|
border_radius="full",
|
||||||
),
|
),
|
||||||
rx.heading("زایای انتخاب پیکربند", size="9", color="white", font_weight="900", letter_spacing="-0.03em", margin_top="16px"),
|
rx.heading(
|
||||||
|
"مزایای انتخاب پیکربند",
|
||||||
|
size=rx.breakpoints(initial="7", md="8", lg="9"),
|
||||||
|
color="white",
|
||||||
|
font_weight="900",
|
||||||
|
letter_spacing="-0.03em",
|
||||||
|
margin_top="16px",
|
||||||
|
text_align="center",
|
||||||
|
),
|
||||||
rx.text(
|
rx.text(
|
||||||
"ارائهدهنده معتبر خدمات هاستینگ و زیرساخت ابری در ایران",
|
"ارائهدهنده معتبر خدمات هاستینگ و زیرساخت ابری در ایران",
|
||||||
color="#94A3B8",
|
color="#94A3B8",
|
||||||
font_size="21px",
|
font_size=rx.breakpoints(initial="16px", md="18px", lg="20px"),
|
||||||
margin_bottom="80px",
|
margin_bottom=rx.breakpoints(initial="40px", md="60px", lg="80px"),
|
||||||
font_weight="500",
|
font_weight="500",
|
||||||
|
text_align="center",
|
||||||
),
|
),
|
||||||
rx.hstack(
|
rx.flex(
|
||||||
about_card("zap", "سرعت فوقالعاده", "سرورهای بهینهشده با SSD NVMe و CDN جهانی برای بارگذاری آنی", "linear-gradient(135deg, #1B4B7F, #4F46E5)", "rgba(27, 75, 127, 0.5)"),
|
about_card("zap", "سرعت فوقالعاده", "سرورهای بهینهشده با SSD NVMe و CDN جهانی برای بارگذاری آنی", "linear-gradient(135deg, #1B4B7F, #4F46E5)", "rgba(27, 75, 127, 0.5)"),
|
||||||
about_card("clock", "پشتیبانی 24/7", "تیم پشتیبانی حرفهای و با تجربه، آماده کمک در هر لحظه", "linear-gradient(135deg, #4DB8C4, #7C3AED)", "rgba(77, 184, 196, 0.5)"),
|
about_card("clock", "پشتیبانی 24/7", "تیم پشتیبانی حرفهای و با تجربه، آماده کمک در هر لحظه", "linear-gradient(135deg, #4DB8C4, #7C3AED)", "rgba(77, 184, 196, 0.5)"),
|
||||||
about_card("shield-check", "امنیت پیشرفته", "SSL رایگان، بکاپ اتوماتیک روزانه و محافظت DDoS", "linear-gradient(135deg, #6DD7E5, #9333EA)", "rgba(109, 215, 229, 0.5)"),
|
about_card("shield-check", "امنیت پیشرفته", "SSL رایگان، بکاپ اتوماتیک روزانه و محافظت DDoS", "linear-gradient(135deg, #6DD7E5, #9333EA)", "rgba(109, 215, 229, 0.5)"),
|
||||||
spacing="9",
|
direction=rx.breakpoints(initial="column", lg="row"),
|
||||||
|
spacing=rx.breakpoints(initial="6", md="7", lg="9"),
|
||||||
width="100%",
|
width="100%",
|
||||||
|
align="stretch",
|
||||||
),
|
),
|
||||||
max_width="1500px",
|
max_width="1500px",
|
||||||
margin="0 auto",
|
margin="0 auto",
|
||||||
padding="140px 8%",
|
padding=rx.breakpoints(initial="80px 5%", md="110px 6%", lg="140px 8%"),
|
||||||
),
|
),
|
||||||
background="linear-gradient(180deg, rgba(10, 18, 35, 0.98) 0%, rgba(5, 10, 20, 1) 100%)",
|
background="linear-gradient(180deg, rgba(10, 18, 35, 0.98) 0%, rgba(5, 10, 20, 1) 100%)",
|
||||||
width="100%",
|
width="100%",
|
||||||
@@ -1207,13 +1218,22 @@ def services_section() -> rx.Component:
|
|||||||
padding="10px 24px",
|
padding="10px 24px",
|
||||||
border_radius="full",
|
border_radius="full",
|
||||||
),
|
),
|
||||||
rx.heading("همه چیز برای کسبوکار آنلاین شما", size="9", color="white", font_weight="900", letter_spacing="-0.03em", margin_top="16px"),
|
rx.heading(
|
||||||
|
"همه چیز برای کسبوکار آنلاین شما",
|
||||||
|
size=rx.breakpoints(initial="7", md="8", lg="9"),
|
||||||
|
color="white",
|
||||||
|
font_weight="900",
|
||||||
|
letter_spacing="-0.03em",
|
||||||
|
margin_top="16px",
|
||||||
|
text_align="center",
|
||||||
|
),
|
||||||
rx.text(
|
rx.text(
|
||||||
"از استارتاپ تا شرکتهای بزرگ، راهکار مناسب برای هر کسبوکاری",
|
"از استارتاپ تا شرکتهای بزرگ، راهکار مناسب برای هر کسبوکاری",
|
||||||
color="#94A3B8",
|
color="#94A3B8",
|
||||||
font_size="21px",
|
font_size=rx.breakpoints(initial="16px", md="18px", lg="20px"),
|
||||||
margin_bottom="80px",
|
margin_bottom=rx.breakpoints(initial="40px", md="60px", lg="80px"),
|
||||||
font_weight="500",
|
font_weight="500",
|
||||||
|
text_align="center",
|
||||||
),
|
),
|
||||||
rx.grid(
|
rx.grid(
|
||||||
service_card("وردپرس کلود", "کلود اختصاصی وردپرس با مدیریت هوشمند و پیشرفته", "cloud", ["نصب خودکار وردپرس", "مدیریت چند سایتی", "بکاپ اتوماتیک", "SSL رایگان", "بهینهسازی خودکار"], "#1B4B7F"),
|
service_card("وردپرس کلود", "کلود اختصاصی وردپرس با مدیریت هوشمند و پیشرفته", "cloud", ["نصب خودکار وردپرس", "مدیریت چند سایتی", "بکاپ اتوماتیک", "SSL رایگان", "بهینهسازی خودکار"], "#1B4B7F"),
|
||||||
@@ -1222,13 +1242,13 @@ def services_section() -> rx.Component:
|
|||||||
service_card("DevOps حرفهای", "اتوماسیون و مدیریت زیرساخت کلود", "code", ["Kubernetes", "Docker", "CI/CD Pipeline", "Infrastructure as Code"], "#1B4B7F"),
|
service_card("DevOps حرفهای", "اتوماسیون و مدیریت زیرساخت کلود", "code", ["Kubernetes", "Docker", "CI/CD Pipeline", "Infrastructure as Code"], "#1B4B7F"),
|
||||||
service_card("فروش دامین", "ثبت دامینهای بینالمللی و ایرانی", "tag", [".com, .ir, .net", "قیمت رقابتی", "تحویل فوری", "مدیریت DNS"], "#4DB8C4"),
|
service_card("فروش دامین", "ثبت دامینهای بینالمللی و ایرانی", "tag", [".com, .ir, .net", "قیمت رقابتی", "تحویل فوری", "مدیریت DNS"], "#4DB8C4"),
|
||||||
service_card("پشتیبانی 24/7", "پشتیبانی تخصصی وردپرس و سرور", "headset", ["تیم متخصص", "پاسخگویی سریع", "مشاوره رایگان", "پشتیبانی فارسی"], "#6DD7E5"),
|
service_card("پشتیبانی 24/7", "پشتیبانی تخصصی وردپرس و سرور", "headset", ["تیم متخصص", "پاسخگویی سریع", "مشاوره رایگان", "پشتیبانی فارسی"], "#6DD7E5"),
|
||||||
columns="3",
|
columns=rx.breakpoints(initial="1", sm="1", md="2", lg="3"),
|
||||||
spacing="9",
|
spacing=rx.breakpoints(initial="6", md="7", lg="9"),
|
||||||
width="100%",
|
width="100%",
|
||||||
),
|
),
|
||||||
max_width="1500px",
|
max_width="1500px",
|
||||||
margin="0 auto",
|
margin="0 auto",
|
||||||
padding="160px 8%",
|
padding=rx.breakpoints(initial="80px 5%", md="120px 6%", lg="160px 8%"),
|
||||||
),
|
),
|
||||||
width="100%",
|
width="100%",
|
||||||
id="services",
|
id="services",
|
||||||
@@ -1690,23 +1710,31 @@ def footer() -> rx.Component:
|
|||||||
return rx.box(
|
return rx.box(
|
||||||
rx.vstack(
|
rx.vstack(
|
||||||
rx.divider(background="rgba(27, 75, 127, 0.4)", margin_y="10"),
|
rx.divider(background="rgba(27, 75, 127, 0.4)", margin_y="10"),
|
||||||
rx.hstack(
|
rx.flex(
|
||||||
rx.vstack(
|
rx.vstack(
|
||||||
rx.hstack(
|
rx.hstack(
|
||||||
rx.icon("cloud", size=32, color="#4DB8C4"),
|
rx.icon("cloud", size=32, color="#4DB8C4"),
|
||||||
rx.heading("پیکربند", size="7", color="#4DB8C4", font_weight="900"),
|
rx.heading(
|
||||||
|
"پیکربند",
|
||||||
|
size=rx.breakpoints(initial="6", md="7"),
|
||||||
|
color="#4DB8C4",
|
||||||
|
font_weight="900"
|
||||||
|
),
|
||||||
spacing="3",
|
spacing="3",
|
||||||
|
justify="center",
|
||||||
),
|
),
|
||||||
rx.text(
|
rx.text(
|
||||||
"ارائهدهنده خدمات هاستینگ، دامین و زیرساخت ابری با کیفیت بالا و پشتیبانی 24/7",
|
"ارائهدهنده خدمات هاستینگ، دامین و زیرساخت ابری با کیفیت بالا و پشتیبانی 24/7",
|
||||||
color="#94A3B8",
|
color="#94A3B8",
|
||||||
font_size="17px",
|
font_size=rx.breakpoints(initial="15px", md="17px"),
|
||||||
line_height="1.7",
|
line_height="1.7",
|
||||||
max_width="450px",
|
max_width="450px",
|
||||||
font_weight="500",
|
font_weight="500",
|
||||||
|
text_align=rx.breakpoints(initial="center", lg="start"),
|
||||||
),
|
),
|
||||||
spacing="5",
|
spacing="5",
|
||||||
align="start",
|
align=rx.breakpoints(initial="center", lg="start"),
|
||||||
|
width=rx.breakpoints(initial="100%", lg="auto"),
|
||||||
),
|
),
|
||||||
rx.spacer(),
|
rx.spacer(),
|
||||||
rx.hstack(
|
rx.hstack(
|
||||||
@@ -1762,22 +1790,27 @@ def footer() -> rx.Component:
|
|||||||
color="#94A3B8",
|
color="#94A3B8",
|
||||||
),
|
),
|
||||||
spacing="6",
|
spacing="6",
|
||||||
|
justify="center",
|
||||||
),
|
),
|
||||||
|
direction=rx.breakpoints(initial="column", lg="row"),
|
||||||
width="100%",
|
width="100%",
|
||||||
align="center",
|
align="center",
|
||||||
padding_y="40px",
|
justify=rx.breakpoints(initial="center", lg="between"),
|
||||||
|
spacing=rx.breakpoints(initial="8", lg="0"),
|
||||||
|
padding_y=rx.breakpoints(initial="30px", md="40px"),
|
||||||
),
|
),
|
||||||
rx.divider(background="rgba(27, 75, 127, 0.3)", margin_y="8"),
|
rx.divider(background="rgba(27, 75, 127, 0.3)", margin_y="8"),
|
||||||
rx.text(
|
rx.text(
|
||||||
"© ۱۴۰۳ پیکربند. تمامی حقوق محفوظ است.",
|
"© ۱۴۰۳ پیکربند. تمامی حقوق محفوظ است.",
|
||||||
color="#64748B",
|
color="#64748B",
|
||||||
font_size="16px",
|
font_size=rx.breakpoints(initial="14px", md="16px"),
|
||||||
font_weight="600",
|
font_weight="600",
|
||||||
padding_bottom="10",
|
padding_bottom="10",
|
||||||
|
text_align="center",
|
||||||
),
|
),
|
||||||
max_width="1500px",
|
max_width="1500px",
|
||||||
margin="0 auto",
|
margin="0 auto",
|
||||||
padding="60px 8% 40px",
|
padding=rx.breakpoints(initial="40px 5% 30px", md="50px 6% 35px", lg="60px 8% 40px"),
|
||||||
),
|
),
|
||||||
width="100%",
|
width="100%",
|
||||||
background="linear-gradient(180deg, rgba(10, 18, 35, 0.98) 0%, rgba(5, 10, 20, 1) 100%)",
|
background="linear-gradient(180deg, rgba(10, 18, 35, 0.98) 0%, rgba(5, 10, 20, 1) 100%)",
|
||||||
|
|||||||
18
restore-files.sh
Executable file
18
restore-files.sh
Executable file
@@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Script to restore original pipeline file names
|
||||||
|
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
|
||||||
|
echo "═══ Restoring original file names ═══"
|
||||||
|
|
||||||
|
mv .woodpecker.yml .woodpecker-base.yml
|
||||||
|
mv .woodpecker-app.yml .woodpecker.yml
|
||||||
|
|
||||||
|
echo "✓ Files restored:"
|
||||||
|
ls -lh .woodpecker*.yml
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "Now you can:"
|
||||||
|
echo " 1. Commit the changes"
|
||||||
|
echo " 2. Push to trigger application pipeline"
|
||||||
|
|
||||||
Reference in New Issue
Block a user