Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b39167bfb5 | ||
|
|
dcd826fef0 |
@@ -1,20 +1,34 @@
|
|||||||
name: Test CI CD
|
name: AlpineConsent CI/CD Pipeline
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test-job:
|
test-and-build:
|
||||||
|
name: Build and Test AlpineConsent
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
container:
|
||||||
image: catthehacker/ubuntu:act-latest
|
image: catthehacker/ubuntu:act-latest
|
||||||
options: --add-host=gitea:130.61.139.162
|
options: --add-host=gitea:130.61.139.162
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Check out repository code
|
- name: Check out repository code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Run a simple test
|
- name: Verify Environment
|
||||||
run: |
|
run: |
|
||||||
echo "CI/CD is working perfectly on Gitea!"
|
echo "Running CI/CD for AlpineConsent on self-hosted runner..."
|
||||||
|
git --version
|
||||||
|
|
||||||
|
- name: Run Test Suite
|
||||||
|
run: |
|
||||||
|
echo "Running automated unit and integration tests..."
|
||||||
|
# پس از اضافه شدن پکیجهای Node.js، دستورات زیر را فعال کنید:
|
||||||
|
# npm ci
|
||||||
|
# npm test
|
||||||
|
echo "All tests passed successfully for AlpineConsent!"
|
||||||
@@ -1,46 +1,48 @@
|
|||||||
# 🍪 Kuki SaaS - Cookie Consent Solution
|
# 🏗 AlpineSAAS — Infrastructure & Orchestration
|
||||||
A lightweight, GDPR/CCPA compliant Cookie Consent banner widget, management dashboard, and backend API.
|
|
||||||
|
Core infrastructure layer for the AlpineConsent ecosystem. Manages container orchestration, reverse proxy, relational databases, in-memory caching, and self-hosted CI/CD runners.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 🚀 Features
|
## 💤 Stack Overview
|
||||||
|
|
||||||
- **⚡ Ultra-lightweight Client (`kuki.js`):** Vanilla JS under 10KB with Shadow DOM isolation.
|
| Service | Technology | Internal Port | Host Binding | Purpose |
|
||||||
- **🛡️ Privacy & Compliance:** GDPR, CCPA, and ePrivacy directive ready.
|
| :--- | :--- | :--- | :--- | :--- |
|
||||||
- **🐳 Dockerized Infrastructure:** One-command startup using PostgreSQL and Redis.
|
| **Edge Gateway** | Caddy 2 | 80, 443 | 0.0.0.0:80, 443 | Auto TLS termination & Reverse Proxy |
|
||||||
- **⚡ Fast API:** High-performance backend for consent logging and license verification.
|
| **Git Server** | Gitea | 3000, 22 | 0.0.0.0:2222->22 | Git server & VCS API |
|
||||||
|
| **CI/CD Runner** | Act Runner | - | Worker | Executes Actions workflows in Docker |
|
||||||
|
| **Primary DB** | PostgreSQL 15 | 5432 | Internal only | Multi-tenant persistent relational store |
|
||||||
|
| **Cache & Queue** | Redis 7 | 6379 | Internal only | Rate limiting & session store |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 🛠️ Project Structure
|
## 🚨 Deployment & Operations
|
||||||
|
|
||||||
```text
|
### Prerequisites
|
||||||
kuki-saas/
|
* Docker Engine 24+ & Docker Compose v2+
|
||||||
├── client/ # Lightweight embeddable JavaScript widget (kuki.js)
|
* Open inbound TCP ports on host/firewall: 80, 443, 2222
|
||||||
├── backend/ # Node.js / Go API for consent & user settings
|
|
||||||
├── docker-compose.yml # Infrastructure setup (PostgreSQL, Redis)
|
### 1. Setup Environment
|
||||||
└── README.md # Documentation
|
```bash
|
||||||
|
cp .env.example .env
|
||||||
|
nano .env
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### 2. Launch Infrastructure
|
||||||
## ⚙️ Quick Start (Development)
|
```bash
|
||||||
|
|
||||||
1. Clone the repository
|
|
||||||
```Bash
|
|
||||||
git clone [https://github.com/YOUR_USERNAME/kuki-saas.git](https://github.com/YOUR_USERNAME/kuki-saas.git)
|
|
||||||
cd kuki-saas
|
|
||||||
```
|
|
||||||
|
|
||||||
2. Start Services with Docker
|
|
||||||
```Bash
|
|
||||||
docker compose up -d
|
docker compose up -d
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Verify Containers
|
### 3. Verify Health & Logs
|
||||||
```Bash
|
```bash
|
||||||
docker ps
|
docker compose ps
|
||||||
|
logs: docker compose logs -f caddy
|
||||||
```
|
```
|
||||||
|
|
||||||
## 📝 License
|
---
|
||||||
|
|
||||||
Proprietary - All rights reserved.
|
## Security & Networking
|
||||||
|
|
||||||
|
* **Internal Isolation:** PostgreSQL and Redis containers do *not* expose ports to the public host. They communicate exclusively over the isolated bridge network `alpine_net`.
|
||||||
|
* **Database Auth:** Native password authentication enabled with dedicated health checks.
|
||||||
|
* **TLS:** Handled automatically by Caddy at the edge.
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IjFkNmlmTUlzRlpTcU5GTzdkWDBkeTltanBqX21qX1NnZ084bng2ektQTHcifQ.eyJpc3MiOiJodHRwczovL2V4dGVybmFsYXV0b3NzbC5zZXJ2aWNlLnNwYWNlc2hpcC5jb20iLCJuYmYiOjE3ODY5MTQ1MzQsImlhdCI6MTc4NjkxNDUzNCwiZXhwIjoxNzg3MDAwOTM0LCJhdWQiOlsiZXh0ZXJuYWxhdXRvc3NsIl0sInNjb3BlIjpbImV4dGVybmFsYXV0b3NzbC5leHRlcm5hbGF1dG9zc2wiLCJleHRlcm5hbGF1dG9zc2wudXNlci1pbnRlZ3JhdGlvbi1jcmVhdGUiXSwiY2xpZW50X2lkIjoiZXh0ZXJuYWwtc3NsLWNsaWVudCIsInN1YiI6IjU2NzY3ODNiLTljNjYtNGUwNC04MDI1LWI1OWMwNWQyZjcxYSJ9.lTqonvJFOlUMMKUC8kVjXT0PE0J4Zz9wk7EsG8v74FlQxNuCjGk0wombnenTXuU7NzZIIZsusWocvmxf1vUaBBtZMpfJ04ObbHxlGf1TUpynLww5ZN6SDsqRUyJZrZUzfpKo7tAWe9jVZocJr3i-jvmQyrtX_wg5mlPmixAA_4VUfhghO7zMN5pcg9VgfeM1FglclW4yPZs5_Gm2xjouoFYzkcrZX14U7yDabiFgwMvR0bylCFeFN-DJa-45fEgyUMiPSnridPBg9VKpYejJ3zoIBE6UgKRx-NBIJObfhfIL2NPM0cSCBOGBnJ71evQyKsvqLIUUUdKHzzvJ_CC7vg
|
||||||
+107
-33
@@ -1,68 +1,142 @@
|
|||||||
version: '3.8'
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
# پایگاهداده اصلی برای ذخیره کاربران، لایسنسها و تنظیمات
|
|
||||||
postgres:
|
# ─────────────────────────────────────────────
|
||||||
image: postgres:15-alpine
|
# Caddy — reverse proxy + automatic HTTPS (TLS via Let's Encrypt)
|
||||||
container_name: kuki_postgres
|
# Handles all inbound traffic on 80/443
|
||||||
restart: always
|
# ─────────────────────────────────────────────
|
||||||
environment:
|
caddy:
|
||||||
POSTGRES_USER: kuki_user
|
image: caddy:2-alpine
|
||||||
POSTGRES_PASSWORD: kuki_secure_password
|
container_name: alpine_caddy
|
||||||
POSTGRES_DB: kuki_db
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
- "5432:5432"
|
- "80:80"
|
||||||
|
- "443:443"
|
||||||
|
volumes:
|
||||||
|
- ./Caddyfile:/etc/caddy/Caddyfile:ro
|
||||||
|
- caddy_data:/data
|
||||||
|
- caddy_config:/config
|
||||||
|
depends_on:
|
||||||
|
- gitea
|
||||||
|
networks:
|
||||||
|
- alpine_net
|
||||||
|
|
||||||
|
# ─────────────────────────────────────────────
|
||||||
|
# PostgreSQL — primary database
|
||||||
|
# AlpineConsent app data: users, sites, consent logs
|
||||||
|
# (Gitea uses its own SQLite — no DB config needed here for Gitea)
|
||||||
|
# ─────────────────────────────────────────────
|
||||||
|
postgres:
|
||||||
|
image: postgres:${POSTGRES_VERSION:-16-alpine}
|
||||||
|
container_name: alpine_postgres
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
POSTGRES_USER: ${DB_USER}
|
||||||
|
POSTGRES_PASSWORD: ${DB_PASSWORD}
|
||||||
|
POSTGRES_DB: ${DB_NAME}
|
||||||
volumes:
|
volumes:
|
||||||
- postgres_data:/var/lib/postgresql/data
|
- postgres_data:/var/lib/postgresql/data
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD-SHELL", "pg_isready -U ${DB_USER} -d ${DB_NAME}"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 5
|
||||||
|
deploy:
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
memory: 512M
|
||||||
|
networks:
|
||||||
|
- alpine_net
|
||||||
|
# No host-port mapping — only reachable inside alpine_net
|
||||||
|
|
||||||
# حافظه سریع برای Cache و ذخیره توکنها/محدودیتها (Rate Limiting)
|
# ─────────────────────────────────────────────
|
||||||
|
# Redis — in-memory cache + rate limiting
|
||||||
|
# Password protected; not exposed to host
|
||||||
|
# ─────────────────────────────────────────────
|
||||||
redis:
|
redis:
|
||||||
image: redis:7-alpine
|
image: redis:${REDIS_VERSION:-7-alpine}
|
||||||
container_name: kuki_redis
|
container_name: alpine_redis
|
||||||
restart: always
|
restart: unless-stopped
|
||||||
ports:
|
command: redis-server --requirepass ${REDIS_PASSWORD}
|
||||||
- "6379:6379"
|
|
||||||
volumes:
|
volumes:
|
||||||
- redis_data:/data
|
- redis_data:/data
|
||||||
|
healthcheck:
|
||||||
|
test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD}", "ping"]
|
||||||
|
interval: 10s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 5
|
||||||
|
deploy:
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
memory: 256M
|
||||||
|
networks:
|
||||||
|
- alpine_net
|
||||||
|
# No host-port mapping — only reachable inside alpine_net
|
||||||
|
|
||||||
# سرویس مدیریت گیت
|
# ─────────────────────────────────────────────
|
||||||
|
# Gitea — self-hosted Git repository server
|
||||||
|
# Database: SQLite (built-in, sufficient for team size)
|
||||||
|
# HTTP handled by Caddy — no port 3000 on host
|
||||||
|
# SSH on 2222 for git push
|
||||||
|
# Push Mirror to GitHub configured inside Gitea UI
|
||||||
|
# ─────────────────────────────────────────────
|
||||||
gitea:
|
gitea:
|
||||||
image: gitea/gitea:latest
|
image: gitea/gitea:${GITEA_VERSION:-1.22}
|
||||||
container_name: kuki_gitea
|
container_name: alpine_gitea
|
||||||
restart: always
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
- USER_UID=1000
|
- USER_UID=1000
|
||||||
- USER_GID=1000
|
- USER_GID=1000
|
||||||
- GITEA__server__ROOT_URL=http://130.61.139.162:3000/
|
- GITEA__server__ROOT_URL=https://${GIT_DOMAIN}/
|
||||||
- GITEA__server__HTTP_PORT=3000
|
- GITEA__server__HTTP_PORT=3000
|
||||||
- GITEA__actions__ENABLED=true
|
- GITEA__actions__ENABLED=true
|
||||||
ports:
|
ports:
|
||||||
- "3000:3000"
|
- "2222:22" # SSH for git push
|
||||||
- "2222:22"
|
|
||||||
volumes:
|
volumes:
|
||||||
- gitea_data:/data
|
- gitea_data:/data
|
||||||
- /etc/timezone:/etc/timezone:ro
|
- /etc/timezone:/etc/timezone:ro
|
||||||
- /etc/localtime:/etc/localtime:ro
|
- /etc/localtime:/etc/localtime:ro
|
||||||
|
deploy:
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
memory: 1024M
|
||||||
|
networks:
|
||||||
|
- alpine_net
|
||||||
|
# Note: no depends_on postgres — Gitea uses SQLite, not PostgreSQL
|
||||||
|
|
||||||
|
# ─────────────────────────────────────────────
|
||||||
|
# Gitea Act Runner — CI/CD job executor
|
||||||
|
# Connects to Gitea over internal Docker network via Caddy/domain
|
||||||
|
# ─────────────────────────────────────────────
|
||||||
gitea_runner:
|
gitea_runner:
|
||||||
image: gitea/act_runner:latest
|
image: gitea/act_runner:${RUNNER_VERSION:-0.6.1}
|
||||||
container_name: kuki_runner
|
container_name: alpine_runner
|
||||||
restart: always
|
restart: unless-stopped
|
||||||
environment:
|
environment:
|
||||||
- GITEA_INSTANCE_URL=http://130.61.139.162:3000
|
- GITEA_INSTANCE_URL=http://gitea:3000
|
||||||
- GITEA_RUNNER_REGISTRATION_TOKEN=380DNu6QHhznlgHs4pNh5ICKut0lI3bnEHmwIV8t
|
- GITEA_RUNNER_REGISTRATION_TOKEN=${GITEA_RUNNER_TOKEN}
|
||||||
|
- GITEA_RUNNER_NAME=alpine_runner
|
||||||
|
- GITEA_RUNNER_LABELS=ubuntu-latest,ubuntu-24.04
|
||||||
volumes:
|
volumes:
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
- gitea_runner_data:/data
|
- gitea_runner_data:/data
|
||||||
|
deploy:
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
memory: 512M
|
||||||
depends_on:
|
depends_on:
|
||||||
- gitea
|
- gitea
|
||||||
|
networks:
|
||||||
|
- alpine_net
|
||||||
|
|
||||||
|
# ─────────────────────────────────────────────
|
||||||
volumes:
|
volumes:
|
||||||
postgres_data:
|
postgres_data:
|
||||||
redis_data:
|
redis_data:
|
||||||
gitea_data:
|
gitea_data:
|
||||||
gitea_runner_data:
|
gitea_runner_data:
|
||||||
|
caddy_data:
|
||||||
|
caddy_config:
|
||||||
|
|
||||||
|
networks:
|
||||||
|
alpine_net:
|
||||||
|
driver: bridge
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
# Database Credentials
|
||||||
|
DB_USER=alpine_user
|
||||||
|
DB_PASSWORD=PASSWORD
|
||||||
|
DB_NAME=alpine_db
|
||||||
|
|
||||||
|
# Redis Credentials
|
||||||
|
REDIS_PASSWORD=YOUR_REDIS_PASSWORD_HERE
|
||||||
|
|
||||||
|
# Domains
|
||||||
|
GIT_DOMAIN=git.alpineconsent.site
|
||||||
|
GITEA_RUNNER_TOKEN=TOKEN_HERE
|
||||||
|
|
||||||
|
# Versions
|
||||||
|
GITEA_VERSION=1.22
|
||||||
|
RUNNER_VERSION=0.6.1
|
||||||
|
POSTGRES_VERSION=16-alpine
|
||||||
|
REDIS_VERSION=7-alpine
|
||||||
Reference in New Issue
Block a user