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:
Erdenebat Tsenddorj
2026-01-21 21:06:08 +08:00
parent 2c4e7d2c38
commit f311439621
26 changed files with 955 additions and 1 deletions

126
README.md
View File

@@ -1,2 +1,126 @@
# hell-world
# 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
```bash
docker-compose up --build
```
Services:
- Frontend: http://localhost:3000
- Backend API: http://localhost:8080
- PostgreSQL: localhost:5432
## Manual Setup
### Backend (Go)
```bash
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)
```bash
cd frontend
npm install
NEXT_PUBLIC_API_URL=http://localhost:8080 npm run dev
```
### PostgreSQL
```bash
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 тохируулах:
```bash
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
```bash
kubectl apply -k manifests/
```
### URLs (Production)
- Frontend: https://hell-world.gecore.mn
- Backend API: https://hell-world-api.gecore.mn