Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
packages
dist
.git
.env
26 changes: 22 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
.PHONY: build clean lint docker-build docker-build-simple-email docker-build-send-email-link docker-push docker-push-simple-email docker-push-send-email-link
.PHONY: build clean lint test test-all build-test-runner docker-build docker-build-simple-email docker-build-send-email-link docker-push docker-push-simple-email docker-push-send-email-link

REGISTRY := ghcr.io/constructive-io/constructive-functions
KIND_BIN ?= /opt/homebrew/bin/kind

SUBDIRS := functions/hello-world functions/simple-email functions/send-email-link functions/runtime-script

build:
pnpm run build
pnpm -r build

clean:
pnpm run clean
pnpm -r clean

lint:
pnpm run lint
pnpm -r lint

test:
pnpm -r test

# Docker Build & Push (Restored)
docker-build:
@echo "Building Docker images for functions..."
@for fn in functions/*; do \
Expand Down Expand Up @@ -40,3 +47,14 @@ docker-push-simple-email:

docker-push-send-email-link:
docker push $(REGISTRY)/send-email-link:latest

# Kubernetes Test Runner
test-k8s-all: build-test-runner
@echo "Running All K8s Tests (Centralized Runner)..."
# Run the centralized TS test runner
npx ts-node scripts/test-runner.ts

build-test-runner:
@echo "Building Shared Test Runner Image..."
docker build -f functions/_runtimes/node/Dockerfile.test -t constructive/function-test-runner:v2 .
$(KIND_BIN) load docker-image constructive/function-test-runner:v2 --name interweb-local
73 changes: 73 additions & 0 deletions functions/_runtimes/agentic/Dockerfile.agentic
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Python runtime for LLM API inference (OpenAI & Claude)
# This module makes API calls to OpenAI and Anthropic for LLM inference
# For the full fat container with Ollama & local models, see Dockerfile.ollama
# Based on: /Users/0xj0/Documents/projects/LQL/CONSTRUCTIVE/agentic-foundation

##################### heres what is had inside of (/Users/0xj0/Documents/projects/LQL/CONSTRUCTIVE/agentic-foundation) -- GO VERIFY YOURSELF

# Builder Stage
FROM rust:latest as builder
WORKDIR /app
COPY . .
# Build agent_core
RUN cargo build --release --bin agent_core

# Runtime Stage - "Fat Container"
FROM ubuntu:22.04
WORKDIR /app

# Set non-interactive install
ENV DEBIAN_FRONTEND=noninteractive

# 1. Install Basic Tools & Runtimes (Python, Node, System Utils)
RUN apt-get update && apt-get install -y \
curl wget git build-essential \
python3 python3-pip python3-venv \
nodejs npm \
postgresql-14 postgresql-client-14 \
sudo \
libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 libxkbcommon0 \
libxcomposite1 libxdamage1 libxfixes3 libxrandr2 libgbm1 libasound2 \
chromium-browser \
&& rm -rf /var/lib/apt/lists/*

# 2. Install Rust in Runtime (for the agent to use `cargo`)
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"

# 3. Install PostGraphile
RUN npm install -g postgraphile @graphile-contrib/pg-simplify-inflector

# 4. Install Ollama & Bake Models
# We install Ollama, then start it in the background to pull models into the image layers.
RUN curl -fsSL https://ollama.com/install.sh | sh

# Pre-pull Models (Using available equivalents for the '2025' spec models)
# GPT-OSS -> llama3.2 (Small, open, robust)
# Qwen3-VL -> llava (Vision model standard in Ollama)
# Devstral -> qwen2.5-coder (Excellent coding model)
# Nemotron -> mistral (Strong reasoning)
RUN nohup bash -c "ollama serve" & \
sleep 10 && \
ollama pull llama3.2 && \
ollama pull llava && \
ollama pull qwen2.5-coder && \
ollama pull mistral && \
pkill ollama

# 5. Setup Data & Permissions
RUN mkdir -p /var/lib/postgresql/data && chown -R postgres:postgres /var/lib/postgresql/data

# 6. Copy Binaries & Scripts
COPY --from=builder /app/target/release/agent_core /app/agent_core
COPY scripts/entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh

# 7. Config
ENV DATABASE_URL=postgres://agent:agent@localhost:5432/agentic
ENV OLLAMA_HOST=0.0.0.0:11434

EXPOSE 3000 5432 11434 5000

ENTRYPOINT ["/app/entrypoint.sh"]
CMD ["./agent_core"]
17 changes: 17 additions & 0 deletions functions/_runtimes/node/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM node:22-alpine

WORKDIR /usr/src/app

COPY package.json ./

RUN npm install -g pnpm@10.12.2 && pnpm install --prod

COPY dist ./dist

ENV NODE_ENV=production
ENV PORT=8080

USER node

CMD ["node", "dist/index.js"]

35 changes: 35 additions & 0 deletions functions/_runtimes/node/Dockerfile.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FROM node:20-alpine

# Install Postgres Client and Build Tools
RUN apk add --no-cache postgresql-client bash make g++ python3 kubectl

COPY . /app
WORKDIR /app

# Ensure clean slate
RUN rm -rf node_modules

# 3. Install Dependencies from NPM
RUN npm install -g pnpm@9 && pnpm install --no-frozen-lockfile

# 4. Build
# 5. Install PGPM from NPM
RUN npm install -g pgpm

# Run as postgres user to avoid 'role root does not exist' in pgsql-test
# handle existing user/group if created by apk
RUN (getent group postgres || addgroup -S postgres) && (getent passwd postgres || adduser -S postgres -G postgres)
RUN chown -R postgres:postgres /app
USER postgres
ENV USER=postgres
ENV PGUSER=postgres

# 6. Setup Entrypoint (Inlined for Minimalism)
ENV NODE_ENV=test
CMD ["/bin/bash", "-c", "set -e; \
echo \"Waiting for Postgres at $PGHOST:$PGPORT...\"; \
until pg_isready -h \"$PGHOST\" -p \"$PGPORT\" -U \"$PGUSER\"; do echo \"Waiting...\"; sleep 2; done; \
echo \"Deploying Schema...\"; \
pgpm deploy --package pgpm-database-jobs --database template1 --yes 2>/dev/null || echo \"Deploy continued...\"; \
unset PGDATABASE; \
pnpm test"]
1 change: 1 addition & 0 deletions functions/_runtimes/python/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# TODO: create a standard python function here that can run pytorch for me
42 changes: 42 additions & 0 deletions functions/_runtimes/rust/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Multi-stage build for Rust functions
FROM rust:1.83-alpine AS builder

WORKDIR /build

# Install build dependencies
RUN apk add --no-cache musl-dev

# Copy dependency manifests first (for layer caching)
COPY Cargo.toml Cargo.lock ./

# Create dummy src to build dependencies
RUN mkdir src && echo "fn main() {}" > src/main.rs
RUN cargo build --release --target x86_64-unknown-linux-musl
RUN rm -rf src

# Copy actual source code
COPY src ./src

# Build the actual binary
RUN touch src/main.rs && cargo build --release --target x86_64-unknown-linux-musl

# Runtime stage - minimal Alpine image
FROM alpine:3.19

WORKDIR /usr/src/app

# Copy the compiled binary from builder
COPY --from=builder /build/target/x86_64-unknown-linux-musl/release/app ./app

# Create non-root user
RUN addgroup -g 1000 appuser && \
adduser -D -u 1000 -G appuser appuser && \
chown -R appuser:appuser /usr/src/app

ENV PORT=8080

USER appuser

EXPOSE 8080

CMD ["./app"]
33 changes: 33 additions & 0 deletions functions/hello-world/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

IMAGE_NAME ?= constructive/hello-world-test:v1
KIND_CLUSTER_NAME ?= interweb-local
KIND_BIN ?= $(shell which kind 2>/dev/null || echo "/opt/homebrew/bin/kind")

# Define Secrets and Env
TEST_PGHOST ?= postgres
TEST_PGPASSWORD ?= $(shell kubectl get secret --namespace default pg-credentials -o jsonpath="{.data.PGPASSWORD}" | base64 --decode)

.PHONY: vendor test clean test-k8s

test:
pnpm test

clean:
pnpm clean

# Test in K8s (In-Cluster)
test-k8s:
@echo "Running Generic Test Pattern for Hello World..."
kubectl proxy --port=8001 > proxy.log 2>&1 & PID=$$!; \
echo "Starting Proxy (PID: $$PID)..."; \
sleep 2; \
TEST_PGPASSWORD=$$(kubectl get secret pg-credentials -o jsonpath="{.data.PGPASSWORD}" | base64 --decode) \
IMAGE_NAME="constructive/function-test-runner:v1" \
IS_IN_POD="false" \
PGHOST=$(TEST_PGHOST) \
PGUSER=postgres \
PGPASSWORD=$$TEST_PGPASSWORD \
TEST_GRAPHQL_URL=$(TEST_GRAPHQL_URL) \
npm test -- __tests__/index.test.ts || (echo "=== Proxy Logs ===" && cat proxy.log && kill $$PID && exit 1); \
kill $$PID; \
rm proxy.log
Loading
Loading