feat: implement complete CI/CD with base image strategy

- Add Woodpecker pipeline with base image support
- Separate base image build (.woodpecker-base.yml) from app build (.woodpecker.yml)
- Implement build/push separation in application pipeline
- Create Docker base image with Python 3.11, Node.js 20, and bun
- Update Dockerfile to use pre-built base image for faster builds
- Remove GitHub Actions (not needed, using Woodpecker)
- Fix Docker contexts and paths for new structure
- Update docker-compose.yml build contexts
- Fix rxconfig.py DB path for container environment
- Add ArgoCD application manifests for staging/production
- Create comprehensive documentation:
  - docs/WOODPECKER_CI_CD.md (CI/CD guide)
  - docs/BASE_IMAGE_MANAGEMENT.md (Base image management)
  - helm/peikarband/argocd/README.md (ArgoCD deployment)

Benefits:
- Build time: 8-10min → 2-3min (60-70% faster)
- Better reliability (no repeated npm/bun downloads)
- Separation of concerns (base vs application builds)
- Full pipeline: check → build → push → verify → notify
- Complete deployment automation with Helm + ArgoCD

Pipeline stages:
1. check-base-image: Verify base image availability
2. build-image: Build application (no push)
3. push-image: Push with multi-tags (latest, sha, branch)
4. verify-push: Verify successful push
5. notify: Success/failure notifications

Base image can be rebuilt via:
- Manual trigger in Woodpecker UI
- Auto trigger when Dockerfile.base changes
This commit is contained in:
Ehsan.Asadi
2025-12-30 21:50:45 +03:30
parent b9217fe81e
commit 432aa63e36
14 changed files with 1885 additions and 390 deletions

View File

@@ -1,25 +1,24 @@
# Base Image for Peikarband Projects
# Peikarband Base Image
# Pre-built image with Python, Node.js, bun, and build tools
#
# This Dockerfile should be in a SEPARATE repository: peikarband/base
# It's kept here for reference only.
# Usage:
# Build: docker build -f docker/Dockerfile.base -t hub.peikarband.ir/peikarband/base:latest .
# Or use Woodpecker: trigger .woodpecker-base.yml pipeline
#
# Purpose: Pre-installed build tools (Python, Node.js, bun, gcc, etc.)
# Registry: hub.peikarband.ir/peikarband/base:latest
#
# This image is built once and cached, making subsequent builds much faster
# All Peikarband projects should use this base image
# This image is built once and reused by all Peikarband projects
ARG PYTHON_VERSION=3.11
ARG NODE_VERSION=20
FROM python:${PYTHON_VERSION}-slim AS base
FROM python:${PYTHON_VERSION}-slim
LABEL maintainer="Peikarband Team <dev@peikarband.ir>"
LABEL description="Base image with Python, Node.js, bun, and build tools"
LABEL org.opencontainers.image.title="Peikarband Base"
LABEL org.opencontainers.image.description="Base image with Python, Node.js, bun, and build tools"
WORKDIR /build
# Install build dependencies
# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
g++ \
@@ -28,12 +27,19 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
gnupg \
ca-certificates \
unzip \
git \
&& rm -rf /var/lib/apt/lists/*
# Install Node.js (required for Reflex)
# Install Node.js
ARG NODE_VERSION
RUN curl -fsSL https://deb.nodesource.com/setup_${NODE_VERSION}.x | bash - \
&& apt-get install -y --no-install-recommends nodejs \
&& rm -rf /var/lib/apt/lists/*
&& rm -rf /var/lib/apt/lists/* \
&& 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 \
&& npm config set registry https://registry.npmjs.org/
# Install bun (required by Reflex for frontend build)
# Retry mechanism for network issues
@@ -46,9 +52,19 @@ RUN set -ex && \
# Add bun to PATH
ENV PATH="/root/.bun/bin:${PATH}"
# Upgrade pip, setuptools, wheel
RUN pip install --no-cache-dir --upgrade pip setuptools wheel
# Verify installations
RUN python --version && \
node --version && \
npm --version && \
bun --version
bun --version && \
pip --version
# Set working directory
WORKDIR /build
# Default command
CMD ["/bin/bash"]