refactor: migrar GitLab → Gitea (aulas 10, 11, 13)

- Aula 10: Gitea + Registry + Actions + Runner (substituiu GitLab)
  - gitea-values.yaml: PostgreSQL standalone, Valkey standalone, ~800Mi RAM
  - setup.sh/cleanup.sh: namespace gitea, Helm gitea-charts/gitea + actions
  - README.md: documentação completa com de→para (GitLab/Harbor/Tekton vs Gitea)

- Aula 11: ArgoCD (GitOps) — removido GitLab Runner (runner vive na aula-10)
  - setup.sh: só ArgoCD, integração SSH com Gitea
  - node-bugado/.gitea/workflows/ci.yml: pipeline convertida

- Aula 13: Container Factory — atualizado para Gitea
  - setup.sh/cleanup.sh: referências GitLab → Gitea
  - pipelines/postgresql/ci.yml: Gitea Actions workflow
  - README.md: conexão com act_runner explicada

- CLAUDE.md: tabela de aulas atualizada
This commit is contained in:
ArgoCD Setup
2026-03-14 01:44:30 -03:00
parent ff7af56c30
commit d380cd8585
35 changed files with 3374 additions and 1202 deletions

View File

@@ -0,0 +1,183 @@
# =============================================================================
# GitLab CI/CD Pipeline - PostgreSQL Container Factory
# =============================================================================
#
# Build de imagem PostgreSQL customizada em formato eStargz.
# Push para registry.kube.quest com lazy pulling habilitado.
#
# Requisitos:
# - GitLab Runner com Docker-in-Docker (aula-11)
# - BuildKit habilitado
#
# Uso:
# 1. Criar grupo 'factory' no GitLab
# 2. Criar projeto 'postgresql' dentro do grupo
# 3. Copiar Dockerfile, postgresql.conf e este .gitlab-ci.yml
# 4. Push para main - pipeline roda automaticamente
#
# =============================================================================
stages:
- build
- test
- push
variables:
# Registry do GitLab (aula-10)
REGISTRY: ${CI_REGISTRY}
IMAGE_NAME: ${CI_PROJECT_PATH}
POSTGRES_VERSION: "17"
# BuildKit para suporte a eStargz
DOCKER_BUILDKIT: "1"
BUILDKIT_PROGRESS: plain
# Docker-in-Docker TLS connection
DOCKER_HOST: tcp://docker:2376
DOCKER_TLS_CERTDIR: "/certs"
DOCKER_CERT_PATH: "/certs/client"
DOCKER_TLS_VERIFY: "1"
# =============================================================================
# BUILD - Construir imagem em formato eStargz
# =============================================================================
build:
stage: build
image: docker:24
services:
- docker:24-dind
before_script:
# Aguardar Docker daemon estar pronto
- until docker info; do sleep 1; done
# Login no registry
- docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
# Configurar buildx com driver docker (usa daemon existente)
- docker buildx create --name estargz-builder --driver docker --use || true
- docker buildx inspect --bootstrap
script:
- echo "Building ${IMAGE_NAME}:${POSTGRES_VERSION}-${CI_COMMIT_SHA:0:8} with eStargz compression"
# Build com formato eStargz
- |
docker buildx build \
--output type=image,name=${REGISTRY}/${IMAGE_NAME}:${POSTGRES_VERSION}-${CI_COMMIT_SHA:0:8},push=true,compression=estargz,force-compression=true,oci-mediatypes=true \
--label "org.opencontainers.image.revision=${CI_COMMIT_SHA}" \
--label "org.opencontainers.image.created=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
--label "org.opencontainers.image.source=${CI_PROJECT_URL}" \
--build-arg POSTGRES_VERSION=${POSTGRES_VERSION} \
.
rules:
- if: $CI_COMMIT_BRANCH == "main"
- if: $CI_COMMIT_TAG
tags:
- kubernetes
- docker
# =============================================================================
# TEST - Testar imagem construída
# =============================================================================
test:
stage: test
image: docker:24
services:
- docker:24-dind
before_script:
- until docker info; do sleep 1; done
- docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
script:
- echo "Testing PostgreSQL image..."
# Iniciar container de teste
- |
docker run -d --name pg-test \
-e POSTGRES_PASSWORD=testpassword \
-e POSTGRES_DB=testdb \
${REGISTRY}/${IMAGE_NAME}:${POSTGRES_VERSION}-${CI_COMMIT_SHA:0:8}
# Aguardar inicialização (30s max)
- |
for i in $(seq 1 30); do
if docker exec pg-test pg_isready -U postgres -d testdb 2>/dev/null; then
echo "PostgreSQL ready!"
break
fi
echo "Waiting for PostgreSQL... ($i/30)"
sleep 1
done
# Verificar healthcheck
- docker exec pg-test pg_isready -U postgres -d testdb
# Testar conexão e queries básicas
- docker exec pg-test psql -U postgres -d testdb -c "SELECT version();"
- docker exec pg-test psql -U postgres -d testdb -c "SHOW shared_buffers;"
- docker exec pg-test psql -U postgres -d testdb -c "SHOW max_connections;"
# Testar criação de tabela
- docker exec pg-test psql -U postgres -d testdb -c "CREATE TABLE test (id serial PRIMARY KEY, name text);"
- docker exec pg-test psql -U postgres -d testdb -c "INSERT INTO test (name) VALUES ('test');"
- docker exec pg-test psql -U postgres -d testdb -c "SELECT * FROM test;"
- docker exec pg-test psql -U postgres -d testdb -c "DROP TABLE test;"
# Cleanup
- docker stop pg-test && docker rm pg-test
- echo "All tests passed!"
needs:
- build
rules:
- if: $CI_COMMIT_BRANCH == "main"
- if: $CI_COMMIT_TAG
tags:
- kubernetes
- docker
# =============================================================================
# PUSH - Tag como versão e latest
# =============================================================================
push:
stage: push
image: docker:24
services:
- docker:24-dind
before_script:
- until docker info; do sleep 1; done
- docker login -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD} ${CI_REGISTRY}
- docker buildx create --name estargz-builder --driver docker --use || true
- docker buildx inspect --bootstrap
script:
- echo "Tagging and pushing final images..."
# Re-tag como versão (17)
- |
docker buildx build \
--output type=image,name=${REGISTRY}/${IMAGE_NAME}:${POSTGRES_VERSION},push=true,compression=estargz,force-compression=true,oci-mediatypes=true \
--label "org.opencontainers.image.revision=${CI_COMMIT_SHA}" \
--label "org.opencontainers.image.created=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
.
# Re-tag como latest
- |
docker buildx build \
--output type=image,name=${REGISTRY}/${IMAGE_NAME}:latest,push=true,compression=estargz,force-compression=true,oci-mediatypes=true \
--label "org.opencontainers.image.revision=${CI_COMMIT_SHA}" \
--label "org.opencontainers.image.created=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
.
# Build versão GZIP (para benchmark)
- |
docker buildx build \
--output type=image,name=${REGISTRY}/${IMAGE_NAME}:${POSTGRES_VERSION}-gzip,push=true,compression=gzip,oci-mediatypes=true \
--label "org.opencontainers.image.revision=${CI_COMMIT_SHA}" \
--label "org.opencontainers.image.created=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
.
- echo "Images pushed:"
- echo " - ${REGISTRY}/${IMAGE_NAME}:${POSTGRES_VERSION} (eStargz)"
- echo " - ${REGISTRY}/${IMAGE_NAME}:${POSTGRES_VERSION}-gzip (tradicional)"
- echo " - ${REGISTRY}/${IMAGE_NAME}:latest (eStargz)"
needs:
- test
rules:
- if: $CI_COMMIT_BRANCH == "main"
tags:
- kubernetes
- docker

View File

@@ -0,0 +1,157 @@
# =============================================================================
# Gitea Actions Workflow - PostgreSQL Container Factory
# =============================================================================
#
# Build de imagem PostgreSQL customizada em formato eStargz.
# Push para Gitea Container Registry com lazy pulling habilitado.
#
# Requisitos:
# - Gitea Actions Runner com Docker (aula-10)
# - Secret REGISTRY_TOKEN configurado no repo
#
# Uso:
# 1. Criar org 'factory' no Gitea
# 2. Criar repositório 'postgresql' na org
# 3. Copiar Dockerfile, postgresql.conf e este ci.yml para .gitea/workflows/
# 4. Push para main - pipeline roda automaticamente
#
# =============================================================================
name: Build PostgreSQL
on:
push:
branches: [main]
tags: ['*']
env:
REGISTRY: gitea.kube.quest
IMAGE_NAME: factory/postgresql
POSTGRES_VERSION: "17"
jobs:
# ===========================================================================
# BUILD - Construir imagem em formato eStargz
# ===========================================================================
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Gitea Registry
run: |
echo "${{ secrets.REGISTRY_TOKEN }}" | docker login ${{ env.REGISTRY }} \
-u ${{ gitea.actor }} --password-stdin
- name: Build eStargz image
run: |
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-8)
echo "Building ${{ env.IMAGE_NAME }}:${{ env.POSTGRES_VERSION }}-${SHORT_SHA} with eStargz compression"
docker buildx build \
--output type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.POSTGRES_VERSION }}-${SHORT_SHA},push=true,compression=estargz,force-compression=true,oci-mediatypes=true \
--label "org.opencontainers.image.revision=${{ github.sha }}" \
--label "org.opencontainers.image.created=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
--build-arg POSTGRES_VERSION=${{ env.POSTGRES_VERSION }} \
.
# ===========================================================================
# TEST - Testar imagem construída
# ===========================================================================
test:
runs-on: ubuntu-latest
needs: build
steps:
- name: Login to Gitea Registry
run: |
echo "${{ secrets.REGISTRY_TOKEN }}" | docker login ${{ env.REGISTRY }} \
-u ${{ gitea.actor }} --password-stdin
- name: Test PostgreSQL image
run: |
SHORT_SHA=$(echo "${{ github.sha }}" | cut -c1-8)
echo "Testing PostgreSQL image..."
docker run -d --name pg-test \
-e POSTGRES_PASSWORD=testpassword \
-e POSTGRES_DB=testdb \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.POSTGRES_VERSION }}-${SHORT_SHA}
# Aguardar inicialização (30s max)
for i in $(seq 1 30); do
if docker exec pg-test pg_isready -U postgres -d testdb 2>/dev/null; then
echo "PostgreSQL ready!"
break
fi
echo "Waiting for PostgreSQL... ($i/30)"
sleep 1
done
# Verificar healthcheck
docker exec pg-test pg_isready -U postgres -d testdb
# Testar conexão e queries básicas
docker exec pg-test psql -U postgres -d testdb -c "SELECT version();"
docker exec pg-test psql -U postgres -d testdb -c "SHOW shared_buffers;"
docker exec pg-test psql -U postgres -d testdb -c "SHOW max_connections;"
# Testar criação de tabela
docker exec pg-test psql -U postgres -d testdb -c "CREATE TABLE test (id serial PRIMARY KEY, name text);"
docker exec pg-test psql -U postgres -d testdb -c "INSERT INTO test (name) VALUES ('test');"
docker exec pg-test psql -U postgres -d testdb -c "SELECT * FROM test;"
docker exec pg-test psql -U postgres -d testdb -c "DROP TABLE test;"
# Cleanup
docker stop pg-test && docker rm pg-test
echo "All tests passed!"
# ===========================================================================
# PUSH - Tag como versão e latest
# ===========================================================================
push:
runs-on: ubuntu-latest
needs: test
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Gitea Registry
run: |
echo "${{ secrets.REGISTRY_TOKEN }}" | docker login ${{ env.REGISTRY }} \
-u ${{ gitea.actor }} --password-stdin
- name: Push version and latest tags (eStargz)
run: |
echo "Tagging and pushing final images..."
# Tag como versão (17)
docker buildx build \
--output type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.POSTGRES_VERSION }},push=true,compression=estargz,force-compression=true,oci-mediatypes=true \
--label "org.opencontainers.image.revision=${{ github.sha }}" \
--label "org.opencontainers.image.created=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
.
# Tag como latest
docker buildx build \
--output type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,push=true,compression=estargz,force-compression=true,oci-mediatypes=true \
--label "org.opencontainers.image.revision=${{ github.sha }}" \
--label "org.opencontainers.image.created=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
.
- name: Push GZIP version (for benchmark)
run: |
docker buildx build \
--output type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.POSTGRES_VERSION }}-gzip,push=true,compression=gzip,oci-mediatypes=true \
--label "org.opencontainers.image.revision=${{ github.sha }}" \
--label "org.opencontainers.image.created=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
.
echo "Images pushed:"
echo " - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.POSTGRES_VERSION }} (eStargz)"
echo " - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.POSTGRES_VERSION }}-gzip (GZIP)"
echo " - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest (eStargz)"