diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 00000000..e5e04445 --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,169 @@ +name: Build and Push Docker Images + +on: + push: + branches: + - main # Pushes to main โ†’ tags as "latest" + - development # Pushes to development โ†’ tags as "dev" + tags: + - 'v*.*.*' # Version tags (v1.0.0, v1.2.3, etc.) โ†’ tags as version number + workflow_dispatch: # Allows manual trigger from GitHub UI + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push: + name: Build and Push Docker Image + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + # Step 1: Download the code + - name: ๐Ÿ“ฅ Checkout code + uses: actions/checkout@v4 + + # Step 2: Set up QEMU for multi-platform builds (ARM, AMD64, etc.) + - name: ๐Ÿ”ง Set up QEMU + uses: docker/setup-qemu-action@v3 + + # Step 3: Set up Docker Buildx (advanced Docker builder) + - name: ๐Ÿ”ง Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + # Step 4: Log in to GitHub Container Registry + - name: ๐Ÿ” Log in to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.CPMP_GHCR_TOKEN }} + + # Step 5: Figure out what tags to use + - name: ๐Ÿท๏ธ Extract metadata (tags, labels) + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + # Tag "latest" for main branch + type=raw,value=latest,enable={{is_default_branch}} + # Tag "dev" for development branch + type=raw,value=dev,enable=${{ github.ref == 'refs/heads/development' }} + # Tag version numbers from git tags (v1.0.0 โ†’ 1.0.0) + type=semver,pattern={{version}} + # Tag major.minor from git tags (v1.2.3 โ†’ 1.2) + type=semver,pattern={{major}}.{{minor}} + # Tag major from git tags (v1.2.3 โ†’ 1) + type=semver,pattern={{major}} + # Tag with git SHA for tracking (first 7 characters) + type=sha,prefix=sha-,format=short + + # Step 6: Build the frontend first + - name: ๐ŸŽจ Build frontend + run: | + cd frontend + npm ci + npm run build + + # Step 7: Build and push Docker image + - name: ๐Ÿณ Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + + # Step 8: Create a summary + - name: ๐Ÿ“‹ Create summary + run: | + echo "## ๐ŸŽ‰ Docker Image Built Successfully!" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### ๐Ÿ“ฆ Image Details" >> $GITHUB_STEP_SUMMARY + echo "- **Registry**: GitHub Container Registry (ghcr.io)" >> $GITHUB_STEP_SUMMARY + echo "- **Repository**: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}" >> $GITHUB_STEP_SUMMARY + echo "- **Tags**: " >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + echo "${{ steps.meta.outputs.tags }}" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### ๐Ÿš€ How to Use" >> $GITHUB_STEP_SUMMARY + echo '```bash' >> $GITHUB_STEP_SUMMARY + echo "docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest" >> $GITHUB_STEP_SUMMARY + echo "docker run -d -p 8080:8080 -v caddy_data:/app/data ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest" >> $GITHUB_STEP_SUMMARY + echo '```' >> $GITHUB_STEP_SUMMARY + + test-image: + name: Test Docker Image + needs: build-and-push + runs-on: ubuntu-latest + + steps: + # Step 1: Figure out which tag to test + - name: ๐Ÿท๏ธ Determine image tag + id: tag + run: | + if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then + echo "tag=latest" >> $GITHUB_OUTPUT + elif [[ "${{ github.ref }}" == "refs/heads/development" ]]; then + echo "tag=dev" >> $GITHUB_OUTPUT + elif [[ "${{ github.ref }}" == refs/tags/v* ]]; then + echo "tag=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT + else + echo "tag=sha-$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_OUTPUT + fi + + # Step 2: Pull the image we just built + - name: ๐Ÿ“ฅ Pull Docker image + run: docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.tag }} + + # Step 3: Start the container + - name: ๐Ÿš€ Run container + run: | + docker run -d \ + --name test-container \ + -p 8080:8080 \ + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.tag }} + + # Step 4: Wait for it to start + - name: โณ Wait for container to be ready + run: sleep 10 + + # Step 5: Check if the health endpoint works + - name: ๐Ÿฅ Test health endpoint + run: | + response=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8080/api/v1/health) + if [ $response -eq 200 ]; then + echo "โœ… Health check passed!" + else + echo "โŒ Health check failed with status $response" + docker logs test-container + exit 1 + fi + + # Step 6: Check the logs for errors + - name: ๐Ÿ“‹ Check container logs + if: always() + run: docker logs test-container + + # Step 7: Clean up + - name: ๐Ÿงน Stop container + if: always() + run: docker stop test-container && docker rm test-container + + # Step 8: Summary + - name: ๐Ÿ“‹ Create test summary + if: always() + run: | + echo "## ๐Ÿงช Docker Image Test Results" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "- **Image**: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.tag.outputs.tag }}" >> $GITHUB_STEP_SUMMARY + echo "- **Health Check**: ${{ job.status == 'success' && 'โœ… Passed' || 'โŒ Failed' }}" >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 00000000..6db95c81 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,353 @@ +name: Deploy Documentation to GitHub Pages + +on: + push: + branches: + - main # Deploy docs when pushing to main + paths: + - 'docs/**' # Only run if docs folder changes + - 'README.md' # Or if README changes + - '.github/workflows/docs.yml' # Or if this workflow changes + workflow_dispatch: # Allow manual trigger + +# Sets permissions to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment +concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + build: + name: Build Documentation + runs-on: ubuntu-latest + + steps: + # Step 1: Get the code + - name: ๐Ÿ“ฅ Checkout code + uses: actions/checkout@v4 + + # Step 2: Set up Node.js (for building any JS-based doc tools) + - name: ๐Ÿ”ง Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + + # Step 3: Create a beautiful docs site structure + - name: ๐Ÿ“ Build documentation site + run: | + # Create output directory + mkdir -p _site + + # Copy all markdown files + cp README.md _site/ + cp -r docs _site/ + + # Create a simple HTML index that looks nice + cat > _site/index.html << 'EOF' + + + + + + Caddy Proxy Manager Plus - Documentation + + + + +
+

๐Ÿš€ Caddy Proxy Manager Plus

+

Make your websites easy to reach - No coding required!

+
+ +
+
+

๐Ÿ‘‹ Welcome!

+

+ This documentation will help you get started with Caddy Proxy Manager Plus. + Whether you're a complete beginner or an experienced developer, we've got you covered! +

+
+ +

๐Ÿ“š Getting Started

+
+
+

๐Ÿ  Getting Started Guide Start Here

+

Your first setup in just 5 minutes! We'll walk you through everything step by step.

+ Read the Guide โ†’ +
+ +
+

๐Ÿ“– README Essential

+

Learn what the app does, how to install it, and see examples of what you can build.

+ Read More โ†’ +
+ +
+

๐Ÿ“ฅ Import Guide

+

Already using Caddy? Learn how to bring your existing configuration into the app.

+ Import Your Configs โ†’ +
+
+ +

๐Ÿ”ง Developer Documentation

+
+
+

๐Ÿ”Œ API Reference Advanced

+

Complete REST API documentation with examples in JavaScript and Python.

+ View API Docs โ†’ +
+ +
+

๐Ÿ’พ Database Schema Advanced

+

Understand how data is stored, relationships, and backup strategies.

+ View Schema โ†’ +
+ +
+

โœจ Contributing Guide

+

Want to help make this better? Learn how to contribute code, docs, or ideas.

+ Start Contributing โ†’ +
+
+ +

๐Ÿ“‹ All Documentation

+
+

๐Ÿ“š Documentation Index

+

Browse all available documentation organized by topic and skill level.

+ View Full Index โ†’ +
+ +

๐Ÿ†˜ Need Help?

+
+

Get Support

+

+ Stuck? Have questions? We're here to help! +

+
+ + ๐Ÿ’ฌ Ask a Question + + + ๐Ÿ› Report a Bug + + + โญ View on GitHub + +
+
+
+ + + + + EOF + + # Convert markdown files to HTML using a simple converter + npm install -g marked + + # Convert each markdown file + for file in _site/docs/*.md; do + if [ -f "$file" ]; then + filename=$(basename "$file" .md) + marked "$file" -o "_site/docs/${filename}.html" --gfm + fi + done + + # Convert README and CONTRIBUTING + marked _site/README.md -o _site/README.html --gfm + if [ -f "CONTRIBUTING.md" ]; then + cp CONTRIBUTING.md _site/ + marked _site/CONTRIBUTING.md -o _site/CONTRIBUTING.html --gfm + fi + + # Add simple styling to all HTML files + for html_file in _site/*.html _site/docs/*.html; do + if [ -f "$html_file" ] && [ "$html_file" != "_site/index.html" ]; then + # Add a header with navigation to each page + temp_file="${html_file}.tmp" + cat > "$temp_file" << 'HEADER' + + + + + + Caddy Proxy Manager Plus - Documentation + + + + + +
+ HEADER + + # Append original content + cat "$html_file" >> "$temp_file" + + # Add footer + cat >> "$temp_file" << 'FOOTER' +
+ + + + FOOTER + + mv "$temp_file" "$html_file" + fi + done + + echo "โœ… Documentation site built successfully!" + + # Step 4: Upload the built site + - name: ๐Ÿ“ค Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + path: '_site' + + deploy: + name: Deploy to GitHub Pages + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + + steps: + # Deploy to GitHub Pages + - name: ๐Ÿš€ Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 + + # Create a summary + - name: ๐Ÿ“‹ Create deployment summary + run: | + echo "## ๐ŸŽ‰ Documentation Deployed!" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "Your documentation is now live at:" >> $GITHUB_STEP_SUMMARY + echo "๐Ÿ”— ${{ steps.deployment.outputs.page_url }}" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "### ๐Ÿ“š What's Included" >> $GITHUB_STEP_SUMMARY + echo "- Getting Started Guide" >> $GITHUB_STEP_SUMMARY + echo "- Complete README" >> $GITHUB_STEP_SUMMARY + echo "- API Documentation" >> $GITHUB_STEP_SUMMARY + echo "- Database Schema" >> $GITHUB_STEP_SUMMARY + echo "- Import Guide" >> $GITHUB_STEP_SUMMARY + echo "- Contributing Guidelines" >> $GITHUB_STEP_SUMMARY diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..cfb20ef5 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,387 @@ +# Contributing to CaddyProxyManager+ + +Thank you for your interest in contributing to CaddyProxyManager+! This document provides guidelines and instructions for contributing to the project. + +## Table of Contents + +- [Code of Conduct](#code-of-conduct) +- [Getting Started](#getting-started) +- [Development Workflow](#development-workflow) +- [Coding Standards](#coding-standards) +- [Testing Guidelines](#testing-guidelines) +- [Pull Request Process](#pull-request-process) +- [Issue Guidelines](#issue-guidelines) +- [Documentation](#documentation) + +## Code of Conduct + +This project follows a Code of Conduct that all contributors are expected to adhere to: + +- Be respectful and inclusive +- Welcome newcomers and help them get started +- Focus on what's best for the community +- Show empathy towards other community members + +## Getting Started + +### Prerequisites + +- **Go 1.22+** for backend development +- **Node.js 20+** and npm for frontend development +- Git for version control +- A GitHub account + +### Fork and Clone + +1. Fork the repository on GitHub +2. Clone your fork locally: +```bash +git clone https://github.com/YOUR_USERNAME/CaddyProxyManagerPlus.git +cd CaddyProxyManagerPlus +``` + +3. Add the upstream remote: +```bash +git remote add upstream https://github.com/Wikid82/CaddyProxyManagerPlus.git +``` + +### Set Up Development Environment + +**Backend:** +```bash +cd backend +go mod download +go run ./cmd/seed/main.go # Seed test data +go run ./cmd/api/main.go # Start backend +``` + +**Frontend:** +```bash +cd frontend +npm install +npm run dev # Start frontend dev server +``` + +## Development Workflow + +### Branching Strategy + +- **main** - Production-ready code +- **development** - Main development branch (default) +- **feature/** - Feature branches (e.g., `feature/add-ssl-support`) +- **bugfix/** - Bug fix branches (e.g., `bugfix/fix-import-crash`) +- **hotfix/** - Urgent production fixes + +### Creating a Feature Branch + +Always branch from `development`: + +```bash +git checkout development +git pull upstream development +git checkout -b feature/your-feature-name +``` + +### Commit Message Guidelines + +Follow the [Conventional Commits](https://www.conventionalcommits.org/) specification: + +``` +(): + + + +