Skip to content

Commit

Permalink
Add default enclave config and template
Browse files Browse the repository at this point in the history
  • Loading branch information
tanyav2 committed Jan 27, 2025
1 parent 41bdbcc commit b4686e8
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 1 deletion.
22 changes: 22 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Build and Attest

on:
push:
tags:
- 'v*'

jobs:
release:
runs-on: large
permissions:
contents: write
packages: write
id-token: write
attestations: write

steps:
- uses: actions/checkout@v4
- uses: tinfoilanalytics/[email protected]
with:
docker-context: .
github-token: ${{ secrets.GITHUB_TOKEN }}
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM ghcr.io/tinfoilanalytics/nitro-attestation-shim:v0.2.2 AS shim

FROM ollama/ollama

RUN apt update -y
RUN apt install -y iproute2 jq

COPY --from=shim /nitro-attestation-shim /nitro-attestation-shim
COPY config.json /app/config.json
COPY start.sh /app/start.sh

ENV HOME=/

RUN chmod +x /app/start.sh && \
nohup bash -c "ollama serve &" && sleep 5 && \
for model in $(jq -r '.models[]' /app/config.json); do \
ollama pull "$model"; \
done

ENTRYPOINT ["/app/start.sh"]
34 changes: 33 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,34 @@
# default-models-nitro
Default CPU-only model enclave for Tinfoil

This repository serves as both:

- Tinfoil's default inference enclave running CPU-only models using Ollama inference server, on AWS Nitro Enclaves
- A template for running your choice of CPU-only models on Nitro Enclaves

## Default Configuration

The default enclave runs the following models:

- `llama3.2:1b`
- `llama-guard3:1b`
- `qwen2.5-coder:0.5b`
- `nomic-embed-text`

And exposes the following endpoints for inference:

- `/api/chat`
- `/v1/chat/completions`
- `/api/generate`
- `/api/embed`

As shown in `config.json`.

## Custom Configuration

If you want to run a different set of models and/or expose a different set of endpoints:

1. Click "Use this template" to create a new repository
2. Edit `config.json` to customize:
- `models`: Any model from Ollama's [library](https://ollama.com/library)
- `paths`: API endpoints from Ollama's [API documentation](https://ollama.ai/docs/api) you want to expose
3. Create a release tag (e.g. `v0.0.1`) to trigger the build workflow
14 changes: 14 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"models": [
"llama3.2:1b",
"llama-guard3:1b",
"qwen2.5-coder:0.5b",
"nomic-embed-text"
],
"paths": [
"/api/chat",
"/v1/chat/completions",
"/api/generate",
"/api/embed"
]
}
22 changes: 22 additions & 0 deletions start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

# Read configuration
CONFIG_FILE="/app/config.json"
PATHS=$(jq -r '.paths[]' $CONFIG_FILE)

# Build shim arguments
SHIM_ARGS=(
"-e" "[email protected]"
"-u" "11434"
)

# Add paths from config
for path in $PATHS; do
SHIM_ARGS+=("-p" "$path")
done

# Add final arguments
SHIM_ARGS+=("--" "/bin/ollama" "serve")

# Execute shim with arguments
exec /nitro-attestation-shim "${SHIM_ARGS[@]}"

0 comments on commit b4686e8

Please sign in to comment.