Skip to content

The only tool you need to know what is happening and how to fix it.

docker done

dduxfa9b4f4ce9cf
diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 00000000..15afc439
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,40 @@
+# Git
+.git
+.gitignore
+
+# IDE
+.vscode
+.idea
+*.swp
+*.swo
+
+# Node
+frontend/node_modules
+frontend/.svelte-kit
+
+# Go
+backend/vendor
+
+# Build artifacts (will be rebuilt in Docker)
+frontend/build
+
+# Documentation
+*.md
+
+# Environment files (use .env.docker instead)
+backend/.env
+.env
+
+# OS files
+.DS_Store
+Thumbs.db
+
+# Logs
+*.log
+
+# Temporary files
+tmp/
+temp/
+
+# Claude plans
+.claude/
diff --git a/DOCKER.md b/DOCKER.md
new file mode 100644
index 00000000..fe0b4dcc
--- /dev/null
+++ b/DOCKER.md
@@ -0,0 +1,87 @@
+# Traceway Docker Deployment
+
+All-in-one Docker container that runs the complete Traceway stack:
+- **Frontend**: SvelteKit SPA served via nginx (port 80)
+- **Backend**: Go/Gin API server (port 8082)
+- **ClickHouse**: Time-series database (internal)
+
+## Build
+
+```bash
+docker build -t traceway:latest .
+```
+
+## Run
+
+### Basic
+```bash
+docker run -d --name traceway -p 80:80 -p 8082:8082 traceway:latest
+```
+
+### With Persistent Data (Recommended)
+```bash
+docker run -d --name traceway \
+ -p 80:80 \
+ -p 8082:8082 \
+ -v traceway-data:/var/lib/clickhouse \
+ traceway:latest
+```
+
+### With Custom Tokens
+```bash
+docker run -d --name traceway \
+ -p 80:80 \
+ -p 8082:8082 \
+ -e TOKEN="your-client-token" \
+ -e APP_TOKEN="your-app-token" \
+ -v traceway-data:/var/lib/clickhouse \
+ traceway:latest
+```
+
+## Access Points
+
+| URL | Description |
+|-----|-------------|
+| `http://localhost/` | Frontend (SvelteKit SPA) |
+| `http://localhost/api/*` | Backend API (proxied through nginx) |
+| `http://localhost:8082/api/*` | Direct backend access |
+
+## Useful Commands
+
+```bash
+# View logs
+docker logs traceway
+
+# Follow logs
+docker logs -f traceway
+
+# Check service status
+docker exec traceway supervisorctl status
+
+# Enter container shell
+docker exec -it traceway bash
+
+# Stop container
+docker stop traceway
+
+# Stop and remove
+docker stop traceway && docker rm traceway
+
+# Remove with data volume
+docker stop traceway && docker rm traceway && docker volume rm traceway-data
+```
+
+## Architecture
+
+The container uses **supervisord** to manage three services:
+
+1. **ClickHouse** (priority 10) - Starts first
+2. **Backend** (priority 20) - Waits for ClickHouse, then starts
+3. **Nginx** (priority 30) - Starts last, serves frontend and proxies API
+
+## Notes
+
+- First startup takes ~60 seconds while ClickHouse initializes
+- Backend automatically runs database migrations on startup
+- Use `-v traceway-data:/var/lib/clickhouse` to persist data between restarts
+- Environment variables `TOKEN` and `APP_TOKEN` can be overridden at runtime
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 00000000..87f42b38
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,112 @@
+# ==============================================================================
+# Traceway All-in-One Docker Image
+# Includes: Frontend (SvelteKit), Backend (Go), ClickHouse
+# ==============================================================================
+
+# ==============================================================================
+# Stage 1: Build Frontend
+# ==============================================================================
+FROM node:22-alpine AS frontend-builder
+
+WORKDIR /app/frontend
+
+# Copy package files first for better caching
+COPY frontend/package.json frontend/package-lock.json ./
+
+# Install dependencies
+RUN npm ci
+
+# Copy source and build
+COPY frontend/ ./
+RUN npm run build
+
+# ==============================================================================
+# Stage 2: Build Backend
+# ==============================================================================
+FROM golang:1.24-alpine AS backend-builder
+
+WORKDIR /app/backend
+
+# Install build dependencies
+RUN apk add --no-cache git
+
+# Copy all backend source
+COPY backend/ ./
+
+# Fix go version (1.25.1 doesn't exist yet, use 1.24) and download deps
+RUN go mod edit -go=1.24 && go mod download
+
+# Build
+RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o /traceway-backend .
+
+# ==============================================================================
+# Stage 3: Extract ClickHouse binaries
+# ==============================================================================
+FROM clickhouse/clickhouse-server:24.8-alpine AS clickhouse-source
+
+# ==============================================================================
+# Stage 4: Final Runtime Image
+# ==============================================================================
+FROM debian:bookworm-slim
+
+# Install runtime dependencies
+RUN apt-get update && apt-get install -y --no-install-recommends \
+ nginx \
+ supervisor \
+ ca-certificates \
+ curl \
+ && rm -rf /var/lib/apt/lists/* \
+ && mkdir -p /var/log/supervisor \
+ && mkdir -p /var/log/nginx \
+ && mkdir -p /var/lib/clickhouse \
+ && mkdir -p /var/log/clickhouse-server \
+ && mkdir -p /etc/clickhouse-server/config.d \
+ && mkdir -p /etc/clickhouse-server/users.d
+
+# Copy ClickHouse binaries and configs from official image
+COPY --from=clickhouse-source /usr/bin/clickhouse /usr/bin/clickhouse
+COPY --from=clickhouse-source /etc/clickhouse-server/config.xml /etc/clickhouse-server/config.xml
+COPY --from=clickhouse-source /etc/clickhouse-server/users.xml /etc/clickhouse-server/users.xml
+
+# Create ClickHouse symlinks (clickhouse is a multicall binary)
+RUN ln -s /usr/bin/clickhouse /usr/bin/clickhouse-server \
+ && ln -s /usr/bin/clickhouse /usr/bin/clickhouse-client
+
+# Copy built frontend
+COPY --from=frontend-builder /app/frontend/build /var/www/html
+
+# Copy built backend
+COPY --from=backend-builder /traceway-backend /usr/local/bin/traceway-backend
+
+# Copy configuration files
+COPY docker/nginx.conf /etc/nginx/nginx.conf
+COPY docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
+COPY docker/clickhouse-config.xml /etc/clickhouse-server/config.d/docker.xml
+COPY docker/clickhouse-users.xml /etc/clickhouse-server/users.d/docker.xml
+COPY docker/wait-for-clickhouse.sh /usr/local/bin/wait-for-clickhouse.sh
+COPY docker/start-backend.sh /usr/local/bin/start-backend.sh
+
+# Make scripts executable
+RUN chmod +x /usr/local/bin/wait-for-clickhouse.sh \
+ && chmod +x /usr/local/bin/start-backend.sh
+
+# Create clickhouse user and set permissions
+RUN useradd -r -s /bin/false clickhouse \
+ && chown -R clickhouse:clickhouse /var/lib/clickhouse \
+ && chown -R clickhouse:clickhouse /var/log/clickhouse-server
+
+# Create app directory for backend and copy env file
+WORKDIR /app
+COPY backend/.env.docker /app/.env
+
+# Expose ports
+# Port 80: nginx (frontend + API proxy)
+# Port 8082: direct backend access (optional)
+EXPOSE 80 8082
+
+# Health check
+HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
+ CMD curl -f http://localhost/health || exit 1
+
+# Start supervisord
+CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]
diff --git a/backend/.env.docker b/backend/.env.docker
new file mode 100644
index 00000000..284be51c
--- /dev/null
+++ b/backend/.env.docker
@@ -0,0 +1,7 @@
+TOKEN="demotoken"
+APP_TOKEN="nice"
+CLICKHOUSE_SERVER=localhost:9000
+CLICKHOUSE_DATABASE=traceway
+CLICKHOUSE_USERNAME=default
+CLICKHOUSE_PASSWORD=
+CLICKHOUSE_TLS=false
diff --git a/docker/clickhouse-config.xml b/docker/clickhouse-config.xml
new file mode 100644
index 00000000..1d98de2d
--- /dev/null
+++ b/docker/clickhouse-config.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0"?>
+<clickhouse>
+ <!-- Listen on localhost only for security -->
+ <listen_host>127.0.0.1</listen_host>
+
+ <!-- Native protocol port -->
+ <tcp_port>9000</tcp_port>
+
+ <!-- HTTP interface (for debugging) -->
+ <http_port>8123</http_port>
+
+ <!-- Data and log directories -->
+ <path>/var/lib/clickhouse/</path>
+ <tmp_path>/var/lib/clickhouse/tmp/</tmp_path>
+ <user_files_path>/var/lib/clickhouse/user_files/</user_files_path>
+ <format_schema_path>/var/lib/clickhouse/format_schemas/</format_schema_path>
+
+ <!-- Logging -->
+ <logger>
+ <level>information</level>
+ <log>/var/log/clickhouse-server/clickhouse-server.log</log>
+ <errorlog>/var/log/clickhouse-server/clickhouse-server.err.log</errorlog>
+ <size>100M</size>
+ <count>3</count>
+ </logger>
+
+ <!-- Memory limits for container -->
+ <max_server_memory_usage_to_ram_ratio>0.8</max_server_memory_usage_to_ram_ratio>
+
+ <!-- Mark cache size (5GB) -->
+ <mark_cache_size>5368709120</mark_cache_size>
+
+ <!-- Disable distributed DDL for single-node -->
+ <distributed_ddl>
+ <path>/clickhouse/task_queue/ddl</path>
+ </distributed_ddl>
+</clickhouse>
diff --git a/docker/clickhouse-users.xml b/docker/clickhouse-users.xml
new file mode 100644
index 00000000..d2990dbc
--- /dev/null
+++ b/docker/clickhouse-users.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0"?>
+<clickhouse>
+ <users>
+ <default>
+ <password></password>
+ <networks>
+ <ip>127.0.0.1</ip>
+ <ip>::1</ip>
+ </networks>
+ <profile>default</profile>
+ <quota>default</quota>
+ <access_management>1</access_management>
+ </default>
+ </users>
+
+ <profiles>
+ <default>
+ <max_memory_usage>10000000000</max_memory_usage>
+ <use_uncompressed_cache>0</use_uncompressed_cache>
+ <load_balancing>random</load_balancing>
+ </default>
+ </profiles>
+
+ <quotas>
+ <default>
+ <interval>
+ <duration>3600</duration>
+ <queries>0</queries>
+ <errors>0</errors>
+ <result_rows>0</result_rows>
+ <read_rows>0</read_rows>
+ <execution_time>0</execution_time>
+ </interval>
+ </default>
+ </quotas>
+</clickhouse>
diff --git a/docker/nginx.conf b/docker/nginx.conf
new file mode 100644
index 00000000..27b81521
--- /dev/null
+++ b/docker/nginx.conf
@@ -0,0 +1,93 @@
+user www-data;
+worker_processes auto;
+pid /run/nginx.pid;
+error_log /var/log/nginx/error.log warn;
+
+events {
+ worker_connections 1024;
+ use epoll;
+ multi_accept on;
+}
+
+http {
+ include /etc/nginx/mime.types;
+ default_type application/octet-stream;
+
+ log_format main '$remote_addr - $remote_user [$time_local] "$request" '
+ '$status $body_bytes_sent "$http_referer" '
+ '"$http_user_agent" "$http_x_forwarded_for"';
+
+ access_log /var/log/nginx/access.log main;
+
+ sendfile on;
+ tcp_nopush on;
+ tcp_nodelay on;
+ keepalive_timeout 65;
+ types_hash_max_size 2048;
+
+ # Gzip compression
+ gzip on;
+ gzip_vary on;
+ gzip_proxied any;
+ gzip_comp_level 6;
+ gzip_types text/plain text/css text/xml application/json application/javascript
+ application/xml application/xml+rss text/javascript image/svg+xml;
+
+ # Upstream for backend
+ upstream backend {
+ server 127.0.0.1:8082;
+ keepalive 32;
+ }
+
+ server {
+ listen 80;
+ server_name _;
+ root /var/www/html;
+ index index.html;
+
+ # Security headers
+ add_header X-Frame-Options "SAMEORIGIN" always;
+ add_header X-Content-Type-Options "nosniff" always;
+ add_header X-XSS-Protection "1; mode=block" always;
+
+ # API proxy - all /api requests go to backend
+ location /api {
+ proxy_pass http://backend;
+ proxy_http_version 1.1;
+ 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_set_header Connection "";
+
+ # Timeouts
+ proxy_connect_timeout 60s;
+ proxy_send_timeout 60s;
+ proxy_read_timeout 60s;
+
+ # Buffering settings
+ proxy_buffering on;
+ proxy_buffer_size 4k;
+ proxy_buffers 8 4k;
+ }
+
+ # Static assets with caching
+ location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
+ expires 1y;
+ add_header Cache-Control "public, immutable";
+ try_files $uri =404;
+ }
+
+ # SPA fallback - serve index.html for all other routes
+ location / {
+ try_files $uri $uri/ /index.html;
+ }
+
+ # Health check endpoint
+ location /health {
+ access_log off;
+ return 200 "OK\n";
+ add_header Content-Type text/plain;
+ }
+ }
+}
diff --git a/docker/start-backend.sh b/docker/start-backend.sh
new file mode 100644
index 00000000..ce528183
--- /dev/null
+++ b/docker/start-backend.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+set -e
+
+echo "Waiting for ClickHouse to be ready..."
+/usr/local/bin/wait-for-clickhouse.sh
+
+echo "Starting Traceway backend..."
+exec /usr/local/bin/traceway-backend
diff --git a/docker/supervisord.conf b/docker/supervisord.conf
new file mode 100644
index 00000000..601673e1
--- /dev/null
+++ b/docker/supervisord.conf
@@ -0,0 +1,57 @@
+[supervisord]
+nodaemon=true
+logfile=/var/log/supervisor/supervisord.log
+pidfile=/var/run/supervisord.pid
+childlogdir=/var/log/supervisor
+user=root
+
+[unix_http_server]
+file=/var/run/supervisor.sock
+chmod=0700
+
+[rpcinterface:supervisor]
+supervisor.rpcinterface_factory=supervisor.rpcinterface:make_main_rpcinterface
+
+[supervisorctl]
+serverurl=unix:///var/run/supervisor.sock
+
+; ClickHouse - starts first (priority 10)
+[program:clickhouse]
+command=/usr/bin/clickhouse-server --config-file=/etc/clickhouse-server/config.xml
+user=clickhouse
+autostart=true
+autorestart=true
+priority=10
+startsecs=10
+startretries=3
+stdout_logfile=/var/log/supervisor/clickhouse-stdout.log
+stderr_logfile=/var/log/supervisor/clickhouse-stderr.log
+stdout_logfile_maxbytes=10MB
+stderr_logfile_maxbytes=10MB
+
+; Backend - starts after ClickHouse (priority 20)
+[program:backend]
+command=/usr/local/bin/start-backend.sh
+directory=/app
+autostart=true
+autorestart=true
+priority=20
+startsecs=5
+startretries=3
+stdout_logfile=/var/log/supervisor/backend-stdout.log
+stderr_logfile=/var/log/supervisor/backend-stderr.log
+stdout_logfile_maxbytes=10MB
+stderr_logfile_maxbytes=10MB
+
+; Nginx - starts last (priority 30)
+[program:nginx]
+command=/usr/sbin/nginx -g "daemon off;"
+autostart=true
+autorestart=true
+priority=30
+startsecs=2
+startretries=3
+stdout_logfile=/var/log/supervisor/nginx-stdout.log
+stderr_logfile=/var/log/supervisor/nginx-stderr.log
+stdout_logfile_maxbytes=10MB
+stderr_logfile_maxbytes=10MB
diff --git a/docker/wait-for-clickhouse.sh b/docker/wait-for-clickhouse.sh
new file mode 100644
index 00000000..861e3e13
--- /dev/null
+++ b/docker/wait-for-clickhouse.sh
@@ -0,0 +1,25 @@
+#!/bin/bash
+set -e
+
+MAX_RETRIES=30
+RETRY_INTERVAL=2
+
+echo "Checking ClickHouse availability..."
+
+for i in $(seq 1 $MAX_RETRIES); do
+ if /usr/bin/clickhouse-client --host localhost --port 9000 --query "SELECT 1" > /dev/null 2>&1; then
+ echo "ClickHouse is ready!"
+
+ # Create database if it doesn't exist
+ echo "Creating traceway database if not exists..."
+ /usr/bin/clickhouse-client --host localhost --port 9000 --query "CREATE DATABASE IF NOT EXISTS traceway"
+ echo "Database ready!"
+
+ exit 0
+ fi
+ echo "Attempt $i/$MAX_RETRIES: ClickHouse not ready yet, waiting ${RETRY_INTERVAL}s..."
+ sleep $RETRY_INTERVAL
+done
+
+echo "ERROR: ClickHouse failed to become ready after $MAX_RETRIES attempts"
+exit 1
diff --git a/frontend/src/routes/issues/[exceptionHash]/events/+page.ts b/frontend/src/routes/issues/[exceptionHash]/events/+page.ts
new file mode 100644
index 00000000..4b5a5749
--- /dev/null
+++ b/frontend/src/routes/issues/[exceptionHash]/events/+page.ts
@@ -0,0 +1,14 @@
+import { redirect } from '@sveltejs/kit';
+import { authState } from '$lib/state/auth.svelte';
+import type { PageLoad } from './$types';
+
+export const prerender = false;
+
+export const load: PageLoad = ({ params }) => {
+ if (!authState.isAuthenticated) {
+ throw redirect(302, '/login');
+ }
+ return {
+ exceptionHash: params.exceptionHash
+ };
+};