Spaces:
Sleeping
Sleeping
Commit ·
ef2dce7
1
Parent(s): 7b9f847
Harden Docker runtime and align deployment docs for phase 2
Browse files- .dockerignore +6 -0
- Dockerfile +12 -1
- README.md +13 -9
.dockerignore
CHANGED
|
@@ -7,3 +7,9 @@ __pycache__/
|
|
| 7 |
.env
|
| 8 |
.git/
|
| 9 |
.gitignore
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
.env
|
| 8 |
.git/
|
| 9 |
.gitignore
|
| 10 |
+
Synapse_Code_Auditor/
|
| 11 |
+
.pytest_cache/
|
| 12 |
+
.mypy_cache/
|
| 13 |
+
.ruff_cache/
|
| 14 |
+
.vscode/
|
| 15 |
+
.idea/
|
Dockerfile
CHANGED
|
@@ -4,14 +4,25 @@ ENV PYTHONDONTWRITEBYTECODE=1
|
|
| 4 |
ENV PYTHONUNBUFFERED=1
|
| 5 |
ENV PORT=7860
|
| 6 |
ENV PIP_DEFAULT_TIMEOUT=240
|
|
|
|
| 7 |
|
| 8 |
WORKDIR /app
|
| 9 |
|
|
|
|
|
|
|
| 10 |
COPY requirements.txt ./
|
| 11 |
-
RUN pip install --no-cache-dir --
|
|
|
|
| 12 |
|
| 13 |
COPY . .
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
EXPOSE 7860
|
| 16 |
|
|
|
|
|
|
|
|
|
|
| 17 |
CMD ["sh", "-c", "uvicorn app.main:app --host 0.0.0.0 --port ${PORT:-7860}"]
|
|
|
|
| 4 |
ENV PYTHONUNBUFFERED=1
|
| 5 |
ENV PORT=7860
|
| 6 |
ENV PIP_DEFAULT_TIMEOUT=240
|
| 7 |
+
ENV PIP_DISABLE_PIP_VERSION_CHECK=1
|
| 8 |
|
| 9 |
WORKDIR /app
|
| 10 |
|
| 11 |
+
RUN useradd -m -u 1000 appuser
|
| 12 |
+
|
| 13 |
COPY requirements.txt ./
|
| 14 |
+
RUN pip install --no-cache-dir --upgrade pip \
|
| 15 |
+
&& pip install --no-cache-dir --retries 10 -r requirements.txt
|
| 16 |
|
| 17 |
COPY . .
|
| 18 |
|
| 19 |
+
RUN chown -R appuser:appuser /app
|
| 20 |
+
|
| 21 |
+
USER appuser
|
| 22 |
+
|
| 23 |
EXPOSE 7860
|
| 24 |
|
| 25 |
+
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
|
| 26 |
+
CMD python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:7860/health', timeout=3)"
|
| 27 |
+
|
| 28 |
CMD ["sh", "-c", "uvicorn app.main:app --host 0.0.0.0 --port ${PORT:-7860}"]
|
README.md
CHANGED
|
@@ -22,7 +22,12 @@ Software teams use code review to catch bugs, improve quality, and enforce maint
|
|
| 22 |
|
| 23 |
```text
|
| 24 |
.
|
|
|
|
|
|
|
|
|
|
| 25 |
├── inference.py
|
|
|
|
|
|
|
| 26 |
├── validate_submission.py
|
| 27 |
├── app/
|
| 28 |
│ ├── __init__.py
|
|
@@ -148,7 +153,7 @@ curl -X POST http://localhost:7860/reset -H "Content-Type: application/json" -d
|
|
| 148 |
|
| 149 |
The baseline runner is `inference.py` at the project root. It uses the OpenAI client and executes all 3 tasks.
|
| 150 |
|
| 151 |
-
Required environment variables:
|
| 152 |
|
| 153 |
- API_BASE_URL: OpenAI-compatible API URL
|
| 154 |
- MODEL_NAME: model identifier
|
|
@@ -158,6 +163,8 @@ Optional:
|
|
| 158 |
|
| 159 |
- ENV_BASE_URL: environment API base URL (default http://localhost:7860)
|
| 160 |
- DRY_RUN: set to `1` to skip external LLM calls and use deterministic local responses
|
|
|
|
|
|
|
| 161 |
|
| 162 |
Structured logs:
|
| 163 |
|
|
@@ -197,14 +204,11 @@ Validator checks:
|
|
| 197 |
## Example Baseline Output
|
| 198 |
|
| 199 |
```text
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
- medium: score=1.0000 | Coverage=1.00; Penalty=0.00; Matched=3/3
|
| 206 |
-
- hard: score=0.8000 | Coverage=1.00; Penalty=0.20; Matched=5/5
|
| 207 |
-
Average score: 0.9333
|
| 208 |
```
|
| 209 |
|
| 210 |
## Hugging Face Spaces Deployment
|
|
|
|
| 22 |
|
| 23 |
```text
|
| 24 |
.
|
| 25 |
+
├── server/
|
| 26 |
+
│ ├── __init__.py
|
| 27 |
+
│ └── app.py
|
| 28 |
├── inference.py
|
| 29 |
+
├── pyproject.toml
|
| 30 |
+
├── uv.lock
|
| 31 |
├── validate_submission.py
|
| 32 |
├── app/
|
| 33 |
│ ├── __init__.py
|
|
|
|
| 153 |
|
| 154 |
The baseline runner is `inference.py` at the project root. It uses the OpenAI client and executes all 3 tasks.
|
| 155 |
|
| 156 |
+
Required environment variables for non-dry-run execution:
|
| 157 |
|
| 158 |
- API_BASE_URL: OpenAI-compatible API URL
|
| 159 |
- MODEL_NAME: model identifier
|
|
|
|
| 163 |
|
| 164 |
- ENV_BASE_URL: environment API base URL (default http://localhost:7860)
|
| 165 |
- DRY_RUN: set to `1` to skip external LLM calls and use deterministic local responses
|
| 166 |
+
- API_BASE_URL: defaults to https://api.openai.com/v1 when not provided
|
| 167 |
+
- MODEL_NAME: defaults to gpt-4o-mini when not provided
|
| 168 |
|
| 169 |
Structured logs:
|
| 170 |
|
|
|
|
| 204 |
## Example Baseline Output
|
| 205 |
|
| 206 |
```text
|
| 207 |
+
[START] {"event":"run_started","env_base_url":"inprocess","task_count":3,"dry_run":true}
|
| 208 |
+
[STEP] {"event":"task_completed","index":1,"task_id":"easy","score":1.0}
|
| 209 |
+
[STEP] {"event":"task_completed","index":2,"task_id":"medium","score":1.0}
|
| 210 |
+
[STEP] {"event":"task_completed","index":3,"task_id":"hard","score":0.9}
|
| 211 |
+
[END] {"event":"run_finished","average_score":0.9667,"status":"ok"}
|
|
|
|
|
|
|
|
|
|
| 212 |
```
|
| 213 |
|
| 214 |
## Hugging Face Spaces Deployment
|