## Summary This PR sets up the complete CI/CD infrastructure for the Chat Switchboard project, implementing automated testing, linting, building, and Docker containerization. ## Changes ### CI/CD Workflows 1. **`.gitea/workflows/backend.yml`** - Backend CI pipeline - Automated Go module initialization - Test execution with coverage reporting - Code linting with golangci-lint - Binary compilation with version tags - Artifact upload for debugging 2. **`.gitea/workflows/frontend.yml`** - Frontend CI pipeline - JavaScript linting with ESLint - CSS validation with Prettier - Standalone HTML build via build.sh - HTML structure validation - Build artifact management 3. **`.gitea/workflows/docker.yml`** - Docker CI pipeline - Backend container building and testing - Frontend container building - Automatic image tagging on tags/branches - Registry push on main branch - Multi-arch manifest creation ### Docker Configuration - `server/Dockerfile` - Multi-stage Go backend container with health checks - `Dockerfile.frontend` - Nginx frontend container with gzip compression - `nginx.conf` - Optimized nginx config with security headers ### Dependencies - `server/go.mod` - Initialized Go module with Gin and godotenv ### Documentation - `docs/CICD_SETUP.md` - Comprehensive CI/CD documentation ## Features - ✅ Auto-trigger on push/PR to main/develop - ✅ Test coverage reporting - ✅ Code quality checks (golangci-lint, ESLint) - ✅ Build artifact management (7-day retention) - ✅ Semantic versioning support (v* tags) - ✅ Multi-stage Docker builds - ✅ Container health checks - ✅ Security headers in nginx - ✅ Gzip compression - ✅ Non-root container execution ## Testing The workflows will automatically run on this PR. Once merged, all future PRs and pushes to main/develop will trigger the appropriate CI checks. ## Acceptance Criteria - ✅ All PRs run CI checks - ✅ Docker images auto-build on tags - ✅ Standalone build generates on each commit ## Next Steps (Manual) 1. Merge this PR to `main` 2. Create `develop` branch: `git checkout main && git checkout -b develop && git push origin develop` 3. Configure branch protection in Gitea (Settings → Branches → Add protection rule for main/develop) 4. Test with a sample PR to verify CI runs ## Breaking Changes None. This is purely infrastructure setup with no impact on existing functionality. Reviewed-on: xcaliber/chat-switchboard#22
50 lines
1.0 KiB
Docker
50 lines
1.0 KiB
Docker
# ==========================================
|
|
# Chat Switchboard Unified Dockerfile
|
|
# Option B: Multi-stage build
|
|
# ==========================================
|
|
|
|
# Stage 1: Backend build
|
|
FROM golang:1.22-bookworm AS backend
|
|
|
|
WORKDIR /app
|
|
|
|
COPY server/go.mod ./
|
|
COPY server/go.sum ./
|
|
RUN go mod download
|
|
|
|
COPY server/ .
|
|
RUN CGO_ENABLED=1 go build -o /backend chat-switchboard-api
|
|
|
|
# Stage 2: Frontend build
|
|
FROM alpine:3.19 AS frontend
|
|
|
|
WORKDIR /app
|
|
|
|
RUN apk add --no-cache bash coreutils
|
|
|
|
COPY build.sh ./
|
|
COPY src ./src
|
|
|
|
RUN chmod +x build.sh && ./build.sh
|
|
|
|
# Stage 3: Production
|
|
FROM nginx:alpine AS production
|
|
|
|
# Copy backend binary
|
|
COPY --from=backend /backend /usr/local/bin/
|
|
|
|
# Copy built frontend files
|
|
COPY --from=frontend /app/standalone /usr/share/nginx/html
|
|
|
|
# Copy custom nginx config for reverse proxy
|
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
|
|
|
# Create startup script
|
|
RUN echo '#!/bin/sh\n\
|
|
mkdir -p /app/data\n\
|
|
/usr/local/bin/backend serve &\n\
|
|
nginx -g "daemon off;"\n' > /start.sh && chmod +x /start.sh
|
|
|
|
EXPOSE 80
|
|
|
|
CMD ["/start.sh"] |