Add full-stack Hello World app with CI/CD
- Go backend with PostgreSQL connection - Next.js frontend with TypeScript - Docker Compose for local development - Woodpecker CI pipeline for build and push - Kubernetes manifests with Kustomize - ArgoCD application for GitOps deployment Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
78
.woodpecker.yaml
Normal file
78
.woodpecker.yaml
Normal file
@@ -0,0 +1,78 @@
|
||||
# Woodpecker CI Pipeline
|
||||
# Go Backend + Next.js Frontend + PostgreSQL
|
||||
|
||||
when:
|
||||
- event: [push, pull_request]
|
||||
branch: main
|
||||
|
||||
steps:
|
||||
# 1. Backend Docker image build
|
||||
build-backend:
|
||||
image: docker:24-dind
|
||||
privileged: true
|
||||
commands:
|
||||
- docker build -t hell-world-backend:${CI_COMMIT_SHA:0:8} ./backend
|
||||
- docker tag hell-world-backend:${CI_COMMIT_SHA:0:8} registry.gecore.mn/library/hell-world-backend:${CI_COMMIT_SHA:0:8}
|
||||
- docker tag hell-world-backend:${CI_COMMIT_SHA:0:8} registry.gecore.mn/library/hell-world-backend:latest
|
||||
|
||||
# 2. Frontend Docker image build
|
||||
build-frontend:
|
||||
image: docker:24-dind
|
||||
privileged: true
|
||||
commands:
|
||||
- docker build -t hell-world-frontend:${CI_COMMIT_SHA:0:8} ./frontend
|
||||
- docker tag hell-world-frontend:${CI_COMMIT_SHA:0:8} registry.gecore.mn/library/hell-world-frontend:${CI_COMMIT_SHA:0:8}
|
||||
- docker tag hell-world-frontend:${CI_COMMIT_SHA:0:8} registry.gecore.mn/library/hell-world-frontend:latest
|
||||
|
||||
# 3. Push backend to Harbor registry
|
||||
push-backend:
|
||||
image: docker:24-dind
|
||||
privileged: true
|
||||
commands:
|
||||
- echo "$HARBOR_PASSWORD" | docker login registry.gecore.mn -u "$HARBOR_USER" --password-stdin
|
||||
- docker push registry.gecore.mn/library/hell-world-backend:${CI_COMMIT_SHA:0:8}
|
||||
- docker push registry.gecore.mn/library/hell-world-backend:latest
|
||||
secrets: [harbor_user, harbor_password]
|
||||
when:
|
||||
event: push
|
||||
branch: main
|
||||
|
||||
# 4. Push frontend to Harbor registry
|
||||
push-frontend:
|
||||
image: docker:24-dind
|
||||
privileged: true
|
||||
commands:
|
||||
- echo "$HARBOR_PASSWORD" | docker login registry.gecore.mn -u "$HARBOR_USER" --password-stdin
|
||||
- docker push registry.gecore.mn/library/hell-world-frontend:${CI_COMMIT_SHA:0:8}
|
||||
- docker push registry.gecore.mn/library/hell-world-frontend:latest
|
||||
secrets: [harbor_user, harbor_password]
|
||||
when:
|
||||
event: push
|
||||
branch: main
|
||||
|
||||
# 5. Update Kubernetes manifests with new image tags
|
||||
update-manifests:
|
||||
image: alpine:latest
|
||||
commands:
|
||||
- apk add --no-cache sed git
|
||||
- sed -i "s|image:.*hell-world-backend.*|image: registry.gecore.mn/library/hell-world-backend:${CI_COMMIT_SHA:0:8}|g" manifests/backend-deployment.yaml
|
||||
- sed -i "s|image:.*hell-world-frontend.*|image: registry.gecore.mn/library/hell-world-frontend:${CI_COMMIT_SHA:0:8}|g" manifests/frontend-deployment.yaml
|
||||
- git config user.email "ci@gecore.mn"
|
||||
- git config user.name "Woodpecker CI"
|
||||
- git add manifests/
|
||||
- git commit -m "ci: update images to ${CI_COMMIT_SHA:0:8}" || true
|
||||
- git push origin main || true
|
||||
when:
|
||||
event: push
|
||||
branch: main
|
||||
|
||||
# 6. Deploy notification
|
||||
notify:
|
||||
image: alpine:latest
|
||||
commands:
|
||||
- echo "✅ Build completed for commit ${CI_COMMIT_SHA:0:8}"
|
||||
- echo "📦 Backend: registry.gecore.mn/library/hell-world-backend:${CI_COMMIT_SHA:0:8}"
|
||||
- echo "📦 Frontend: registry.gecore.mn/library/hell-world-frontend:${CI_COMMIT_SHA:0:8}"
|
||||
- echo "🔗 ArgoCD will sync automatically"
|
||||
when:
|
||||
status: [success, failure]
|
||||
Reference in New Issue
Block a user