Commit
·
18e8736
1
Parent(s):
8768feb
update root path
Browse files- .env.new +0 -45
- Dockerfile +0 -2
- README-Docker.md +0 -121
- docker-compose-fixed.yml +0 -39
- docker-compose-simple.yml +0 -27
- gcp_auth.py +0 -74
- mysite/routers/gradio.py +3 -1
- start.ps1 +0 -30
- stop.ps1 +0 -20
- test_docker_config.py +0 -120
.env.new
CHANGED
@@ -1,45 +0,0 @@
|
|
1 |
-
# Groq API Configuration (from README.md)
|
2 |
-
OPENAI_API_BASE=https://api.groq.com/openai/v1
|
3 |
-
OPENAI_API_KEY=your_api_key_here
|
4 |
-
MODEL_NAME=llama3-8b-8192
|
5 |
-
LOCAL_MODEL=true
|
6 |
-
|
7 |
-
# Gradio Configuration
|
8 |
-
GRADIO_SERVER_NAME=0.0.0.0
|
9 |
-
GRADIO_SERVER_PORT=7860
|
10 |
-
|
11 |
-
# Database Configuration (if needed)
|
12 |
-
DATABASE_URL=postgresql://postgres:postgres@postgres:5432/gradio_app
|
13 |
-
|
14 |
-
# Django Configuration
|
15 |
-
DJANGO_SECRET_KEY=your-secret-key-here
|
16 |
-
DJANGO_DEBUG=False
|
17 |
-
DJANGO_ALLOWED_HOSTS=localhost,127.0.0.1,0.0.0.0
|
18 |
-
|
19 |
-
# Google Cloud Configuration (Base64 encoded to avoid issues)
|
20 |
-
GOOGLE_APPLICATION_CREDENTIALS_CONTENT={"type":"service_account","project_id":"urlounge74620","private_key_id":"f24a8ae1770ddebd6ce9a0d113f605496227745e","private_key":"-----BEGIN PRIVATE KEY-----\nMIIEugIBADANBgkqhkiG9w0BAQEFAASCBKQwggSgAgEAAoIBAQC3XR4hg/vKb2MV\nVn3XX2n826kbOrZw3nqS/SUDqi084yJAqaHbbJR+ht8axsjBmltXL2mninpQSHJI\n4OCfoxNLOpSKe2cySYdDbtASHDpIRH/A8rnW0GAVoD5MBkxmQ5WEmyo6+vJAg8Rq\nuzXEfNPDangim9mJ5n7Egy/PU84kNh3G7DBti20/5rFr7YHS5rhuwisdB5zD7Rri\n9HEoBU1oRDlZBUuFMuQa7cgGUMC70MF7+ghgzxAThgh216fo5wrjdv13GtJX1Qlp\n6xMoxacscHzukPp1G/Mzb8aPLoO/GmyPxCIAF7pyU9U34V8gLSHKH5I6SdiCO0bN\nI89JKsZ3AgMBAAECgf8IlxolLIsqByDOgJlMY/0Cs+IV4LJjSxBq1nzMhcntYqBy\nds/f9OdGVZ1jBt+PA6EMVlmvrB+vTslULZCvweI91cSceQs6AMNiVRWhpBaRZ7wm\nYjtsJ+41K2jJFjGdznr+9AVdZEpcq2eApe50k8c4PlDdWkfqE2UpbF8AMOUoay1T\nafwo2xdfD5xquFcrwzZ8DYOosUQijIi99dquCeNKbYRe4lZMebV/QVzdVL6uSsYZ\ntOUAV0wQ3eC98XfNF9Bg61eTGCMwcaKDEJkgS/hqFZf6LndRHGNYksKyb1d+/OMv\n0eSuviqNsTubwzBvUTD+lUbjjV5dBRVBnVPeSPUCgYEA+qfFjl7w1Typ8ipIF51k\nKTP+h3cfNy0zMmuig4uFgDRhw+X/eJKWdFJTaaIqLPbynzBKmll992Cyf9owZypN\nvxC43geEtoK3UBWFkvbrQpFNBasHACM4ovf9ykOd63vZvbDqGv7n+E3CWHVD2Wlp\nxBqOAK7kM2QWkQS2CBOhjQsCgYEAu0YHGGvSxc7ubIs1YI4MtyRE2FNIgneBus+Y\nlrK0r9hkeLmtXtTVUjescbXKP0J/e3sqL7jFFBlPbUfl2hQClOHxpvC9W801B2ht\nB0bKuqLcqAF360LxQVasR14EC6vSrjY9tdawYzwFLkCDMMUJDSFN1RCPwkPSxIrq\nWy5P18UCgYBx5NgEuCkwi28hZYr6h/7iJgkK3trlRHmV+IiQw033ElY2IIUz8U/C\nLUJPpmsJoXBfWx8bAX0Wce7J34fM6NEI9305DiuEjuLi1dSrEd2WktVvtOXqbxam\nHo9IX+8a+FzZL9FAUQFwt0yOy0H4QUjY3cQWlWGF5H3IiV55TwpCPwKBgBH/Jsto\nATdVLYBs2FJRFFO9PohzaHJxPZxQOt+wiMClUPJxFYIZfe6Kvx2mVKtDnrClI2a2\noOnPjNx5nlMYvS7Fj811MR1TWRc/J8sdOHo7EG1sxrNrGXgn9iJdnJHqjzKCr+d7\nDPNHspVFMZpCPekDbC+CLKoheaxWtgsWSvpAoGACOoyu3gMv29eh+6wMsA9Qhsb\nhkbAl8oUQyEh1O45D/bbcYJTm8Ue98m8csIRYRdUWDm/DxeJD9v+uUZwVkMK1bNQ\nuJyWFtVdRwsf5jnbD11gPs4LZyW/ZvJKtiiBtWPqeK0gSPqKP1HY2TYvLIsBlSOY\nc2/xwB1+HB+TfuZwItM=\n-----END PRIVATE KEY-----\n","client_email":"t-louge@urlounge74620.iam.gserviceaccount.com","client_id":"113873685578046298528","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_x509_cert_url":"https://www.googleapis.com/robot/v1/metadata/x509/t-louge%40urlounge74620.iam.gserviceaccount.com","universe_domain":"googleapis.com"}
|
21 |
-
GOOGLE_PROJECT_ID=urlounge74620
|
22 |
-
GOOGLE_CLIENT_EMAIL=t-louge@urlounge74620.iam.gserviceaccount.com
|
23 |
-
|
24 |
-
# Additional Environment Variables
|
25 |
-
APPSHEET_APPID=YOUR_VALUE_HERE
|
26 |
-
APPSHEET_KEY=YOUR_VALUE_HERE
|
27 |
-
ASSSHEET_APPID=YOUR_VALUE_HERE
|
28 |
-
ChannelAccessToken=YOUR_VALUE_HERE
|
29 |
-
ChannelID=YOUR_VALUE_HERE
|
30 |
-
ChannelSecret=YOUR_VALUE_HERE
|
31 |
-
WEBHOOK_GAS=YOUR_VALUE_HERE
|
32 |
-
WEBHOOK_URL=YOUR_VALUE_HERE
|
33 |
-
api_key=YOUR_VALUE_HERE
|
34 |
-
chat_url=YOUR_VALUE_HERE
|
35 |
-
hf_token=YOUR_VALUE_HERE
|
36 |
-
n8nhook=YOUR_VALUE_HERE
|
37 |
-
openinterpreter_secret=YOUR_VALUE_HERE
|
38 |
-
postgre_host=YOUR_VALUE_HERE
|
39 |
-
postgre_pass=YOUR_VALUE_HERE
|
40 |
-
postgre_url=YOUR_VALUE_HERE
|
41 |
-
postgre_user=YOUR_VALUE_HERE
|
42 |
-
token=YOUR_VALUE_HERE
|
43 |
-
github_user=YOUR_VALUE_HERE
|
44 |
-
github_token=YOUR_VALUE_HERE
|
45 |
-
TOOL_KIT_DIR=usage
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Dockerfile
CHANGED
@@ -14,7 +14,6 @@ RUN apt-get update && apt-get install -y \
|
|
14 |
g++ \
|
15 |
curl \
|
16 |
git \
|
17 |
-
jq \
|
18 |
&& rm -rf /var/lib/apt/lists/*
|
19 |
|
20 |
# Copy requirements first for better caching
|
@@ -23,7 +22,6 @@ COPY requirements.txt .
|
|
23 |
# Install Python dependencies
|
24 |
RUN pip install --no-cache-dir --upgrade pip && \
|
25 |
pip install --no-cache-dir gradio==4.29.0 && \
|
26 |
-
pip install --no-cache-dir google-cloud-storage google-auth google-auth-oauthlib google-auth-httplib2 && \
|
27 |
pip install --no-cache-dir -r requirements.txt
|
28 |
|
29 |
# Copy the application code
|
|
|
14 |
g++ \
|
15 |
curl \
|
16 |
git \
|
|
|
17 |
&& rm -rf /var/lib/apt/lists/*
|
18 |
|
19 |
# Copy requirements first for better caching
|
|
|
22 |
# Install Python dependencies
|
23 |
RUN pip install --no-cache-dir --upgrade pip && \
|
24 |
pip install --no-cache-dir gradio==4.29.0 && \
|
|
|
25 |
pip install --no-cache-dir -r requirements.txt
|
26 |
|
27 |
# Copy the application code
|
README-Docker.md
CHANGED
@@ -1,121 +0,0 @@
|
|
1 |
-
# 🦀 Gradio FastAPI Django Main - Docker Setup
|
2 |
-
|
3 |
-
Based on the configuration in README.md:
|
4 |
-
- **Title**: Gradio fastapi_django_main
|
5 |
-
- **Emoji**: 🦀
|
6 |
-
- **SDK**: Gradio 4.29.0
|
7 |
-
- **App File**: app.py
|
8 |
-
|
9 |
-
## Quick Start
|
10 |
-
|
11 |
-
### Prerequisites
|
12 |
-
- Docker Desktop installed and running
|
13 |
-
- PowerShell (Windows) or Bash (Linux/macOS)
|
14 |
-
|
15 |
-
### 🚀 Start Application
|
16 |
-
```powershell
|
17 |
-
# Windows
|
18 |
-
.\start.ps1
|
19 |
-
|
20 |
-
# Or manually:
|
21 |
-
docker-compose up --build -d
|
22 |
-
```
|
23 |
-
|
24 |
-
### 🛑 Stop Application
|
25 |
-
```powershell
|
26 |
-
# Windows
|
27 |
-
.\stop.ps1
|
28 |
-
|
29 |
-
# Or manually:
|
30 |
-
docker-compose down
|
31 |
-
```
|
32 |
-
|
33 |
-
## Configuration
|
34 |
-
|
35 |
-
### Environment Variables
|
36 |
-
Copy `.env.example` to `.env` and update the values:
|
37 |
-
|
38 |
-
```bash
|
39 |
-
# Groq API Configuration
|
40 |
-
OPENAI_API_BASE=https://api.groq.com/openai/v1
|
41 |
-
OPENAI_API_KEY=your_actual_api_key_here
|
42 |
-
MODEL_NAME=llama3-8b-8192
|
43 |
-
LOCAL_MODEL=true
|
44 |
-
|
45 |
-
# Gradio Configuration
|
46 |
-
GRADIO_SERVER_NAME=0.0.0.0
|
47 |
-
GRADIO_SERVER_PORT=7860
|
48 |
-
```
|
49 |
-
|
50 |
-
## Services
|
51 |
-
|
52 |
-
### Main Application
|
53 |
-
- **Container**: `gradio-fastapi-django-main`
|
54 |
-
- **Port**: 7860
|
55 |
-
- **URL**: http://localhost:7860
|
56 |
-
|
57 |
-
### Features
|
58 |
-
- Gradio 4.29.0 Web Interface
|
59 |
-
- FastAPI Backend
|
60 |
-
- Django Integration
|
61 |
-
- Groq API Support
|
62 |
-
- Health Checks
|
63 |
-
- Auto-restart on failure
|
64 |
-
|
65 |
-
## Docker Commands
|
66 |
-
|
67 |
-
```bash
|
68 |
-
# Build only
|
69 |
-
docker-compose build
|
70 |
-
|
71 |
-
# Start in foreground (see logs)
|
72 |
-
docker-compose up
|
73 |
-
|
74 |
-
# Start in background
|
75 |
-
docker-compose up -d
|
76 |
-
|
77 |
-
# View logs
|
78 |
-
docker-compose logs -f
|
79 |
-
|
80 |
-
# Check status
|
81 |
-
docker-compose ps
|
82 |
-
|
83 |
-
# Stop and remove
|
84 |
-
docker-compose down
|
85 |
-
|
86 |
-
# Rebuild and start
|
87 |
-
docker-compose up --build
|
88 |
-
|
89 |
-
# Clean up everything
|
90 |
-
docker-compose down -v --remove-orphans
|
91 |
-
docker system prune -f
|
92 |
-
```
|
93 |
-
|
94 |
-
## Troubleshooting
|
95 |
-
|
96 |
-
### Container won't start
|
97 |
-
1. Check Docker Desktop is running
|
98 |
-
2. Check logs: `docker-compose logs`
|
99 |
-
3. Verify `.env` file exists and has correct values
|
100 |
-
4. Ensure port 7860 is not in use
|
101 |
-
|
102 |
-
### API Key Issues
|
103 |
-
1. Update `OPENAI_API_KEY` in `.env` file
|
104 |
-
2. Restart containers: `docker-compose restart`
|
105 |
-
|
106 |
-
### Performance Issues
|
107 |
-
1. Allocate more memory to Docker Desktop
|
108 |
-
2. Check container resources: `docker stats`
|
109 |
-
|
110 |
-
## Development
|
111 |
-
|
112 |
-
### Local Development with Docker
|
113 |
-
```bash
|
114 |
-
# Mount source code for live reloading
|
115 |
-
docker-compose -f docker-compose.dev.yml up
|
116 |
-
```
|
117 |
-
|
118 |
-
### Access Container Shell
|
119 |
-
```bash
|
120 |
-
docker-compose exec gradio-fastapi-django bash
|
121 |
-
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
docker-compose-fixed.yml
CHANGED
@@ -1,39 +0,0 @@
|
|
1 |
-
version: '3.8'
|
2 |
-
|
3 |
-
services:
|
4 |
-
gradio-fastapi-django:
|
5 |
-
build:
|
6 |
-
context: .
|
7 |
-
dockerfile: Dockerfile
|
8 |
-
container_name: gradio-fastapi-django-main
|
9 |
-
ports:
|
10 |
-
- "7860:7860"
|
11 |
-
environment:
|
12 |
-
- PYTHONUNBUFFERED=1
|
13 |
-
- GRADIO_SERVER_NAME=0.0.0.0
|
14 |
-
- GRADIO_SERVER_PORT=7860
|
15 |
-
- OPENAI_API_BASE=${OPENAI_API_BASE:-https://api.groq.com/openai/v1}
|
16 |
-
- OPENAI_API_KEY=${OPENAI_API_KEY}
|
17 |
-
- MODEL_NAME=${MODEL_NAME:-llama3-8b-8192}
|
18 |
-
- LOCAL_MODEL=${LOCAL_MODEL:-true}
|
19 |
-
- GOOGLE_APPLICATION_CREDENTIALS_CONTENT=${GOOGLE_APPLICATION_CREDENTIALS_CONTENT}
|
20 |
-
- GOOGLE_PROJECT_ID=${GOOGLE_PROJECT_ID}
|
21 |
-
- GOOGLE_CLIENT_EMAIL=${GOOGLE_CLIENT_EMAIL}
|
22 |
-
volumes:
|
23 |
-
- ./cache:/app/cache
|
24 |
-
- ./gradio_cached_examples:/app/gradio_cached_examples
|
25 |
-
- ./static:/app/static
|
26 |
-
- ./templates:/app/templates
|
27 |
-
restart: unless-stopped
|
28 |
-
healthcheck:
|
29 |
-
test: ["CMD", "curl", "-f", "http://localhost:7860/health"]
|
30 |
-
interval: 30s
|
31 |
-
timeout: 10s
|
32 |
-
retries: 3
|
33 |
-
start_period: 30s
|
34 |
-
networks:
|
35 |
-
- gradio-network
|
36 |
-
|
37 |
-
networks:
|
38 |
-
gradio-network:
|
39 |
-
driver: bridge
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
docker-compose-simple.yml
CHANGED
@@ -1,27 +0,0 @@
|
|
1 |
-
version: '3.8'
|
2 |
-
|
3 |
-
services:
|
4 |
-
gradio-fastapi-django:
|
5 |
-
build:
|
6 |
-
context: .
|
7 |
-
dockerfile: Dockerfile
|
8 |
-
container_name: gradio-fastapi-django-main
|
9 |
-
ports:
|
10 |
-
- "7860:7860"
|
11 |
-
env_file:
|
12 |
-
- .env
|
13 |
-
volumes:
|
14 |
-
- ./cache:/app/cache
|
15 |
-
- ./static:/app/static
|
16 |
-
- ./templates:/app/templates
|
17 |
-
restart: unless-stopped
|
18 |
-
healthcheck:
|
19 |
-
test: ["CMD", "curl", "-f", "http://localhost:7860/health"]
|
20 |
-
interval: 30s
|
21 |
-
timeout: 10s
|
22 |
-
retries: 3
|
23 |
-
start_period: 30s
|
24 |
-
|
25 |
-
networks:
|
26 |
-
default:
|
27 |
-
driver: bridge
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gcp_auth.py
CHANGED
@@ -1,74 +0,0 @@
|
|
1 |
-
#!/usr/bin/env python3
|
2 |
-
"""
|
3 |
-
Google Cloud Authentication Helper
|
4 |
-
This script handles Google Cloud authentication using environment variables.
|
5 |
-
"""
|
6 |
-
|
7 |
-
import os
|
8 |
-
import json
|
9 |
-
import tempfile
|
10 |
-
from google.auth import default
|
11 |
-
from google.cloud import storage
|
12 |
-
|
13 |
-
|
14 |
-
def setup_gcp_credentials():
|
15 |
-
"""Setup Google Cloud credentials from environment variables."""
|
16 |
-
|
17 |
-
# Get credentials content from environment variable
|
18 |
-
creds_content = os.getenv('GOOGLE_APPLICATION_CREDENTIALS_CONTENT')
|
19 |
-
|
20 |
-
if creds_content:
|
21 |
-
# Parse JSON credentials
|
22 |
-
try:
|
23 |
-
creds_dict = json.loads(creds_content)
|
24 |
-
|
25 |
-
# Create temporary credentials file
|
26 |
-
with tempfile.NamedTemporaryFile(mode='w', suffix='.json', delete=False) as f:
|
27 |
-
json.dump(creds_dict, f)
|
28 |
-
temp_creds_path = f.name
|
29 |
-
|
30 |
-
# Set environment variable for Google Cloud SDK
|
31 |
-
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = temp_creds_path
|
32 |
-
|
33 |
-
print(f"✅ Google Cloud credentials configured successfully")
|
34 |
-
print(f"📁 Project ID: {creds_dict.get('project_id', 'N/A')}")
|
35 |
-
print(f"📧 Client Email: {creds_dict.get('client_email', 'N/A')}")
|
36 |
-
|
37 |
-
return temp_creds_path
|
38 |
-
|
39 |
-
except json.JSONDecodeError as e:
|
40 |
-
print(f"❌ Error parsing Google Cloud credentials: {e}")
|
41 |
-
return None
|
42 |
-
else:
|
43 |
-
print("⚠️ No Google Cloud credentials found in environment variables")
|
44 |
-
return None
|
45 |
-
|
46 |
-
|
47 |
-
def test_gcp_connection():
|
48 |
-
"""Test Google Cloud connection."""
|
49 |
-
try:
|
50 |
-
# Test authentication
|
51 |
-
credentials, project = default()
|
52 |
-
print(f"✅ Google Cloud authentication successful")
|
53 |
-
print(f"📁 Project: {project}")
|
54 |
-
|
55 |
-
# Test Cloud Storage access
|
56 |
-
client = storage.Client()
|
57 |
-
buckets = list(client.list_buckets())
|
58 |
-
print(f"📦 Found {len(buckets)} storage buckets")
|
59 |
-
|
60 |
-
return True
|
61 |
-
except Exception as e:
|
62 |
-
print(f"❌ Google Cloud connection test failed: {e}")
|
63 |
-
return False
|
64 |
-
|
65 |
-
|
66 |
-
if __name__ == "__main__":
|
67 |
-
# Setup credentials
|
68 |
-
creds_path = setup_gcp_credentials()
|
69 |
-
|
70 |
-
if creds_path:
|
71 |
-
# Test connection
|
72 |
-
test_gcp_connection()
|
73 |
-
else:
|
74 |
-
print("❌ Failed to setup Google Cloud credentials")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mysite/routers/gradio.py
CHANGED
@@ -19,7 +19,9 @@ import pkgutil
|
|
19 |
import traceback
|
20 |
|
21 |
def include_gradio_interfaces():
|
22 |
-
|
|
|
|
|
23 |
gradio_interfaces = {} # 辞書型: { interface_name: gradio_interface }
|
24 |
|
25 |
# `controllers/` 以下の全てのサブディレクトリを探索
|
|
|
19 |
import traceback
|
20 |
|
21 |
def include_gradio_interfaces():
|
22 |
+
# プロジェクトルートからcontrollersディレクトリのパスを取得
|
23 |
+
current_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
24 |
+
package_dir = os.path.join(current_dir, "controllers") # `controllers/` 直下を探索
|
25 |
gradio_interfaces = {} # 辞書型: { interface_name: gradio_interface }
|
26 |
|
27 |
# `controllers/` 以下の全てのサブディレクトリを探索
|
start.ps1
CHANGED
@@ -1,30 +0,0 @@
|
|
1 |
-
# Gradio FastAPI Django Main - Docker Compose Start Script
|
2 |
-
# Based on README.md configuration: Gradio 4.29.0, app.py
|
3 |
-
|
4 |
-
Write-Host "🦀 Starting Gradio FastAPI Django Main Application" -ForegroundColor Cyan
|
5 |
-
Write-Host "Emoji: 🦀" -ForegroundColor Yellow
|
6 |
-
Write-Host "SDK: Gradio 4.29.0" -ForegroundColor Green
|
7 |
-
Write-Host "App File: app.py" -ForegroundColor Blue
|
8 |
-
|
9 |
-
# Check if Docker is running
|
10 |
-
if (!(Get-Process "Docker Desktop" -ErrorAction SilentlyContinue)) {
|
11 |
-
Write-Host "❌ Docker Desktop is not running. Please start Docker Desktop first." -ForegroundColor Red
|
12 |
-
exit 1
|
13 |
-
}
|
14 |
-
|
15 |
-
# Build and start the containers
|
16 |
-
Write-Host "🔨 Building and starting containers..." -ForegroundColor Cyan
|
17 |
-
docker-compose up --build -d
|
18 |
-
|
19 |
-
if ($LASTEXITCODE -eq 0) {
|
20 |
-
Write-Host "✅ Application started successfully!" -ForegroundColor Green
|
21 |
-
Write-Host "🌐 Application is running at: http://localhost:7860" -ForegroundColor Blue
|
22 |
-
Write-Host "📊 Container status:" -ForegroundColor Yellow
|
23 |
-
docker-compose ps
|
24 |
-
|
25 |
-
Write-Host "`n📝 To view logs: docker-compose logs -f" -ForegroundColor Cyan
|
26 |
-
Write-Host "🛑 To stop: docker-compose down" -ForegroundColor Cyan
|
27 |
-
} else {
|
28 |
-
Write-Host "❌ Failed to start application. Check the logs:" -ForegroundColor Red
|
29 |
-
docker-compose logs
|
30 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stop.ps1
CHANGED
@@ -1,20 +0,0 @@
|
|
1 |
-
# Gradio FastAPI Django Main - Docker Compose Stop Script
|
2 |
-
|
3 |
-
Write-Host "🛑 Stopping Gradio FastAPI Django Main Application" -ForegroundColor Red
|
4 |
-
|
5 |
-
# Stop and remove containers
|
6 |
-
docker-compose down
|
7 |
-
|
8 |
-
if ($LASTEXITCODE -eq 0) {
|
9 |
-
Write-Host "✅ Application stopped successfully!" -ForegroundColor Green
|
10 |
-
} else {
|
11 |
-
Write-Host "❌ Failed to stop application properly." -ForegroundColor Red
|
12 |
-
}
|
13 |
-
|
14 |
-
# Optional: Remove unused volumes and images
|
15 |
-
$cleanup = Read-Host "Do you want to clean up unused Docker resources? (y/N)"
|
16 |
-
if ($cleanup -eq "y" -or $cleanup -eq "Y") {
|
17 |
-
Write-Host "🧹 Cleaning up Docker resources..." -ForegroundColor Yellow
|
18 |
-
docker system prune -f
|
19 |
-
Write-Host "✅ Cleanup completed!" -ForegroundColor Green
|
20 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test_docker_config.py
CHANGED
@@ -1,120 +0,0 @@
|
|
1 |
-
#!/usr/bin/env python3
|
2 |
-
"""
|
3 |
-
Docker環境設定テストスクリプト
|
4 |
-
README.md仕様: Gradio 4.29.0, 🦀 emoji, app.py
|
5 |
-
"""
|
6 |
-
|
7 |
-
import os
|
8 |
-
import json
|
9 |
-
import sys
|
10 |
-
|
11 |
-
def test_environment_variables():
|
12 |
-
"""環境変数の設定をテスト"""
|
13 |
-
print("🦀 Docker環境設定テスト - Gradio FastAPI Django Main")
|
14 |
-
print("=" * 60)
|
15 |
-
|
16 |
-
# 必須環境変数のチェック
|
17 |
-
required_vars = [
|
18 |
-
'OPENAI_API_KEY',
|
19 |
-
'OPENAI_API_BASE',
|
20 |
-
'MODEL_NAME',
|
21 |
-
'GRADIO_SERVER_NAME',
|
22 |
-
'GRADIO_SERVER_PORT',
|
23 |
-
'GOOGLE_APPLICATION_CREDENTIALS_CONTENT'
|
24 |
-
]
|
25 |
-
|
26 |
-
print("📋 必須環境変数チェック:")
|
27 |
-
all_set = True
|
28 |
-
for var in required_vars:
|
29 |
-
value = os.getenv(var, 'NOT_SET')
|
30 |
-
if value == 'NOT_SET' or value == 'YOUR_VALUE_HERE':
|
31 |
-
print(f" ❌ {var}: 未設定")
|
32 |
-
all_set = False
|
33 |
-
else:
|
34 |
-
# 機密情報はマスク
|
35 |
-
if 'KEY' in var or 'SECRET' in var or 'TOKEN' in var:
|
36 |
-
display_value = value[:8] + '...' if len(value) > 8 else '***'
|
37 |
-
else:
|
38 |
-
display_value = value
|
39 |
-
print(f" ✅ {var}: {display_value}")
|
40 |
-
|
41 |
-
print("\n📦 オプション環境変数:")
|
42 |
-
optional_vars = [
|
43 |
-
'APPSHEET_APPID', 'APPSHEET_KEY', 'ChannelAccessToken',
|
44 |
-
'github_user', 'github_token', 'hf_token'
|
45 |
-
]
|
46 |
-
|
47 |
-
for var in optional_vars:
|
48 |
-
value = os.getenv(var, 'NOT_SET')
|
49 |
-
if value != 'NOT_SET' and value != 'YOUR_VALUE_HERE':
|
50 |
-
print(f" ✅ {var}: 設定済み")
|
51 |
-
else:
|
52 |
-
print(f" ⚠️ {var}: 未設定(オプション)")
|
53 |
-
|
54 |
-
return all_set
|
55 |
-
|
56 |
-
def test_gradio_version():
|
57 |
-
"""Gradio バージョンチェック"""
|
58 |
-
try:
|
59 |
-
import gradio as gr
|
60 |
-
print(f"\n🎨 Gradio バージョン: {gr.__version__}")
|
61 |
-
|
62 |
-
# README.md仕様との比較
|
63 |
-
expected_version = "4.29.0"
|
64 |
-
if gr.__version__ == expected_version:
|
65 |
-
print(f" ✅ README.md仕様と一致: {expected_version}")
|
66 |
-
else:
|
67 |
-
print(f" ⚠️ README.md仕様 ({expected_version}) と異なります")
|
68 |
-
|
69 |
-
return True
|
70 |
-
except ImportError as e:
|
71 |
-
print(f" ❌ Gradio インポートエラー: {e}")
|
72 |
-
return False
|
73 |
-
|
74 |
-
def test_google_cloud_config():
|
75 |
-
"""Google Cloud認証設定テスト"""
|
76 |
-
print("\n☁️ Google Cloud設定:")
|
77 |
-
|
78 |
-
creds_content = os.getenv('GOOGLE_APPLICATION_CREDENTIALS_CONTENT')
|
79 |
-
if creds_content:
|
80 |
-
try:
|
81 |
-
creds_json = json.loads(creds_content)
|
82 |
-
project_id = creds_json.get('project_id', 'NOT_FOUND')
|
83 |
-
client_email = creds_json.get('client_email', 'NOT_FOUND')
|
84 |
-
|
85 |
-
print(f" ✅ プロジェクトID: {project_id}")
|
86 |
-
print(f" ✅ サービスアカウント: {client_email}")
|
87 |
-
return True
|
88 |
-
except json.JSONDecodeError:
|
89 |
-
print(" ❌ 認証情報のJSON形式が無効です")
|
90 |
-
return False
|
91 |
-
else:
|
92 |
-
print(" ❌ Google Cloud認証情報が設定されていません")
|
93 |
-
return False
|
94 |
-
|
95 |
-
def main():
|
96 |
-
"""メインテスト実行"""
|
97 |
-
print("🚀 Docker環境設定検証開始\n")
|
98 |
-
|
99 |
-
env_ok = test_environment_variables()
|
100 |
-
gradio_ok = test_gradio_version()
|
101 |
-
gcp_ok = test_google_cloud_config()
|
102 |
-
|
103 |
-
print("\n" + "=" * 60)
|
104 |
-
print("📊 テスト結果サマリー:")
|
105 |
-
print(f" 環境変数: {'✅ OK' if env_ok else '❌ NG'}")
|
106 |
-
print(f" Gradio: {'✅ OK' if gradio_ok else '❌ NG'}")
|
107 |
-
print(f" Google Cloud: {'✅ OK' if gcp_ok else '❌ NG'}")
|
108 |
-
|
109 |
-
overall_status = all([env_ok, gradio_ok, gcp_ok])
|
110 |
-
if overall_status:
|
111 |
-
print("\n🎉 すべてのテストが通過しました!")
|
112 |
-
print("✨ README.md仕様に準拠したDocker環境が正常に設定されています")
|
113 |
-
else:
|
114 |
-
print("\n⚠️ いくつかの設定に問題があります")
|
115 |
-
print("💡 上記のエラーを修正してから再度テストしてください")
|
116 |
-
|
117 |
-
return 0 if overall_status else 1
|
118 |
-
|
119 |
-
if __name__ == "__main__":
|
120 |
-
sys.exit(main())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|