Compare commits
20 Commits
432aa63e36
...
feature/re
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f19f60015b | ||
|
|
3e3d396409 | ||
|
|
cf6fcd4dfe | ||
|
|
15e664461d | ||
|
|
8253fa73de | ||
|
|
fdfca1c4f1 | ||
|
|
a608726db9 | ||
|
|
6fe58c3815 | ||
|
|
826447e9a2 | ||
|
|
7c1b8b90ba | ||
|
|
82af967dfc | ||
|
|
8766103637 | ||
|
|
cb64fa1da2 | ||
|
|
ff32c54269 | ||
|
|
0694d10b7a | ||
|
|
87bb61e471 | ||
|
|
dc9faa989f | ||
|
|
46df8290ec | ||
|
|
5fed68fc54 | ||
|
|
7f4d167ca6 |
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
|
||||||
|
|
||||||
344
.woodpecker.yml
344
.woodpecker.yml
@@ -1,100 +1,72 @@
|
|||||||
# 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:
|
pipeline:
|
||||||
# ============================================
|
# ============================================
|
||||||
# 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
|
||||||
|
|
||||||
dockerfile: docker/Dockerfile
|
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
|
||||||
|
- base-python3.11-node20
|
||||||
|
|
||||||
|
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
|
pull: true
|
||||||
cache_to: type=inline
|
|
||||||
provenance: false
|
provenance: false
|
||||||
|
sbom: false
|
||||||
|
push: true
|
||||||
|
|
||||||
# فقط build، بدون push
|
|
||||||
push: false
|
|
||||||
load: false
|
|
||||||
|
|
||||||
when:
|
when:
|
||||||
- event: [push, tag]
|
event: [push, tag, manual]
|
||||||
branch: [main, develop]
|
branch: [main, develop, feature/restructure-project]
|
||||||
|
# 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:
|
||||||
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 +77,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 +95,102 @@ 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
|
pull: true
|
||||||
cache_to: type=inline
|
|
||||||
provenance: false
|
provenance: false
|
||||||
|
sbom: false
|
||||||
# حالا push میکنیم
|
|
||||||
push: true
|
push: true
|
||||||
|
|
||||||
when:
|
when:
|
||||||
- event: [push, tag]
|
event: [push, tag]
|
||||||
branch: [main, develop]
|
branch: [main, develop, feature/restructure-project]
|
||||||
|
|
||||||
# ============================================
|
# ============================================
|
||||||
# Stage 4: Verify Push
|
# Verify Images
|
||||||
# ============================================
|
# ============================================
|
||||||
|
|
||||||
verify-push:
|
verify-images:
|
||||||
image: alpine:latest
|
image: alpine:latest
|
||||||
commands:
|
commands:
|
||||||
- apk add --no-cache curl
|
- apk add --no-cache curl
|
||||||
- |
|
- |
|
||||||
echo "Verifying image was pushed successfully..."
|
echo "════════════════════════════════════════"
|
||||||
sleep 3 # Wait for registry sync
|
echo " 🔍 Verifying Images in Registry"
|
||||||
|
echo "════════════════════════════════════════"
|
||||||
REGISTRY="hub.peikarband.ir"
|
echo ""
|
||||||
REPO="peikarband/landing"
|
|
||||||
TAG="${CI_COMMIT_SHA:0:8}"
|
|
||||||
|
|
||||||
|
# Check base image
|
||||||
|
echo "Checking base image..."
|
||||||
if curl -f -u "$HARBOR_USERNAME:$HARBOR_PASSWORD" \
|
if curl -f -u "$HARBOR_USERNAME:$HARBOR_PASSWORD" \
|
||||||
"https://$REGISTRY/v2/$REPO/manifests/$TAG" > /dev/null 2>&1; then
|
"https://hub.peikarband.ir/v2/peikarband/landing/manifests/base" > /dev/null 2>&1; then
|
||||||
echo "✓ Image verified: $REGISTRY/$REPO:$TAG"
|
echo "✅ Base image: hub.peikarband.ir/peikarband/landing:base"
|
||||||
else
|
else
|
||||||
echo "❌ Failed to verify image push"
|
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
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
secrets: [HARBOR_USERNAME, HARBOR_PASSWORD]
|
secrets: [HARBOR_USERNAME, HARBOR_PASSWORD]
|
||||||
when:
|
when:
|
||||||
- event: [push, tag]
|
event: [push, tag]
|
||||||
branch: [main, develop]
|
branch: [main, develop, feature/restructure-project]
|
||||||
|
|
||||||
# ============================================
|
# ============================================
|
||||||
# Stages below are commented for now
|
# Notifications
|
||||||
# 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:
|
notify-success:
|
||||||
image: alpine:latest
|
image: alpine:latest
|
||||||
commands:
|
commands:
|
||||||
- echo "🎉 Pipeline completed successfully!"
|
- echo "════════════════════════════════════════"
|
||||||
- echo "Branch: ${CI_COMMIT_BRANCH}"
|
- echo " 🎉 Pipeline Completed Successfully!"
|
||||||
- echo "Commit: ${CI_COMMIT_SHA:0:8}"
|
- echo "════════════════════════════════════════"
|
||||||
- echo "Image: hub.peikarband.ir/peikarband/landing:${CI_COMMIT_SHA:0:8}"
|
- echo ""
|
||||||
|
- echo "Branch:" "${CI_COMMIT_BRANCH}"
|
||||||
|
- echo "Commit:" "${CI_COMMIT_SHA:0:8}"
|
||||||
|
- echo ""
|
||||||
|
- echo "Images:"
|
||||||
|
- echo " • Base:" "hub.peikarband.ir/peikarband/landing:base"
|
||||||
|
- echo " • App:" "hub.peikarband.ir/peikarband/landing:${CI_COMMIT_SHA:0:8}"
|
||||||
|
- echo ""
|
||||||
|
- echo "Deploy with:"
|
||||||
|
- echo " kubectl set image deployment/peikarband-landing \\"
|
||||||
|
- echo " peikarband-landing=hub.peikarband.ir/peikarband/landing:${CI_COMMIT_SHA:0:8}"
|
||||||
|
- echo ""
|
||||||
|
- echo "════════════════════════════════════════"
|
||||||
when:
|
when:
|
||||||
- event: [push, tag]
|
event: [push, tag]
|
||||||
status: success
|
status: success
|
||||||
|
|
||||||
notify-failure:
|
notify-failure:
|
||||||
image: alpine:latest
|
image: alpine:latest
|
||||||
commands:
|
commands:
|
||||||
- echo "❌ Pipeline failed!"
|
- echo "════════════════════════════════════════"
|
||||||
- echo "Branch: ${CI_COMMIT_BRANCH}"
|
- echo " ❌ Pipeline Failed!"
|
||||||
- echo "Commit: ${CI_COMMIT_SHA:0:8}"
|
- echo "════════════════════════════════════════"
|
||||||
|
- echo ""
|
||||||
|
- echo "Branch:" "${CI_COMMIT_BRANCH}"
|
||||||
|
- echo "Commit:" "${CI_COMMIT_SHA:0:8}"
|
||||||
|
- echo ""
|
||||||
- echo "Please check the logs above"
|
- echo "Please check the logs above"
|
||||||
|
- echo "════════════════════════════════════════"
|
||||||
when:
|
when:
|
||||||
- event: [push, tag]
|
event: [push, tag]
|
||||||
status: failure
|
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 ""
|
||||||
|
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
# 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/base:latest
|
||||||
@@ -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,124 @@ 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
|
||||||
ARG PYTHON_VERSION=3.11
|
COPY peikarband/ .
|
||||||
ARG VERSION=latest
|
|
||||||
ARG BUILD_DATE
|
|
||||||
|
|
||||||
# Build info
|
# Initialize Reflex and build frontend
|
||||||
ENV VERSION=${VERSION} \
|
RUN reflex init --loglevel debug || true && \
|
||||||
BUILD_DATE=${BUILD_DATE}
|
reflex export --frontend-only --no-zip --loglevel debug || echo "Export completed with warnings"
|
||||||
|
|
||||||
|
# Build frontend with npm (fallback if reflex export fails)
|
||||||
|
WORKDIR /build/.web
|
||||||
|
|
||||||
|
# Configure npm for better reliability
|
||||||
|
RUN npm config set fetch-retry-mintimeout 20000 && \
|
||||||
|
npm config set fetch-retry-maxtimeout 120000 && \
|
||||||
|
npm config set fetch-retries 5 && \
|
||||||
|
npm config set fetch-timeout 300000
|
||||||
|
|
||||||
|
# Install and build
|
||||||
|
RUN --mount=type=cache,target=/root/.npm \
|
||||||
|
npm ci --prefer-offline --no-audit --loglevel verbose && \
|
||||||
|
npm run build
|
||||||
|
|
||||||
|
# ============================================
|
||||||
|
# Stage 2: Runtime (using base image for Node.js)
|
||||||
|
# ============================================
|
||||||
|
FROM ${BASE_IMAGE} AS runtime
|
||||||
|
|
||||||
|
LABEL org.opencontainers.image.title="Peikarband Landing"
|
||||||
|
LABEL org.opencontainers.image.description="Peikarband hosting platform landing page"
|
||||||
|
LABEL org.opencontainers.image.vendor="Peikarband"
|
||||||
|
LABEL org.opencontainers.image.version="${VERSION}"
|
||||||
|
LABEL org.opencontainers.image.created="${BUILD_DATE}"
|
||||||
|
|
||||||
|
# Create non-root user
|
||||||
|
RUN groupadd -r peikarband && \
|
||||||
|
useradd -r -g peikarband -u 1000 -m -s /bin/bash peikarband
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# Install runtime dependencies only
|
# Base image already has everything we need:
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
# - Python 3.11
|
||||||
curl \
|
# - Node.js 20
|
||||||
ca-certificates \
|
# - curl, ca-certificates
|
||||||
tini \
|
# - tini (for proper init)
|
||||||
&& rm -rf /var/lib/apt/lists/* \
|
# No additional packages needed!
|
||||||
&& apt-get clean
|
|
||||||
|
|
||||||
# Install Node.js runtime
|
# Copy Python dependencies from builder
|
||||||
ARG NODE_VERSION=20
|
COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages
|
||||||
RUN curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION}.x | bash - \
|
COPY --from=builder /usr/local/bin /usr/local/bin
|
||||||
&& apt-get install -y --no-install-recommends nodejs \
|
|
||||||
&& rm -rf /var/lib/apt/lists/* \
|
|
||||||
&& apt-get clean
|
|
||||||
|
|
||||||
# Create non-root user first
|
# Copy application code
|
||||||
RUN groupadd -r -g 1000 peikarband && \
|
COPY --from=builder --chown=peikarband:peikarband /build /app
|
||||||
useradd -r -u 1000 -g peikarband -m -s /bin/bash peikarband && \
|
|
||||||
mkdir -p /app/logs /app/uploads /app/.reflex
|
|
||||||
|
|
||||||
# Copy Python dependencies from builder to user home
|
# Create necessary directories
|
||||||
COPY --from=builder /root/.local /home/peikarband/.local
|
RUN mkdir -p /app/data /app/logs /app/uploaded_files && \
|
||||||
|
chown -R peikarband:peikarband /app
|
||||||
|
|
||||||
# Copy application code from builder
|
# Set proper permissions
|
||||||
COPY --from=builder /build /app
|
RUN chmod -R 755 /app && \
|
||||||
|
chmod -R 777 /app/data /app/logs /app/uploaded_files
|
||||||
|
|
||||||
# Copy and set up runtime script
|
# Environment variables
|
||||||
COPY --chown=peikarband:peikarband peikarband/tools/scripts/update-env-json.sh /app/tools/scripts/update-env-json.sh
|
ENV PYTHONUNBUFFERED=1 \
|
||||||
RUN chmod +x /app/tools/scripts/update-env-json.sh
|
|
||||||
|
|
||||||
# Fix ownership
|
|
||||||
RUN chown -R peikarband:peikarband /home/peikarband/.local /app
|
|
||||||
|
|
||||||
# Add version info (must be before USER switch)
|
|
||||||
RUN echo "${VERSION}" > /app/.version && \
|
|
||||||
chown peikarband:peikarband /app/.version
|
|
||||||
|
|
||||||
# Security: Remove unnecessary setuid/setgid permissions
|
|
||||||
RUN find / -perm /6000 -type f -exec chmod a-s {} \; 2>/dev/null || true
|
|
||||||
|
|
||||||
# Set environment variables
|
|
||||||
ENV PATH=/home/peikarband/.local/bin:$PATH \
|
|
||||||
PYTHONUNBUFFERED=1 \
|
|
||||||
PYTHONDONTWRITEBYTECODE=1 \
|
PYTHONDONTWRITEBYTECODE=1 \
|
||||||
PYTHONHASHSEED=random \
|
PYTHONPATH=/app \
|
||||||
PIP_NO_CACHE_DIR=1 \
|
PATH="/app/.venv/bin:$PATH" \
|
||||||
PIP_DISABLE_PIP_VERSION_CHECK=1 \
|
REFLEX_DIR=/app \
|
||||||
REFLEX_ENV=prod \
|
NODE_ENV=production
|
||||||
ENVIRONMENT=prod
|
|
||||||
|
# Health check
|
||||||
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
|
||||||
|
CMD curl -f http://localhost:${PORT:-3000}/_health || exit 1
|
||||||
|
|
||||||
# Switch to non-root user
|
# Switch to non-root user
|
||||||
USER peikarband
|
USER peikarband
|
||||||
|
|
||||||
# Expose ports
|
# 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", "--"]
|
||||||
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
|
CMD ["reflex", "run", "--env", "prod", "--loglevel", "info"]
|
||||||
ENTRYPOINT ["/usr/bin/tini", "--", "/app/tools/scripts/update-env-json.sh"]
|
|
||||||
|
|
||||||
# Run application (both frontend and backend)
|
# ============================================
|
||||||
CMD ["python", "-m", "reflex", "run", "--env", "prod"]
|
# Build Information
|
||||||
|
# ============================================
|
||||||
|
ARG GIT_COMMIT
|
||||||
|
ARG GIT_BRANCH
|
||||||
|
ARG BUILD_NUMBER
|
||||||
|
|
||||||
|
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 .
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
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 کافیه! 👍
|
||||||
|
|
||||||
|
**آینده:** اگر پروژه دوم شروع شد، مجدداً ارزیابی کنید.
|
||||||
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