Spaces:
Running
Running
Commit
·
74effde
1
Parent(s):
cb01b8b
hf test
Browse files- .dockerignore +59 -0
- Dockerfile +38 -0
- app.py +14 -0
- docker-compose.yml +24 -0
.dockerignore
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Python
|
2 |
+
__pycache__/
|
3 |
+
*.py[cod]
|
4 |
+
*$py.class
|
5 |
+
*.so
|
6 |
+
.Python
|
7 |
+
build/
|
8 |
+
develop-eggs/
|
9 |
+
dist/
|
10 |
+
downloads/
|
11 |
+
eggs/
|
12 |
+
.eggs/
|
13 |
+
lib/
|
14 |
+
lib64/
|
15 |
+
parts/
|
16 |
+
sdist/
|
17 |
+
var/
|
18 |
+
wheels/
|
19 |
+
*.egg-info/
|
20 |
+
.installed.cfg
|
21 |
+
*.egg
|
22 |
+
|
23 |
+
# Virtual environments
|
24 |
+
venv/
|
25 |
+
env/
|
26 |
+
ENV/
|
27 |
+
|
28 |
+
# IDE
|
29 |
+
.vscode/
|
30 |
+
.idea/
|
31 |
+
*.swp
|
32 |
+
*.swo
|
33 |
+
|
34 |
+
# OS
|
35 |
+
.DS_Store
|
36 |
+
Thumbs.db
|
37 |
+
|
38 |
+
# Git
|
39 |
+
.git/
|
40 |
+
.gitignore
|
41 |
+
|
42 |
+
# Credentials and secrets
|
43 |
+
credentials.json
|
44 |
+
.env
|
45 |
+
*.pem
|
46 |
+
*.key
|
47 |
+
|
48 |
+
# Logs
|
49 |
+
*.log
|
50 |
+
logs/
|
51 |
+
|
52 |
+
# Documentation
|
53 |
+
README.md
|
54 |
+
docs/
|
55 |
+
|
56 |
+
# Docker
|
57 |
+
Dockerfile
|
58 |
+
.dockerignore
|
59 |
+
docker-compose.yml
|
Dockerfile
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.11-slim
|
2 |
+
|
3 |
+
# Set working directory
|
4 |
+
WORKDIR /app
|
5 |
+
|
6 |
+
# Install system dependencies
|
7 |
+
RUN apt-get update && apt-get install -y \
|
8 |
+
gcc \
|
9 |
+
curl \
|
10 |
+
&& rm -rf /var/lib/apt/lists/*
|
11 |
+
|
12 |
+
# Copy requirements first for better caching
|
13 |
+
COPY requirements.txt .
|
14 |
+
|
15 |
+
# Install Python dependencies
|
16 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
17 |
+
|
18 |
+
# Copy application code
|
19 |
+
COPY . .
|
20 |
+
|
21 |
+
# Create non-root user for security
|
22 |
+
RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app
|
23 |
+
USER appuser
|
24 |
+
|
25 |
+
# Expose ports (8888 for compatibility, 7860 for Hugging Face)
|
26 |
+
EXPOSE 8888 7860
|
27 |
+
|
28 |
+
# Set environment variables
|
29 |
+
ENV PYTHONPATH=/app
|
30 |
+
ENV HOST=0.0.0.0
|
31 |
+
ENV PORT=7860
|
32 |
+
|
33 |
+
# Health check (use PORT environment variable)
|
34 |
+
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
35 |
+
CMD curl -f http://localhost:${PORT}/health || exit 1
|
36 |
+
|
37 |
+
# Run the application using app.py (Hugging Face compatible entry point)
|
38 |
+
CMD ["python", "app.py"]
|
app.py
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
Hugging Face Spaces entry point.
|
3 |
+
This file is required for Hugging Face Spaces deployment.
|
4 |
+
"""
|
5 |
+
from src.main import app
|
6 |
+
|
7 |
+
# Hugging Face Spaces will automatically run this app
|
8 |
+
if __name__ == "__main__":
|
9 |
+
import uvicorn
|
10 |
+
import os
|
11 |
+
|
12 |
+
host = os.getenv("HOST", "0.0.0.0")
|
13 |
+
port = int(os.getenv("PORT", "7860"))
|
14 |
+
uvicorn.run(app, host=host, port=port)
|
docker-compose.yml
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
version: '3.8'
|
2 |
+
|
3 |
+
services:
|
4 |
+
geminicli2api:
|
5 |
+
build: .
|
6 |
+
ports:
|
7 |
+
- "${PORT:-8888}:${PORT:-8888}"
|
8 |
+
environment:
|
9 |
+
- GEMINI_AUTH_PASSWORD=${GEMINI_AUTH_PASSWORD:-your_password_here}
|
10 |
+
- GEMINI_CREDENTIALS=${GEMINI_CREDENTIALS:-}
|
11 |
+
- GOOGLE_CLOUD_PROJECT=${GOOGLE_CLOUD_PROJECT:-}
|
12 |
+
- GOOGLE_APPLICATION_CREDENTIALS=${GOOGLE_APPLICATION_CREDENTIALS:-}
|
13 |
+
- HOST=${HOST:-0.0.0.0}
|
14 |
+
- PORT=${PORT:-8888}
|
15 |
+
volumes:
|
16 |
+
# Optional: Mount credentials file if using file-based auth
|
17 |
+
- ${GOOGLE_APPLICATION_CREDENTIALS:-/dev/null}:/app/${GOOGLE_APPLICATION_CREDENTIALS:-oauth_creds.json}:ro
|
18 |
+
restart: unless-stopped
|
19 |
+
healthcheck:
|
20 |
+
test: ["CMD", "sh", "-c", "curl -f http://localhost:${PORT:-8888}/health"]
|
21 |
+
interval: 30s
|
22 |
+
timeout: 10s
|
23 |
+
retries: 3
|
24 |
+
start_period: 40s
|