Skip to content
Open

Exp #59

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
2 changes: 1 addition & 1 deletion Dockerfile → .devops/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ COPY . .
ENV PATH="/app/venv/bin:$PATH"
ENV PYTHONUNBUFFERED=1

ENTRYPOINT ["python3", "engine/main.py"]
ENTRYPOINT ["python3", "engine/main.py"]
File renamed without changes.
65 changes: 65 additions & 0 deletions .devops/Dockerfile.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@

FROM ubuntu:24.04 AS builder

LABEL stage=builder

ARG DEBIAN_FRONTEND=noninteractive
ARG BUILD_TYPE=Release
ARG CMAKE_EXTRA_FLAGS=""

RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
g++ \
cmake \
ninja-build \
ccache \
git \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /src

COPY main.cpp ./
COPY benchmark.cpp ./
COPY config/ ./config/
COPY include/ ./include/
COPY data/ ./data/

# If model/Cmakelists.txt exists, use cmake; else fall back to direct g++
RUN set -e; \
if [ -f model/Cmakelists.txt ] || [ -f CMakeLists.txt ]; then \
cmake -B build -G Ninja \
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
${CMAKE_EXTRA_FLAGS} .; \
cmake --build build --parallel "$(nproc)"; \
else \
g++ -std=c++17 -O3 -march=native \
-I. -Iinclude \
-o /usr/local/bin/quadtrix \
main.cpp; \
fi
FROM ubuntu:24.04 AS runtime

LABEL org.opencontainers.image.title="Quadtrix.cpp Engine"
LABEL org.opencontainers.image.description="C++ transformer engine for local LM inference"
LABEL org.opencontainers.image.source="https://github.com/Eamon2009/Quadtrix.cpp"

RUN apt-get update && apt-get install -y --no-install-recommends \
libstdc++6 \
libgomp1 \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /app

COPY --from=builder /usr/local/bin/quadtrix /usr/local/bin/quadtrix
COPY --from=builder /src/data/ ./data/
VOLUME ["/models"]

ENV GPT_DATA_PATH=/app/data/input.txt \
GPT_MODEL_PATH=/models/best_model.bin

EXPOSE 8080

ENTRYPOINT ["/usr/local/bin/quadtrix"]
CMD ["data/input.txt", "--chat"]
47 changes: 47 additions & 0 deletions .devops/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Quadtrix.cpp — Nginx config
# Serves the Vite SPA and proxies /api/* to the FastAPI backend

server {
listen 80;
server_name _;

root /usr/share/nginx/html;
index index.html;

# Gzip
gzip on;
gzip_types text/plain text/css application/json application/javascript
text/xml application/xml application/xml+rss text/javascript
application/wasm;
gzip_min_length 1024;

# SPA fallback — all unknown routes return index.html
location / {
try_files $uri $uri/ /index.html;
}

# Proxy API calls to FastAPI backend
location /api/ {
proxy_pass http://backend:3001;
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 Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 120s;
proxy_send_timeout 120s;
}

# Static asset cache
location ~* \.(js|css|png|svg|ico|woff2|woff|ttf|webmanifest)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}

# Service worker must not be cached
location = /sw.js {
add_header Cache-Control "no-cache";
}
}
57 changes: 33 additions & 24 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,35 +1,44 @@

.git
.gitignore
.github
.venv
**/__pycache__
**/*.pyc
**/*.pyo
**/*.pyd
engine/logs/
__pycache__
*.pyc
*.pyo
*.pyd
*.egg-info
.pytest_cache
.ruff_cache
dist/
build/
*.egg
node_modules
frontend/node_modules
.npm-cache
frontend/.vite
frontend/dist

# Model weights
*.pt
*.bin
models/

# Windows build artifacts
*.exe
frontend/.vite
*.npm-cache
.npmignore
*.o
*.a
*.so
*.dylib
quadtrix.exe
*.png
*.jpg
*.jpeg
*.md
LICENSE
contributing.md
SECURITY.md
run.md
quadtrix
build/
cmake-build-*/
.vscode
*.bin
*.pt
*.gguf
*.safetensors
engine/best_model.pt
engine/logs/
engine/fineweb_30mb.txt
data/input.txt
.DS_Store
Thumbs.db
*.swp
*.swo
.idea
.vscode
docker-compose.override.yml
Loading
Loading