Spaces:
Running
Running
Manus AI commited on
Commit ·
ad5656b
1
Parent(s): 4b2e79b
Final deployment: Updated Dockerfile and added keep-alive script
Browse files- Dockerfile +8 -9
- scripts/keep_alive.py +24 -0
Dockerfile
CHANGED
|
@@ -5,19 +5,18 @@ WORKDIR /app
|
|
| 5 |
RUN apt-get update && apt-get install -y \
|
| 6 |
build-essential \
|
| 7 |
curl \
|
|
|
|
| 8 |
git \
|
| 9 |
&& rm -rf /var/lib/apt/lists/*
|
| 10 |
|
| 11 |
-
COPY
|
| 12 |
-
RUN
|
| 13 |
|
| 14 |
COPY . .
|
| 15 |
|
| 16 |
-
#
|
| 17 |
-
|
|
|
|
| 18 |
|
| 19 |
-
#
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
# Start both FastAPI and Gradio
|
| 23 |
-
CMD ["sh", "-c", "python api/main.py & python app.py"]
|
|
|
|
| 5 |
RUN apt-get update && apt-get install -y \
|
| 6 |
build-essential \
|
| 7 |
curl \
|
| 8 |
+
software-properties-common \
|
| 9 |
git \
|
| 10 |
&& rm -rf /var/lib/apt/lists/*
|
| 11 |
|
| 12 |
+
COPY requirements_enhanced.txt .
|
| 13 |
+
RUN pip3 install --no-cache-dir -r requirements_enhanced.txt
|
| 14 |
|
| 15 |
COPY . .
|
| 16 |
|
| 17 |
+
# Expose ports for FastAPI and Gradio
|
| 18 |
+
EXPOSE 8000
|
| 19 |
+
EXPOSE 7860
|
| 20 |
|
| 21 |
+
# Command to run the Gradio UI by default
|
| 22 |
+
CMD ["python3", "app_enhanced.py"]
|
|
|
|
|
|
|
|
|
scripts/keep_alive.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import requests
|
| 2 |
+
import time
|
| 3 |
+
import logging
|
| 4 |
+
|
| 5 |
+
logging.basicConfig(level=logging.INFO)
|
| 6 |
+
logger = logging.getLogger(__name__)
|
| 7 |
+
|
| 8 |
+
URL = "https://huggingface.co/spaces/Qalam/Nuclear-Intelligence"
|
| 9 |
+
|
| 10 |
+
def ping_space():
|
| 11 |
+
try:
|
| 12 |
+
response = requests.get(URL)
|
| 13 |
+
if response.status_code == 200:
|
| 14 |
+
logger.info(f"Successfully pinged {URL}")
|
| 15 |
+
else:
|
| 16 |
+
logger.warning(f"Failed to ping {URL}. Status code: {response.status_code}")
|
| 17 |
+
except Exception as e:
|
| 18 |
+
logger.error(f"Error pinging {URL}: {e}")
|
| 19 |
+
|
| 20 |
+
if __name__ == "__main__":
|
| 21 |
+
logger.info("Starting Keep-Alive script...")
|
| 22 |
+
while True:
|
| 23 |
+
ping_space()
|
| 24 |
+
time.sleep(20 * 60) # Ping every 20 minutes
|