Files
hell-world/README.md
Erdenebat Tsenddorj f311439621 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>
2026-01-21 21:06:08 +08:00

2.9 KiB
Raw Blame History

Hello World - Go + PostgreSQL + Next.js

Full-stack Hello World application using Go backend, PostgreSQL database, and Next.js frontend.

Project Structure

.
├── backend/          # Go API server
│   ├── main.go
│   ├── go.mod
│   └── Dockerfile
├── frontend/         # Next.js application
│   ├── app/
│   ├── package.json
│   └── Dockerfile
├── docker-compose.yml
└── README.md

Quick Start with Docker

docker-compose up --build

Services:

Manual Setup

Backend (Go)

cd backend
go mod tidy
DB_HOST=localhost DB_PORT=5432 DB_USER=postgres DB_PASSWORD=postgres DB_NAME=hellodb go run main.go

Frontend (Next.js)

cd frontend
npm install
NEXT_PUBLIC_API_URL=http://localhost:8080 npm run dev

PostgreSQL

docker run -d \
  --name hello-postgres \
  -e POSTGRES_USER=postgres \
  -e POSTGRES_PASSWORD=postgres \
  -e POSTGRES_DB=hellodb \
  -p 5432:5432 \
  postgres:16-alpine

API Endpoints

Endpoint Method Description
/api/hello GET Returns hello message and DB status
/api/health GET Health check

Tech Stack

  • Backend: Go 1.21
  • Database: PostgreSQL 16
  • Frontend: Next.js 14, React 18, TypeScript

CI/CD Pipeline

Woodpecker CI

.woodpecker.yaml файл нь дараах алхмуудыг гүйцэтгэнэ:

  1. build-backend - Go backend Docker image build
  2. build-frontend - Next.js frontend Docker image build
  3. push-backend - Harbor registry рүү backend push
  4. push-frontend - Harbor registry рүү frontend push
  5. update-manifests - Kubernetes manifest дахь image tag шинэчлэх
  6. notify - Deployment notification

ArgoCD (GitOps)

ArgoCD application тохируулах:

kubectl apply -f argocd-application.yaml -n argocd

ArgoCD нь manifests/ directory-г автоматаар sync хийнэ.

Kubernetes Deployment

Manifests

manifests/
├── namespace.yaml           # hell-world namespace
├── postgres-secret.yaml     # Database credentials
├── postgres-pvc.yaml        # PostgreSQL storage
├── postgres-deployment.yaml # PostgreSQL deployment
├── postgres-service.yaml    # PostgreSQL service
├── backend-deployment.yaml  # Go backend deployment
├── backend-service.yaml     # Backend service
├── frontend-deployment.yaml # Next.js frontend deployment
├── frontend-service.yaml    # Frontend service
├── ingress.yaml             # Ingress with TLS
└── kustomization.yaml       # Kustomize config

Manual Deploy

kubectl apply -k manifests/

URLs (Production)