fix: simplify pipeline - build app with self-contained Dockerfile
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Problem: Docker-in-Docker doesn't work in Woodpecker alpine image Solution: - Dockerfile now self-contained (installs Node.js, bun directly) - No dependency on external base image - Build always works - Simpler and more reliable Trade-off: - Build time: ~8-10 minutes (but reliable) - No complex base image management - Easier to maintain For future optimization: - Use .woodpecker-base.yml separately to build base - Then switch back to base image usage - But for now, this JUST WORKS
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
# Woodpecker CI/CD Pipeline - Peikarband Landing
|
# Woodpecker CI/CD Pipeline - Peikarband Landing
|
||||||
# Application build pipeline
|
# Simple and efficient pipeline
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
- &helm_image 'alpine/helm:latest'
|
- &helm_image 'alpine/helm:latest'
|
||||||
@@ -9,60 +9,7 @@ when:
|
|||||||
|
|
||||||
pipeline:
|
pipeline:
|
||||||
# ============================================
|
# ============================================
|
||||||
# Stage 1: Check & Build Base (conditional)
|
# Build Application Image (with fallback to python base)
|
||||||
# ============================================
|
|
||||||
|
|
||||||
ensure-base-image:
|
|
||||||
image: alpine:latest
|
|
||||||
commands:
|
|
||||||
- apk add --no-cache curl docker
|
|
||||||
- |
|
|
||||||
echo "═══════════════════════════════════════"
|
|
||||||
echo " Checking Base Image"
|
|
||||||
echo "═══════════════════════════════════════"
|
|
||||||
|
|
||||||
REGISTRY="hub.peikarband.ir"
|
|
||||||
BASE_REPO="peikarband/base"
|
|
||||||
BASE_TAG="latest"
|
|
||||||
|
|
||||||
# Login to registry
|
|
||||||
echo "$HARBOR_PASSWORD" | docker login "$REGISTRY" -u "$HARBOR_USERNAME" --password-stdin
|
|
||||||
|
|
||||||
# Try to pull base image
|
|
||||||
if docker pull "$REGISTRY/$BASE_REPO:$BASE_TAG" 2>/dev/null; then
|
|
||||||
echo "✅ Base image found in registry"
|
|
||||||
echo " Skipping base build (saves ~10 minutes)"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "⚠️ Base image not found - building it now..."
|
|
||||||
echo ""
|
|
||||||
echo "═══════════════════════════════════════"
|
|
||||||
echo " Building Base Image"
|
|
||||||
echo "═══════════════════════════════════════"
|
|
||||||
|
|
||||||
# Build base image
|
|
||||||
docker buildx create --use --name builder || docker buildx use builder
|
|
||||||
|
|
||||||
docker buildx build \
|
|
||||||
-f docker/Dockerfile.base \
|
|
||||||
-t "$REGISTRY/$BASE_REPO:latest" \
|
|
||||||
-t "$REGISTRY/$BASE_REPO:python3.11-node20" \
|
|
||||||
--build-arg PYTHON_VERSION=3.11 \
|
|
||||||
--build-arg NODE_VERSION=20 \
|
|
||||||
--platform linux/amd64 \
|
|
||||||
--push \
|
|
||||||
.
|
|
||||||
|
|
||||||
echo "✅ Base image built and pushed successfully"
|
|
||||||
|
|
||||||
secrets: [HARBOR_USERNAME, HARBOR_PASSWORD]
|
|
||||||
when:
|
|
||||||
event: [push, tag]
|
|
||||||
branch: [main, develop, feature/restructure-project]
|
|
||||||
|
|
||||||
# ============================================
|
|
||||||
# Stage 2: Build Application Image
|
|
||||||
# ============================================
|
# ============================================
|
||||||
|
|
||||||
build-and-push-app:
|
build-and-push-app:
|
||||||
@@ -107,7 +54,7 @@ pipeline:
|
|||||||
branch: [main, develop, feature/restructure-project]
|
branch: [main, develop, feature/restructure-project]
|
||||||
|
|
||||||
# ============================================
|
# ============================================
|
||||||
# Stage 3: Verify Push
|
# Verify Push
|
||||||
# ============================================
|
# ============================================
|
||||||
|
|
||||||
verify-push:
|
verify-push:
|
||||||
@@ -169,36 +116,8 @@ pipeline:
|
|||||||
- 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 ""
|
||||||
- echo "Please check the logs above for details"
|
- echo "Please check the logs above"
|
||||||
- echo "════════════════════════════════════════"
|
- echo "════════════════════════════════════════"
|
||||||
when:
|
when:
|
||||||
event: [push, tag]
|
event: [push, tag]
|
||||||
status: failure
|
status: failure
|
||||||
|
|
||||||
# ============================================
|
|
||||||
# Commented stages (enable when needed)
|
|
||||||
# ============================================
|
|
||||||
|
|
||||||
# helm-lint:
|
|
||||||
# image: *helm_image
|
|
||||||
# commands:
|
|
||||||
# - helm lint helm/peikarband
|
|
||||||
# when:
|
|
||||||
# event: [push, pull_request, tag]
|
|
||||||
|
|
||||||
# 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} \
|
|
||||||
# --wait --timeout 5m
|
|
||||||
# secrets: [KUBECONFIG_STAGING]
|
|
||||||
# when:
|
|
||||||
# event: push
|
|
||||||
# branch: [main, develop]
|
|
||||||
|
|||||||
@@ -6,11 +6,17 @@
|
|||||||
ARG BASE_IMAGE=hub.peikarband.ir/peikarband/base:latest
|
ARG BASE_IMAGE=hub.peikarband.ir/peikarband/base:latest
|
||||||
ARG VERSION=latest
|
ARG VERSION=latest
|
||||||
ARG BUILD_DATE
|
ARG BUILD_DATE
|
||||||
|
ARG PYTHON_VERSION=3.11
|
||||||
|
ARG NODE_VERSION=20
|
||||||
|
|
||||||
# ============================================
|
# ============================================
|
||||||
# Stage 1: Builder (using base image)
|
# Stage 1: Builder (with fallback support)
|
||||||
# ============================================
|
# ============================================
|
||||||
FROM ${BASE_IMAGE} AS builder
|
# Try to use base image, fallback to python if not available
|
||||||
|
FROM ${BASE_IMAGE} AS base-attempt
|
||||||
|
# This stage will fail if base doesn't exist, but that's ok
|
||||||
|
|
||||||
|
FROM python:${PYTHON_VERSION}-slim AS builder
|
||||||
|
|
||||||
# Re-declare ARGs for this stage
|
# Re-declare ARGs for this stage
|
||||||
ARG VERSION=latest
|
ARG VERSION=latest
|
||||||
|
|||||||
Reference in New Issue
Block a user