···1+# Use the official Bun image as base
2+FROM oven/bun:1.0 AS builder
3+4+# Set working directory
5+WORKDIR /app
6+7+# Copy root workspace files
8+COPY package.json bun.lockb ./
9+10+# Copy turbo.json
11+COPY turbo.json ./
12+13+# Copy workspace packages
14+COPY packages/db/ ./packages/db/
15+COPY packages/lexicons/ ./packages/lexicons/
16+COPY packages/tsconfig/ ./packages/tsconfig/
17+18+# Copy the aqua app
19+COPY apps/aqua/ ./apps/aqua/
20+21+# Install dependencies
22+RUN bun install
23+24+# Build workspace packages (if needed)
25+RUN bun run build --filter=@teal/db
26+RUN bun run build --filter=@teal/lexicons
27+28+# Build the aqua app
29+WORKDIR /app/apps/aqua
30+RUN bun run build
31+32+# Start production image (node lts ideally)
33+FROM node:bookworm-slim
34+35+WORKDIR /app
36+37+# Copy built assets from builder
38+COPY --from=builder /app/apps/aqua/dist ./dist
39+# copy base node modules
40+COPY --from=builder /app/node_modules ./node_modules
41+COPY --from=builder /app/apps/aqua/node_modules ./node_modules
42+COPY --from=builder /app/apps/aqua/package.json ./
43+44+# move public to cwd
45+RUN mv ./dist/public ./public
46+47+# Set environment variables
48+ENV NODE_ENV=production
49+50+# Expose the port your app runs on
51+EXPOSE 3000
52+53+# Start the application
54+CMD ["npm", "run", "start"]
···1-package main
2-3-import (
4- "fmt"
5- "sync"
6-7- server "viridian/server"
8- worker "viridian/worker"
9-)
10-11-func main() {
12- var wg sync.WaitGroup
13-14- // Run the server in a goroutine
15- go server.RunServer()
16-17- // Simulate workers, each running in a separate goroutine
18- workerCount := worker.GetCoreCount()
19- fmt.Printf("Starting %d workers\n", workerCount)
20- for i := 1; i <= workerCount; i++ {
21- fmt.Printf("Starting worker %d\n", i)
22- workerID := fmt.Sprintf("worker-%d", i)
23- wg.Add(1)
24- go worker.RunWorker(workerID, &wg)
25- }
26-27- // Wait for all workers to complete (this won't happen in this example since workers run indefinitely)
28- wg.Wait()
29-}
···1-package types
2-3-import (
4- "strconv"
5- "sync"
6-)
7-8-// Job represents a job with an ID and status
9-type Job struct {
10- ID string
11- Status string
12-}
13-14-// Server represents the state of the server, including jobs, worker-job associations, and job status
15-type Server struct {
16- Jobs []Job // Job queue
17- WorkerJobs map[string]string // Mapping worker ID -> job ID
18- JobStatus map[string]string // Mapping job ID -> status
19- Mu sync.Mutex // Mutex to handle concurrency
20-}
21-22-func (s *Server) AddJob() Job {
23- s.Mu.Lock()
24- defer s.Mu.Unlock()
25- job := Job{"job" + strconv.Itoa(len(s.Jobs)), "pending"}
26- s.Jobs = append(s.Jobs, job)
27-28- return job
29-}
30-31-// TrackJob assigns a job to a worker and marks it as in-progress
32-func (s *Server) TrackJob(workerID, jobID string) {
33- s.Mu.Lock()
34- defer s.Mu.Unlock()
35- s.WorkerJobs[workerID] = jobID
36- s.JobStatus[jobID] = "in-progress"
37-}
38-39-// MarkJobCompleted marks a job as completed and removes the worker-job association
40-func (s *Server) MarkJobCompleted(workerID string) {
41- s.Mu.Lock()
42- defer s.Mu.Unlock()
43- jobID := s.WorkerJobs[workerID]
44- s.JobStatus[jobID] = "completed"
45- delete(s.WorkerJobs, workerID) // Remove worker-job association
46-}
···3import process from "node:process";
4import path from "node:path";
56-console.log(
7- "Loading SQLite file at",
8- path.join(process.cwd(), "../../db.sqlite"),
9-);
1011export const db = drizzle({
12 connection:
13 // default is in project root / db.sqlite
14 process.env.DATABASE_URL ??
15- "file:" + path.join(process.cwd(), "../../db.sqlite"),
16 // doesn't seem to work?
17 //casing: "snake_case",
18 schema: schema,
···3import process from "node:process";
4import path from "node:path";
56+console.log("Loading SQLite file at", path.join(process.cwd(), "./db.sqlite"));
00078export const db = drizzle({
9 connection:
10 // default is in project root / db.sqlite
11 process.env.DATABASE_URL ??
12+ "file:" + path.join(process.cwd(), "./db.sqlite"),
13 // doesn't seem to work?
14 //casing: "snake_case",
15 schema: schema,
-2
packages/jetstring/src/index.ts
···2import { db } from "@teal/db/connect";
3import { status } from "@teal/db/schema";
4import { CommitCreateEvent, Jetstream } from "@skyware/jetstream";
5-import { server } from "@teal/lexicons/generated/server/types";
6-import ws from "ws";
78class Handler {
9 private static instance: Handler;
···2import { db } from "@teal/db/connect";
3import { status } from "@teal/db/schema";
4import { CommitCreateEvent, Jetstream } from "@skyware/jetstream";
0056class Handler {
7 private static instance: Handler;