Skip to content

Conversation

@coderloganli
Copy link

No description provided.

Zequn and others added 12 commits December 29, 2025 23:30
- Refactor from single-container to 8 independent services
- Enable horizontal scaling for Logic, Connect, Task, and API services
- Add automatic container IP registration to etcd for RPC communication
- Implement health checks and dependency management
- Create separate dev/prod Docker Compose configurations
- Add Makefile commands for easy deployment
- Update documentation with quick start guide

Improvements over original:
- 44MB runtime images (vs 1.93GB single container)
- Independent service scaling
- Process isolation and resource limits
- Health-based dependency management
- Production-ready deployment

Original project: https://github.com/LockGit/gochat
- Removed docker/dev/ and docker/prod/ (Supervisord configs)
- Removed run.sh and reload.sh (legacy deployment scripts)
- Updated README.md to remove legacy deployment section

The application now uses Docker Compose multi-container deployment exclusively.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…ection

Replaced shell script preprocessing with clean Go implementation:

- Added GetContainerIP() and GetServiceAddress() to tools/network.go
- Updated logic/publish.go to auto-detect container IP for etcd registration
- Updated connect/rpc.go to auto-detect container IP for etcd registration
- Updated Dockerfile to remove entrypoint.sh and use direct CMD
- Updated docker-compose.yml to use direct command without environment preprocessing
- Removed docker/entrypoint.sh

This approach is cleaner and more maintainable:
- No shell preprocessing required
- Services auto-detect their container IP at runtime
- Proper multi-container deployment with correct service discovery
- All services register with actual container IPs (e.g., tcp@172.28.0.4:6900)

Tested and verified:
- All services start successfully
- Services register correctly in etcd with container IPs
- Multi-container deployment fully functional

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Implemented comprehensive CI/CD pipeline for automated testing, building, and deployment:

**CI/CD Workflow (.github/workflows/ci-cd.yml):**
- Test job: go fmt, go vet, tests with Redis service container
- Build job: Docker image with layer caching
- Push job: Push to Docker Hub with multiple tags (latest, branch, git-sha)
- Deploy jobs: Optional deployment to dev/staging/prod environments (commented out)

**Testing Infrastructure:**
- Makefile: Added test, test-coverage, test-unit, test-integration targets
- Makefile: Added fmt, fmt-check, vet, lint for code quality
- Makefile: Added build-binary, build-image for building
- docker-compose.test.yml: Test environment with Redis and etcd
- docker/Dockerfile.test: Test runner Dockerfile

**Deployment:**
- scripts/deploy.sh: Manual deployment script for all environments
- config/staging/: Staging configuration (copied from dev)
- docker-compose.staging.yml: Staging environment overrides

**Documentation:**
- README.md: Added CI/CD Pipeline section with setup instructions
- README.md: Added GitHub Secrets configuration guide
- README.md: Added branch strategy and manual deployment commands
- CHANGELOG.md: Documented all CI/CD pipeline changes

**Removed:**
- .travis.yml: Replaced with GitHub Actions

**Branch Strategy:**
- dev → Development environment (auto-deploy)
- staging → Staging environment (auto-deploy)
- master → Production environment (manual approval)

**Image Tags:**
- latest - Latest from master
- <branch> - Latest from branch
- <git-sha> - Specific commit for rollback

GitHub Secrets required: DOCKERHUB_USERNAME, DOCKERHUB_TOKEN
Optional: Server SSH credentials for deployment

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Changed os.Signal channels from unbuffered to buffered (capacity 1).
This fixes the error: 'misuse of unbuffered os.Signal channel as argument to signal.Notify'

Fixed in:
- main.go: Line 44
- api/chat.go: Line 55
Fixed linting error: 'logrus.Error call has possible formatting directive %s'
Changed to logrus.Errorf() to properly support format string in db/db.go:40
Fixed all logrus logging format issues:
- connect/server.go:71 - Changed logrus.Warn to logrus.Warnf
- connect/rpc.go:115 - Changed logrus.Info to logrus.Infof
- api/chat.go:63 - Added missing format directive %v to logrus.Errorf

Ran go fmt ./... to format all code.
Verified with go vet ./... - all checks pass.

Tested locally before pushing.
Moved environment-specific docker-compose files:
- docker-compose.dev.yml → deployments/
- docker-compose.prod.yml → deployments/
- docker-compose.staging.yml → deployments/
- docker-compose.test.yml → deployments/

Updated references in:
- Makefile (all compose-* targets)
- scripts/deploy.sh
- README.md (Quick Start section)

This improves project organization by separating deployment configs from root directory.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
… support

Problem:
- Integration tests were failing in CI (TCP server not running)
- Tests had infinite loops and poor error handling
- No separation between fast unit tests and slow integration tests

Solution:
Implemented proper test separation with two-stage CI pipeline:

**Unit Tests (Stage 1 - Fast)**:
- Run with `go test -short` flag
- Integration tests check `testing.Short()` and skip
- No service dependencies required
- Runs in ~2 seconds

**Integration Tests (Stage 2 - Full Stack)**:
- Start all services via docker-compose
- Run `go test` from host against exposed container ports
- Tests connect to localhost:7001 (TCP), localhost:6379 (Redis)
- Integration tests execute fully (not skipped!)

Changes:
- pkg/stickpackage/stickpackage_test.go:
  * Added `testing.Short()` check to skip in unit test stage
  * Removed infinite loops, added 10s timeout
  * Proper error handling with t.Fatalf/t.Logf
  * Connection timeout with graceful fallback

- task/queue_test.go:
  * Added `testing.Short()` check
  * Better error handling for empty queue

- deployments/docker-compose.test.yml:
  * Simplified to expose ports (2379, 6379, 7001, 7002)
  * Tests run from host, not in container
  * Removed test-runner service

- .github/workflows/ci-cd.yml:
  * Split "test" job into "unit-test" and "integration-test"
  * unit-test: runs `go test -short` (fast)
  * integration-test: starts services, runs `go test` (full)
  * build: depends on BOTH test jobs passing

- Makefile:
  * test-unit: `go test -short`
  * test-integration: starts services, runs tests, stops services

- Removed docker/Dockerfile.test (no longer needed)

CI Pipeline Flow:
```
Unit Tests → Integration Tests → Build → Push → Deploy
   (2s)          (~2min)         (3min)
```

This ensures:
✓ Fast feedback from unit tests
✓ Integration tests actually RUN (not skipped) in separate stage
✓ Multi-container deployment is properly tested
✓ No test hangs or infinite loops

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Problem:
GitHub Actions runners use Docker Compose V2 which uses the command
`docker compose` (without hyphen) instead of legacy `docker-compose`.
Integration tests were failing with: "docker-compose: command not found"

Changes:
- .github/workflows/ci-cd.yml: Updated all docker-compose → docker compose
- Makefile: Updated all compose commands (dev, prod, scale, logs, ps, clean, test-integration)
- scripts/deploy.sh: Updated deployment commands
- README.md: Updated example commands in documentation
- deployments/docker-compose.test.yml: Updated usage comment

Docker Compose V2 is the modern version bundled with Docker Desktop
and available by default in GitHub Actions runners.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Updated go.mod from Go 1.18 to Go 1.23.0
- Updated Docker build image to golang:1.23
- Updated GitHub Actions workflow to use Go 1.23
- Fixed deprecated io/ioutil usage in site/site.go (now uses os.ReadFile)
- Updated golang.org/x dependencies to Go 1.23-compatible versions
- Synced vendor directory with updated dependencies
- All tests passing with Go 1.23

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant