Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 115 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: CI Pipeline

# =============================================================================
# OpenTraum — CI/CD Template
# =============================================================================
# Skeleton workflow for building, testing, and publishing Docker images.
# Each microservice repository should copy and customize this template.
# =============================================================================

on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]

env:
JAVA_VERSION: "21"
DOCKER_REGISTRY: ghcr.io
IMAGE_PREFIX: opentraum

jobs:
# ---------------------------------------------------------------------------
# Build & Test
# ---------------------------------------------------------------------------
build:
name: Build & Test
runs-on: ubuntu-latest

steps:
- name: Checkout source code
uses: actions/checkout@v4

- name: Set up JDK ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: temurin
cache: gradle

- name: Grant execute permission for Gradlew
run: chmod +x gradlew

- name: Build with Gradle
run: ./gradlew build -x test

- name: Run tests
run: ./gradlew test

- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: build/reports/tests/
retention-days: 7

# ---------------------------------------------------------------------------
# Docker Build & Push (only on main/develop push)
# ---------------------------------------------------------------------------
docker:
name: Docker Build & Push
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'push'

permissions:
contents: read
packages: write

steps:
- name: Checkout source code
uses: actions/checkout@v4

- name: Set up JDK ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: temurin
cache: gradle

- name: Grant execute permission for Gradlew
run: chmod +x gradlew

- name: Build JAR
run: ./gradlew bootJar

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.DOCKER_REGISTRY }}/${{ github.repository }}
tags: |
type=ref,event=branch
type=sha,prefix=
type=raw,value=latest,enable={{is_default_branch}}

- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
65 changes: 65 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# =========================
# OS Generated Files
# =========================
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

# =========================
# IDE / Editor
# =========================
.idea/
.vscode/
*.iml
*.swp
*.swo
*~

# =========================
# Environment & Secrets
# =========================
.env
.env.*
!.env.example
*.pem
*.key
*.crt
*.p12
*.jks

# =========================
# Docker
# =========================
docker-compose.override.yml

# =========================
# Kubernetes Secrets
# =========================
k8s/*-secret.yml
k8s/**/secret.yml
k8s/secrets/

# =========================
# Terraform (future)
# =========================
.terraform/
*.tfstate
*.tfstate.*
*.tfvars
!*.tfvars.example

# =========================
# Logs
# =========================
*.log
logs/

# =========================
# Misc
# =========================
tmp/
temp/
134 changes: 134 additions & 0 deletions docker-compose.infra.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
version: "3.9"

# =============================================================================
# OpenTraum — Infrastructure Only
# =============================================================================
# Usage: docker compose -f docker-compose.infra.yml up -d
# Run only infrastructure services (PostgreSQL, Redis, Kafka)
# Use this when running microservices locally via IDE (IntelliJ, VS Code, etc.)
# =============================================================================

services:
# ---------------------------------------------------------------------------
# PostgreSQL 16
# ---------------------------------------------------------------------------
postgres:
image: postgres:16-alpine
container_name: opentraum-postgres
restart: unless-stopped
ports:
- "5432:5432"
environment:
POSTGRES_USER: opentraum
POSTGRES_PASSWORD: opentraum
POSTGRES_DB: opentraum
volumes:
- postgres-data:/var/lib/postgresql/data
- ./scripts/init-db.sh:/docker-entrypoint-initdb.d/init-db.sh
healthcheck:
test: ["CMD-SHELL", "pg_isready -U opentraum -d opentraum"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
networks:
- opentraum-net

# ---------------------------------------------------------------------------
# Redis 7
# ---------------------------------------------------------------------------
redis:
image: redis:7-alpine
container_name: opentraum-redis
restart: unless-stopped
ports:
- "6379:6379"
command: redis-server --appendonly yes --maxmemory 256mb --maxmemory-policy allkeys-lru
volumes:
- redis-data:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
start_period: 10s
networks:
- opentraum-net

# ---------------------------------------------------------------------------
# Zookeeper (Kafka dependency)
# ---------------------------------------------------------------------------
zookeeper:
image: confluentinc/cp-zookeeper:7.6.0
container_name: opentraum-zookeeper
restart: unless-stopped
ports:
- "2181:2181"
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
volumes:
- zookeeper-data:/var/lib/zookeeper/data
- zookeeper-logs:/var/lib/zookeeper/log
healthcheck:
test: ["CMD-SHELL", "echo ruok | nc localhost 2181 | grep imok"]
interval: 10s
timeout: 5s
retries: 5
start_period: 30s
networks:
- opentraum-net

# ---------------------------------------------------------------------------
# Kafka
# ---------------------------------------------------------------------------
kafka:
image: confluentinc/cp-kafka:7.6.0
container_name: opentraum-kafka
restart: unless-stopped
ports:
- "9092:9092"
- "29092:29092"
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:29092,PLAINTEXT_HOST://localhost:9092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
KAFKA_AUTO_CREATE_TOPICS_ENABLE: "true"
volumes:
- kafka-data:/var/lib/kafka/data
depends_on:
zookeeper:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "kafka-broker-api-versions --bootstrap-server localhost:9092"]
interval: 15s
timeout: 10s
retries: 5
start_period: 60s
networks:
- opentraum-net

# =============================================================================
# Networks & Volumes
# =============================================================================
networks:
opentraum-net:
driver: bridge
name: opentraum-net

volumes:
postgres-data:
name: opentraum-postgres-data
redis-data:
name: opentraum-redis-data
zookeeper-data:
name: opentraum-zookeeper-data
zookeeper-logs:
name: opentraum-zookeeper-logs
kafka-data:
name: opentraum-kafka-data
Loading
Loading