Add new infra architecture 6

This commit is contained in:
Urtzi Alfaro
2026-01-19 16:31:11 +01:00
parent b78399da2c
commit 7d6845574c
58 changed files with 2360 additions and 492 deletions

View File

@@ -1,6 +1,7 @@
# Main CI Pipeline for Bakery-IA
# This pipeline orchestrates the build, test, and deploy process
# Includes: fetch -> detect changes -> test -> build -> update gitops
# Supports environment-configurable base images for dev/prod flexibility
apiVersion: tekton.dev/v1beta1
kind: Pipeline
@@ -28,7 +29,7 @@ spec:
description: Git revision/commit hash
- name: registry
type: string
description: Container registry URL
description: Container registry URL for pushing built images
- name: git-branch
type: string
description: Target branch for GitOps updates
@@ -41,6 +42,15 @@ spec:
type: string
description: Dry run mode - don't push changes
default: "false"
# Base image configuration for environment-specific builds
- name: base-registry
type: string
description: "Base image registry URL (e.g., docker.io for prod, localhost:5000 for dev)"
default: "{{ .Values.pipeline.build.baseRegistry }}"
- name: python-image
type: string
description: "Python base image name and tag (e.g., python:3.11-slim for prod)"
default: "{{ .Values.pipeline.build.pythonImage }}"
tasks:
# Stage 1: Fetch source code
@@ -107,6 +117,11 @@ spec:
value: $(params.registry)
- name: git-revision
value: $(params.git-revision)
# Environment-configurable base images
- name: base-registry
value: $(params.base-registry)
- name: python-image
value: $(params.python-image)
# Stage 5: Update GitOps manifests
- name: update-gitops-manifests

View File

@@ -1,5 +1,6 @@
# Tekton Kaniko Build Task for Bakery-IA CI/CD
# This task builds and pushes container images using Kaniko
# Supports environment-configurable base images via build-args
apiVersion: tekton.dev/v1beta1
kind: Task
@@ -21,10 +22,18 @@ spec:
description: Comma-separated list of services to build
- name: registry
type: string
description: Container registry URL
description: Container registry URL for pushing built images
- name: git-revision
type: string
description: Git revision to tag images with
- name: base-registry
type: string
description: Base image registry URL (e.g., docker.io, ghcr.io/org)
default: "docker.io"
- name: python-image
type: string
description: Python base image name and tag
default: "python:3.11-slim"
results:
- name: build-status
description: Status of the build operation
@@ -37,24 +46,51 @@ spec:
script: |
#!/bin/bash
set -e
echo "==================================================================="
echo "Kaniko Build Configuration"
echo "==================================================================="
echo "Target Registry: $(params.registry)"
echo "Base Registry: $(params.base-registry)"
echo "Python Image: $(params.python-image)"
echo "Git Revision: $(params.git-revision)"
echo "==================================================================="
# Split services parameter by comma
IFS=',' read -ra SERVICES <<< "$(params.services)"
# Build each service
for service in "${SERVICES[@]}"; do
service=$(echo "$service" | xargs) # Trim whitespace
if [ -n "$service" ] && [ "$service" != "none" ]; then
echo ""
echo "Building service: $service"
echo "-------------------------------------------------------------------"
# Determine Dockerfile path (services vs gateway)
if [ "$service" = "gateway" ]; then
DOCKERFILE_PATH="$(workspaces.source.path)/gateway/Dockerfile"
else
DOCKERFILE_PATH="$(workspaces.source.path)/services/$service/Dockerfile"
fi
/kaniko/executor \
--dockerfile="$(workspaces.source.path)/services/$service/Dockerfile" \
--dockerfile="$DOCKERFILE_PATH" \
--destination="$(params.registry)/$service:$(params.git-revision)" \
--context="$(workspaces.source.path)" \
--build-arg="BASE_REGISTRY=$(params.base-registry)" \
--build-arg="PYTHON_IMAGE=$(params.python-image)" \
--cache=true \
--cache-repo="$(params.registry)/cache"
echo "Successfully built: $(params.registry)/$service:$(params.git-revision)"
fi
done
echo ""
echo "==================================================================="
echo "Build completed successfully!"
echo "==================================================================="
echo "success" > $(results.build-status.path)
resources:
limits:

View File

@@ -19,6 +19,11 @@ pipeline:
build:
cacheTTL: "24h"
verbosity: "info"
# Base image registry configuration
# For dev: localhost:5000 with python_3.11-slim
# For prod: docker.io with python:3.11-slim
baseRegistry: "docker.io"
pythonImage: "python:3.11-slim"
# Test configuration
test: