Initial commit: COSMOS - turn your old PC to workstation
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
# Build Stage
|
||||
FROM golang:1.22-alpine AS builder
|
||||
|
||||
WORKDIR /app
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
|
||||
COPY . .
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /cosmos .
|
||||
|
||||
# Runtime Stage
|
||||
FROM alpine:3.19
|
||||
|
||||
RUN apk add --no-cache ca-certificates curl bash msmtp
|
||||
# Install MinIO Client (mc)
|
||||
RUN curl -sSL https://dl.min.io/client/mc/release/linux-amd64/mc -o /usr/local/bin/mc && \
|
||||
chmod +x /usr/local/bin/mc
|
||||
|
||||
WORKDIR /app
|
||||
COPY --from=builder /cosmos /app/cosmos
|
||||
COPY templates /app/templates
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
ENTRYPOINT ["/app/cosmos"]
|
||||
@@ -0,0 +1,19 @@
|
||||
[Unit]
|
||||
Description=Cosmos Workstation Core Service
|
||||
After=network.target scylla-server.service minio.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=cosmos
|
||||
WorkingDirectory=/opt/cosmos
|
||||
ExecStart=/opt/cosmos/portals
|
||||
Restart=always
|
||||
RestartSec=5s
|
||||
EnvironmentFile=-/opt/cosmos/.env
|
||||
|
||||
# Security Hardening
|
||||
NoNewPrivileges=true
|
||||
PrivateTmp=true
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
@@ -0,0 +1,75 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
# ─── ScyllaDB Persistence Layer ─────────────────────────────────────────────
|
||||
scylla:
|
||||
image: scylladb/scylla:5.4
|
||||
container_name: cosmos-scylla
|
||||
restart: unless-stopped
|
||||
command: --smp 1 --memory 1G --overprovisioned 1 --api-address 0.0.0.0
|
||||
volumes:
|
||||
- scylla-data:/var/lib/scylla
|
||||
ports:
|
||||
- "9042:9042"
|
||||
|
||||
# ─── MinIO S3 Object Storage ────────────────────────────────────────────────
|
||||
minio:
|
||||
image: minio/minio:latest
|
||||
container_name: cosmos-minio
|
||||
restart: unless-stopped
|
||||
command: server /data --console-address ":9001"
|
||||
environment:
|
||||
MINIO_ROOT_USER: ${MINIO_ROOT_USER:-minioadmin}
|
||||
MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD:-miniopassword123}
|
||||
volumes:
|
||||
- minio-data:/data
|
||||
ports:
|
||||
- "9000:9000"
|
||||
- "9001:9001"
|
||||
|
||||
# ─── Gitea Git Engine ───────────────────────────────────────────────────────
|
||||
gitea:
|
||||
image: gitea/gitea:latest
|
||||
container_name: cosmos-gitea
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
- USER_UID=1000
|
||||
- USER_GID=1000
|
||||
- GITEA__database__DB_TYPE=sqlite3
|
||||
- GITEA__database__PATH=/data/gitea/gitea.db
|
||||
- GITEA__server__ROOT_URL=http://localhost:3000/
|
||||
- GITEA__security__INSTALL_LOCK=true
|
||||
volumes:
|
||||
- gitea-data:/data
|
||||
ports:
|
||||
- "3000:3000"
|
||||
- "2222:22"
|
||||
|
||||
# ─── Cosmos Workstation Unified Backend ─────────────────────────────────────
|
||||
cosmos:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: deploy/Dockerfile
|
||||
container_name: cosmos-core
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
- scylla
|
||||
- minio
|
||||
- gitea
|
||||
environment:
|
||||
- PORT=8080
|
||||
- COSMOS_DOMAIN=${COSMOS_DOMAIN:-localhost}
|
||||
- COSMOS_BASE_URL=${COSMOS_BASE_URL:-http://localhost:8080}
|
||||
- SCYLLA_HOST=scylla
|
||||
- MINIO_ENDPOINT=minio:9000
|
||||
- MINIO_ROOT_USER=${MINIO_ROOT_USER:-minioadmin}
|
||||
- MINIO_ROOT_PASSWORD=${MINIO_ROOT_PASSWORD:-miniopassword123}
|
||||
- COSMOS_EMAIL_FROM=${COSMOS_EMAIL_FROM:[email protected]}
|
||||
- COSMOS_ADMIN_EMAIL=${COSMOS_ADMIN_EMAIL:[email protected]}
|
||||
ports:
|
||||
- "8080:8080"
|
||||
|
||||
volumes:
|
||||
scylla-data:
|
||||
minio-data:
|
||||
gitea-data:
|
||||
@@ -0,0 +1,59 @@
|
||||
# ==============================================================================
|
||||
# COSMOS WORKSTATION - NGINX REVERSE PROXY CONFIGURATION
|
||||
# Replace "yourdomain.com" with your public domain, dynamic DNS, or local IP
|
||||
# ==============================================================================
|
||||
|
||||
# Rate Limiting Zones
|
||||
limit_req_zone $binary_remote_addr zone=cosmos_limit:10m rate=30r/s;
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name yourdomain.com *.yourdomain.com;
|
||||
|
||||
# Redirect HTTP to HTTPS
|
||||
return 301 https://$host$request_uri;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
server_name yourdomain.com;
|
||||
|
||||
# SSL Certificate Paths (e.g. from Let's Encrypt / Certbot)
|
||||
ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
|
||||
ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;
|
||||
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_ciphers HIGH:!aNULL:!MD5;
|
||||
|
||||
client_max_body_size 500M;
|
||||
|
||||
# ─── Cosmos Unified Portal & S3 Console ───────────────────────────────────
|
||||
location / {
|
||||
limit_req zone=cosmos_limit burst=50 nodelay;
|
||||
proxy_pass http://127.0.0.1:8080;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
|
||||
# ─── Gitea Git Interface ──────────────────────────────────────────────────
|
||||
location /source/ {
|
||||
proxy_pass http://127.0.0.1:3000/;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
}
|
||||
|
||||
# ─── MinIO S3 API Endpoint ────────────────────────────────────────────────
|
||||
location /s3/ {
|
||||
proxy_pass http://127.0.0.1:9000/;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_buffering off;
|
||||
proxy_request_buffering off;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
-- ==============================================================================
|
||||
-- COSMOS WORKSTATION - SCYLLADB / CASSANDRA SCHEMA
|
||||
-- Keyspace and table definitions for unified auth, S3 IAM, and telemetry
|
||||
-- ==============================================================================
|
||||
|
||||
CREATE KEYSPACE IF NOT EXISTS cosmos
|
||||
WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1};
|
||||
|
||||
USE cosmos;
|
||||
|
||||
-- ─── USERS ───────────────────────────────────────────────────────────────────
|
||||
-- Core user directory holding credentials, IAM keys, and bucket links
|
||||
CREATE TABLE IF NOT EXISTS cosmos.users (
|
||||
service text,
|
||||
email text,
|
||||
name text,
|
||||
password_hash text,
|
||||
access_key text,
|
||||
secret_key text,
|
||||
bucket text,
|
||||
bucket_display_name text,
|
||||
session_id text,
|
||||
username text,
|
||||
profile_image text,
|
||||
created_at bigint,
|
||||
PRIMARY KEY ((service, email))
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS users_session_idx ON cosmos.users (session_id);
|
||||
CREATE INDEX IF NOT EXISTS users_username_idx ON cosmos.users (username);
|
||||
|
||||
-- ─── PENDING SIGNUPS ─────────────────────────────────────────────────────────
|
||||
-- Holds temporary registration verification state & OTP tokens
|
||||
CREATE TABLE IF NOT EXISTS cosmos.pending (
|
||||
service text,
|
||||
reg_token text,
|
||||
session_id text,
|
||||
name text,
|
||||
email text,
|
||||
password_hash text,
|
||||
username text,
|
||||
profile_image text,
|
||||
PRIMARY KEY ((service, reg_token))
|
||||
);
|
||||
|
||||
-- ─── PASSWORD RESET TOKENS ───────────────────────────────────────────────────
|
||||
-- One-time secure reset tokens with expiry
|
||||
CREATE TABLE IF NOT EXISTS cosmos.password_reset_tokens (
|
||||
reset_token text PRIMARY KEY,
|
||||
service text,
|
||||
email text,
|
||||
expires_at timestamp
|
||||
);
|
||||
|
||||
-- ─── S3 BUCKETS REGISTRY ─────────────────────────────────────────────────────
|
||||
-- Maps user-created buckets to owner accounts and friendly display names
|
||||
CREATE TABLE IF NOT EXISTS cosmos.buckets (
|
||||
bucket_name text PRIMARY KEY,
|
||||
owner_email text,
|
||||
display_name text
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS buckets_owner_idx ON cosmos.buckets (owner_email);
|
||||
|
||||
-- ─── CUSTOM DOMAINS ──────────────────────────────────────────────────────────
|
||||
-- Maps vanity / CNAME domains to specific private/public buckets
|
||||
CREATE TABLE IF NOT EXISTS cosmos.bucket_domains (
|
||||
domain text PRIMARY KEY,
|
||||
bucket_name text,
|
||||
owner_email text
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS bucket_domains_bucket_idx ON cosmos.bucket_domains (bucket_name);
|
||||
|
||||
-- ─── QUOTA REQUESTS ──────────────────────────────────────────────────────────
|
||||
-- Storage capacity expansion requests pending administrator approval
|
||||
CREATE TABLE IF NOT EXISTS cosmos.quota_requests (
|
||||
req_token text PRIMARY KEY,
|
||||
email text,
|
||||
amount int
|
||||
);
|
||||
|
||||
-- ─── S3 ALL-TIME METRICS ─────────────────────────────────────────────────────
|
||||
-- Aggregated operational telemetry per bucket
|
||||
CREATE TABLE IF NOT EXISTS cosmos.s3_analytics (
|
||||
bucket_name text PRIMARY KEY,
|
||||
total_requests bigint,
|
||||
cache_hits bigint,
|
||||
origin_hits bigint,
|
||||
total_success bigint,
|
||||
total_4xx bigint,
|
||||
total_5xx bigint,
|
||||
total_bytes bigint,
|
||||
last_hit bigint
|
||||
);
|
||||
|
||||
-- ─── S3 HOURLY TIME-SERIES METRICS ───────────────────────────────────────────
|
||||
-- Granular hourly counters for latency, bandwidth, and traffic trends
|
||||
CREATE TABLE IF NOT EXISTS cosmos.s3_analytics_hourly (
|
||||
bucket_name text,
|
||||
hour timestamp,
|
||||
requests counter,
|
||||
cache_hits counter,
|
||||
origin_hits counter,
|
||||
reads counter,
|
||||
writes counter,
|
||||
errors counter,
|
||||
bytes counter,
|
||||
PRIMARY KEY (bucket_name, hour)
|
||||
);
|
||||
Reference in New Issue
Block a user