Spaces:
Sleeping
Sleeping
Nagesh Muralidhar
commited on
Commit
·
80c42b8
1
Parent(s):
0d27572
Update PodCraft for HuggingFace Spaces
Browse files- .gitignore +3 -0
- Dockerfile.spaces +113 -18
- push_to_huggingface.sh +14 -0
.gitignore
CHANGED
@@ -82,3 +82,6 @@ wheels/
|
|
82 |
|
83 |
# Docker
|
84 |
.dockerignore
|
|
|
|
|
|
|
|
82 |
|
83 |
# Docker
|
84 |
.dockerignore
|
85 |
+
|
86 |
+
# Frontend build
|
87 |
+
frontend/podcraft/build/
|
Dockerfile.spaces
CHANGED
@@ -11,39 +11,134 @@ RUN apt-get update && \
|
|
11 |
gnupg \
|
12 |
&& rm -rf /var/lib/apt/lists/*
|
13 |
|
14 |
-
# Copy requirements
|
15 |
COPY backend/requirements.txt .
|
16 |
RUN pip install --no-cache-dir -r requirements.txt
|
17 |
|
18 |
-
# Copy backend code
|
19 |
-
COPY backend/app/ /app/app/
|
20 |
-
|
21 |
-
# Ensure static directory exists
|
22 |
-
RUN mkdir -p /app/static
|
23 |
-
|
24 |
-
# Copy frontend build to static directory if available
|
25 |
-
COPY frontend/podcraft/build/ /app/static/
|
26 |
-
|
27 |
# Install additional packages needed for serving frontend
|
28 |
RUN pip install --no-cache-dir python-multipart
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
# Create directory for temporary files
|
31 |
RUN mkdir -p /app/temp_audio
|
32 |
|
33 |
# Set environment variables
|
34 |
ENV PYTHONPATH=/app
|
35 |
-
|
36 |
-
# Using Secrets from HuggingFace Spaces
|
37 |
-
# MongoDB_URL is hardcoded to the Atlas URL in this case
|
38 |
ENV MONGODB_URL="mongodb+srv://NageshBM:Nash166^@podcraft.ozqmc.mongodb.net/?retryWrites=true&w=majority&appName=Podcraft"
|
|
|
39 |
|
40 |
-
#
|
41 |
-
RUN
|
42 |
-
|
43 |
-
|
|
|
|
|
|
|
44 |
|
45 |
# Expose the port the app runs on
|
46 |
EXPOSE 7860
|
47 |
|
48 |
# HuggingFace Spaces expects the app to run on port 7860
|
49 |
-
CMD ["uvicorn", "
|
|
|
11 |
gnupg \
|
12 |
&& rm -rf /var/lib/apt/lists/*
|
13 |
|
14 |
+
# Copy backend requirements and install
|
15 |
COPY backend/requirements.txt .
|
16 |
RUN pip install --no-cache-dir -r requirements.txt
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
# Install additional packages needed for serving frontend
|
19 |
RUN pip install --no-cache-dir python-multipart
|
20 |
|
21 |
+
# Copy backend code
|
22 |
+
COPY backend/ /app/backend/
|
23 |
+
|
24 |
+
# Create static directory with a placeholder index.html
|
25 |
+
RUN mkdir -p /app/static && \
|
26 |
+
echo '<!DOCTYPE html>\
|
27 |
+
<html lang="en">\
|
28 |
+
<head>\
|
29 |
+
<meta charset="UTF-8">\
|
30 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">\
|
31 |
+
<title>PodCraft - Loading...</title>\
|
32 |
+
<style>\
|
33 |
+
body {\
|
34 |
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;\
|
35 |
+
background-color: #1a1a2e;\
|
36 |
+
color: #ffffff;\
|
37 |
+
display: flex;\
|
38 |
+
flex-direction: column;\
|
39 |
+
align-items: center;\
|
40 |
+
justify-content: center;\
|
41 |
+
height: 100vh;\
|
42 |
+
margin: 0;\
|
43 |
+
text-align: center;\
|
44 |
+
}\
|
45 |
+
h1 {\
|
46 |
+
color: #8b5cf6;\
|
47 |
+
font-size: 2.5rem;\
|
48 |
+
margin-bottom: 1rem;\
|
49 |
+
}\
|
50 |
+
p {\
|
51 |
+
max-width: 600px;\
|
52 |
+
line-height: 1.6;\
|
53 |
+
margin-bottom: 2rem;\
|
54 |
+
}\
|
55 |
+
.loading {\
|
56 |
+
display: inline-block;\
|
57 |
+
position: relative;\
|
58 |
+
width: 80px;\
|
59 |
+
height: 80px;\
|
60 |
+
}\
|
61 |
+
.loading div {\
|
62 |
+
position: absolute;\
|
63 |
+
top: 33px;\
|
64 |
+
width: 13px;\
|
65 |
+
height: 13px;\
|
66 |
+
border-radius: 50%;\
|
67 |
+
background: #8b5cf6;\
|
68 |
+
animation-timing-function: cubic-bezier(0, 1, 1, 0);\
|
69 |
+
}\
|
70 |
+
.loading div:nth-child(1) {\
|
71 |
+
left: 8px;\
|
72 |
+
animation: loading1 0.6s infinite;\
|
73 |
+
}\
|
74 |
+
.loading div:nth-child(2) {\
|
75 |
+
left: 8px;\
|
76 |
+
animation: loading2 0.6s infinite;\
|
77 |
+
}\
|
78 |
+
.loading div:nth-child(3) {\
|
79 |
+
left: 32px;\
|
80 |
+
animation: loading2 0.6s infinite;\
|
81 |
+
}\
|
82 |
+
.loading div:nth-child(4) {\
|
83 |
+
left: 56px;\
|
84 |
+
animation: loading3 0.6s infinite;\
|
85 |
+
}\
|
86 |
+
@keyframes loading1 {\
|
87 |
+
0% {\
|
88 |
+
transform: scale(0);\
|
89 |
+
}\
|
90 |
+
100% {\
|
91 |
+
transform: scale(1);\
|
92 |
+
}\
|
93 |
+
}\
|
94 |
+
@keyframes loading3 {\
|
95 |
+
0% {\
|
96 |
+
transform: scale(1);\
|
97 |
+
}\
|
98 |
+
100% {\
|
99 |
+
transform: scale(0);\
|
100 |
+
}\
|
101 |
+
}\
|
102 |
+
@keyframes loading2 {\
|
103 |
+
0% {\
|
104 |
+
transform: translate(0, 0);\
|
105 |
+
}\
|
106 |
+
100% {\
|
107 |
+
transform: translate(24px, 0);\
|
108 |
+
}\
|
109 |
+
}\
|
110 |
+
</style>\
|
111 |
+
</head>\
|
112 |
+
<body>\
|
113 |
+
<h1>PodCraft</h1>\
|
114 |
+
<p>The AI-powered podcast generation platform is setting up. Please check back in a few minutes while we complete the build process.</p>\
|
115 |
+
<div class="loading">\
|
116 |
+
<div></div>\
|
117 |
+
<div></div>\
|
118 |
+
<div></div>\
|
119 |
+
<div></div>\
|
120 |
+
</div>\
|
121 |
+
</body>\
|
122 |
+
</html>' > /app/static/index.html
|
123 |
+
|
124 |
# Create directory for temporary files
|
125 |
RUN mkdir -p /app/temp_audio
|
126 |
|
127 |
# Set environment variables
|
128 |
ENV PYTHONPATH=/app
|
|
|
|
|
|
|
129 |
ENV MONGODB_URL="mongodb+srv://NageshBM:Nash166^@podcraft.ozqmc.mongodb.net/?retryWrites=true&w=majority&appName=Podcraft"
|
130 |
+
ENV OPENAI_API_KEY=""
|
131 |
|
132 |
+
# Create a simple main.py for the HuggingFace Space
|
133 |
+
RUN echo 'import sys\n\
|
134 |
+
import os\n\
|
135 |
+
# Add backend to Python path\n\
|
136 |
+
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "backend"))\n\
|
137 |
+
# Import the main app\n\
|
138 |
+
from backend.app.main import app' > /app/main.py
|
139 |
|
140 |
# Expose the port the app runs on
|
141 |
EXPOSE 7860
|
142 |
|
143 |
# HuggingFace Spaces expects the app to run on port 7860
|
144 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|
push_to_huggingface.sh
CHANGED
@@ -15,6 +15,14 @@ git lfs install
|
|
15 |
git lfs track "*.gif" "*.png" "*.jpg" "*.jpeg" "*.mp3" "*.mp4" "*.wav" "*.ogg"
|
16 |
git add .gitattributes
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
# Configure git if needed
|
19 |
if ! git remote | grep -q "origin"; then
|
20 |
echo "Please enter your HuggingFace username:"
|
@@ -30,6 +38,12 @@ find . -type f -size +100M | while read file; do
|
|
30 |
echo "Consider removing or excluding it from git."
|
31 |
done
|
32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
# Prepare for commit
|
34 |
echo "Adding files to git..."
|
35 |
git add .
|
|
|
15 |
git lfs track "*.gif" "*.png" "*.jpg" "*.jpeg" "*.mp3" "*.mp4" "*.wav" "*.ogg"
|
16 |
git add .gitattributes
|
17 |
|
18 |
+
# Make sure we're using Dockerfile.spaces for HuggingFace
|
19 |
+
echo "Ensuring space.yml is configured correctly..."
|
20 |
+
if ! grep -q "dockerfile: Dockerfile.spaces" space.yml; then
|
21 |
+
echo "Updating space.yml to use Dockerfile.spaces..."
|
22 |
+
sed -i 's/sdk: docker/sdk: docker\ndockerfile: Dockerfile.spaces/' space.yml
|
23 |
+
git add space.yml
|
24 |
+
fi
|
25 |
+
|
26 |
# Configure git if needed
|
27 |
if ! git remote | grep -q "origin"; then
|
28 |
echo "Please enter your HuggingFace username:"
|
|
|
38 |
echo "Consider removing or excluding it from git."
|
39 |
done
|
40 |
|
41 |
+
# Remove the frontend/podcraft/build directory as it causes errors
|
42 |
+
echo "Removing frontend/podcraft/build from git if it exists..."
|
43 |
+
if [ -d "frontend/podcraft/build" ]; then
|
44 |
+
git rm -r --cached frontend/podcraft/build || true
|
45 |
+
fi
|
46 |
+
|
47 |
# Prepare for commit
|
48 |
echo "Adding files to git..."
|
49 |
git add .
|