f3114396213a3c35bdffcb89396e20cb0666e076
- 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>
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:
- Frontend: http://localhost:3000
- Backend API: http://localhost:8080
- PostgreSQL: localhost:5432
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 файл нь дараах алхмуудыг гүйцэтгэнэ:
- build-backend - Go backend Docker image build
- build-frontend - Next.js frontend Docker image build
- push-backend - Harbor registry рүү backend push
- push-frontend - Harbor registry рүү frontend push
- update-manifests - Kubernetes manifest дахь image tag шинэчлэх
- 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)
- Frontend: https://hell-world.gecore.mn
- Backend API: https://hell-world-api.gecore.mn
Description
Languages
TypeScript
52.4%
Go
35.5%
Dockerfile
10.2%
JavaScript
1.9%