Skip to content

Commit 4d36ef3

Browse files
Initial commit
0 parents  commit 4d36ef3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+11816
-0
lines changed

.env.example

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
OPEN_ROUTER_API_KEY=YOUR_API_KEY
2+
3+
# For TEE deployment only
4+
TEE_IMAGE_REFERENCE=ghcr.io/flare-research/flare-ai-consensus:main
5+
INSTANCE_NAME=PROJECT_NAME-TEAM-_NAME
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Build and Push
2+
3+
on:
4+
push:
5+
# tags: ["v*.*.*"] # Match semantic versioning tags like v1.0.0
6+
branches: ["main"]
7+
workflow_dispatch: # Allow manual triggering of the workflow
8+
9+
env:
10+
REGISTRY: ghcr.io
11+
IMAGE_NAME: ${{ github.repository }}
12+
13+
jobs:
14+
build-and-push:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
18+
packages: write
19+
attestations: write
20+
id-token: write
21+
steps:
22+
# Checkout repository
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
25+
26+
# Log in to GHCR
27+
- name: Login to GitHub Container Registry
28+
uses: docker/login-action@v3
29+
with:
30+
registry: ${{ env.REGISTRY }}
31+
username: ${{ github.actor }}
32+
password: ${{ secrets.GITHUB_TOKEN }}
33+
34+
# Generate Docker metadata
35+
- name: Metadata for Docker
36+
id: meta
37+
uses: docker/metadata-action@v5
38+
with:
39+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
40+
41+
# Cache Docker layers to speed up builds
42+
- name: Cache Docker layers
43+
uses: actions/cache@v3
44+
with:
45+
path: /tmp/.buildx-cache
46+
key: ${{ runner.os }}-docker-${{ github.ref }}
47+
restore-keys: |
48+
${{ runner.os }}-docker-
49+
50+
# Build and push Docker image
51+
- name: Build and push Docker image
52+
uses: docker/build-push-action@v6
53+
id: push
54+
with:
55+
context: .
56+
push: true
57+
load: true
58+
tags: ${{ steps.meta.outputs.tags }}
59+
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/lint.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
branches: ["main"]
8+
9+
jobs:
10+
lint:
11+
runs-on: "ubuntu-latest"
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
16+
# Set up Python environment
17+
- name: Set up uv
18+
uses: astral-sh/setup-uv@v5
19+
with:
20+
version: "latest"
21+
22+
# Install dependencies
23+
- name: Install dependencies
24+
run: uv sync --frozen --all-extras
25+
26+
# Format code with ruff
27+
- name: Format with ruff
28+
run: uv run ruff format --diff
29+
30+
# Lint code with ruff
31+
- name: Lint with ruff
32+
run: uv run ruff check --diff
33+
continue-on-error: false
34+
35+
# Type check with pyright
36+
- name: Type check with pyright
37+
run: uv run pyright

.gitignore

Lines changed: 268 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,268 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.nox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
*.py,cover
50+
.hypothesis/
51+
.pytest_cache/
52+
cover/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
.pybuilder/
76+
target/
77+
78+
# Jupyter Notebook
79+
.ipynb_checkpoints
80+
81+
# IPython
82+
profile_default/
83+
ipython_config.py
84+
85+
# pyenv
86+
# For a library or package, you might want to ignore these files since the code is
87+
# intended to run in multiple environments; otherwise, check them in:
88+
# .python-version
89+
90+
# pipenv
91+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
93+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
94+
# install all needed dependencies.
95+
#Pipfile.lock
96+
97+
# poetry
98+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99+
# This is especially recommended for binary packages to ensure reproducibility, and is more
100+
# commonly ignored for libraries.
101+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102+
#poetry.lock
103+
104+
# pdm
105+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106+
#pdm.lock
107+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108+
# in version control.
109+
# https://pdm.fming.dev/#use-with-ide
110+
.pdm.toml
111+
112+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
113+
__pypackages__/
114+
115+
# Celery stuff
116+
celerybeat-schedule
117+
celerybeat.pid
118+
119+
# SageMath parsed files
120+
*.sage.py
121+
122+
# Environments
123+
.env
124+
.venv
125+
env/
126+
venv/
127+
ENV/
128+
env.bak/
129+
venv.bak/
130+
131+
# Spyder project settings
132+
.spyderproject
133+
.spyproject
134+
135+
# Rope project settings
136+
.ropeproject
137+
138+
# mkdocs documentation
139+
/site
140+
141+
# mypy
142+
.mypy_cache/
143+
.dmypy.json
144+
dmypy.json
145+
146+
# Pyre type checker
147+
.pyre/
148+
149+
# pytype static type analyzer
150+
.pytype/
151+
152+
# Cython debug symbols
153+
cython_debug/
154+
155+
# PyCharm
156+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
157+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
158+
# and can be added to the global gitignore or merged into this file. For a more nuclear
159+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
160+
#.idea/
161+
162+
# Images
163+
# *.jpg
164+
!docs/images/*
165+
*.pdf
166+
*.svg
167+
# *.jpeg
168+
# *.png
169+
*.bmp
170+
171+
### VirtualEnv template
172+
# Virtualenv
173+
# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/
174+
[Bb]in
175+
[Ii]nclude
176+
[Ll]ib
177+
[Ll]ib64
178+
[Ll]ocal
179+
[Ss]cripts
180+
pyvenv.cfg
181+
pip-selfcheck.json
182+
183+
### JetBrains template
184+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
185+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
186+
187+
# User-specific stuff
188+
.idea/**/workspace.xml
189+
.idea/**/tasks.xml
190+
.idea/**/usage.statistics.xml
191+
.idea/**/dictionaries
192+
.idea/**/shelf
193+
194+
# AWS User-specific
195+
.idea/**/aws.xml
196+
197+
# Generated files
198+
.idea/**/contentModel.xml
199+
200+
# Sensitive or high-churn files
201+
.idea/**/dataSources/
202+
.idea/**/dataSources.ids
203+
.idea/**/dataSources.local.xml
204+
.idea/**/sqlDataSources.xml
205+
.idea/**/dynamic.xml
206+
.idea/**/uiDesigner.xml
207+
.idea/**/dbnavigator.xml
208+
209+
# Gradle
210+
.idea/**/gradle.xml
211+
.idea/**/libraries
212+
213+
# Gradle and Maven with auto-import
214+
# When using Gradle or Maven with auto-import, you should exclude module files,
215+
# since they will be recreated, and may cause churn. Uncomment if using
216+
# auto-import.
217+
# .idea/artifacts
218+
# .idea/compiler.xml
219+
# .idea/jarRepositories.xml
220+
# .idea/modules.xml
221+
# .idea/*.iml
222+
# .idea/modules
223+
# *.iml
224+
# *.ipr
225+
226+
# CMake
227+
cmake-build-*/
228+
229+
# Mongo Explorer plugin
230+
.idea/**/mongoSettings.xml
231+
232+
# File-based project format
233+
*.iws
234+
235+
# IntelliJ
236+
out/
237+
238+
# mpeltonen/sbt-idea plugin
239+
.idea_modules/
240+
241+
# JIRA plugin
242+
atlassian-ide-plugin.xml
243+
244+
# Cursive Clojure plugin
245+
.idea/replstate.xml
246+
247+
# SonarLint plugin
248+
.idea/sonarlint/
249+
250+
# Crashlytics plugin (for Android Studio and IntelliJ)
251+
com_crashlytics_export_strings.xml
252+
crashlytics.properties
253+
crashlytics-build.properties
254+
fabric.properties
255+
256+
# Editor-based Rest Client
257+
.idea/httpRequests
258+
259+
# Android studio 3.1+ serialized cache file
260+
.idea/caches/build_file_checksums.ser
261+
262+
# idea folder, uncomment if you don't need it
263+
.idea
264+
265+
*.csv
266+
.DS_Store
267+
.ruff_cache/
268+
final_consensus.json

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.12

Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Stage 1: Build Backend
2+
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim AS backend-builder
3+
ADD . /flare-ai-consensus
4+
WORKDIR /flare-ai-consensus
5+
RUN uv sync --frozen
6+
7+
# Stage 2: Final Image
8+
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim
9+
10+
WORKDIR /app
11+
COPY --from=backend-builder /flare-ai-consensus/.venv ./.venv
12+
COPY --from=backend-builder /flare-ai-consensus/src ./src
13+
COPY --from=backend-builder /flare-ai-consensus/pyproject.toml .
14+
COPY --from=backend-builder /flare-ai-consensus/README.md .
15+
16+
# Allow workload operator to override environment variables
17+
LABEL "tee.launch_policy.allow_env_override"="OPEN_ROUTER_API_KEY"
18+
LABEL "tee.launch_policy.log_redirect"="always"
19+
20+
EXPOSE 80
21+
22+
CMD ["uv", "run", "start-backend"]

0 commit comments

Comments
 (0)