Spaces:
Running
Running
add dockerfile to deploy, add monitoring prometheus
Browse files- Dockerfile +30 -0
- docker-compose.yml +16 -0
- helper.py +1 -0
- prometheus.yml +7 -0
Dockerfile
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.10-slim
|
2 |
+
|
3 |
+
# Add build argument
|
4 |
+
ARG HUGGINGFACE_API_KEY
|
5 |
+
|
6 |
+
# System dependencies
|
7 |
+
RUN apt-get update && apt-get install -y \
|
8 |
+
build-essential \
|
9 |
+
curl \
|
10 |
+
&& rm -rf /var/lib/apt/lists/*
|
11 |
+
|
12 |
+
# Set working directory
|
13 |
+
WORKDIR /app
|
14 |
+
|
15 |
+
# Copy requirements first for caching
|
16 |
+
COPY requirements.txt .
|
17 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
18 |
+
|
19 |
+
# Copy project files
|
20 |
+
COPY . .
|
21 |
+
|
22 |
+
# Environment variables
|
23 |
+
ENV PYTHONUNBUFFERED=1
|
24 |
+
ENV HUGGINGFACE_API_KEY=${HUGGINGFACE_API_KEY}
|
25 |
+
|
26 |
+
# Expose port
|
27 |
+
EXPOSE 7860
|
28 |
+
|
29 |
+
# Run the application
|
30 |
+
CMD ["python", "main.py"]
|
docker-compose.yml
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
version: '3.8'
|
2 |
+
services:
|
3 |
+
ai-dungeon:
|
4 |
+
build:
|
5 |
+
context: .
|
6 |
+
args:
|
7 |
+
- HUGGINGFACE_API_KEY=${HUGGINGFACE_API_KEY}
|
8 |
+
ports:
|
9 |
+
- "7860:7860"
|
10 |
+
environment:
|
11 |
+
- HUGGINGFACE_API_KEY=${HUGGINGFACE_API_KEY}
|
12 |
+
deploy:
|
13 |
+
resources:
|
14 |
+
reservations:
|
15 |
+
devices:
|
16 |
+
- capabilities: [gpu]
|
helper.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import os
|
|
|
2 |
from dotenv import load_dotenv, find_dotenv
|
3 |
import json
|
4 |
import gradio as gr
|
|
|
1 |
import os
|
2 |
+
import re
|
3 |
from dotenv import load_dotenv, find_dotenv
|
4 |
import json
|
5 |
import gradio as gr
|
prometheus.yml
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
global:
|
2 |
+
scrape_interval: 15s
|
3 |
+
|
4 |
+
scrape_configs:
|
5 |
+
- job_name: 'ai-dungeon'
|
6 |
+
static_configs:
|
7 |
+
- targets: ['localhost:7860']
|