Spaces:
Sleeping
Sleeping
ariansyahdedy
commited on
Commit
·
d5c46e9
1
Parent(s):
4690b45
Initial commit
Browse files- .gitignore +2 -0
- Dockerfile +42 -0
- app/main.py +18 -0
- requirements.txt +2 -0
.gitignore
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
.venv
|
2 |
+
__pycache__
|
Dockerfile
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3.10
|
2 |
+
|
3 |
+
RUN useradd -m -u 1000 user
|
4 |
+
|
5 |
+
WORKDIR /code
|
6 |
+
|
7 |
+
# Install libgl1-mesa-glx and libglib2.0-0
|
8 |
+
RUN apt-get update && apt-get install -y libgl1-mesa-glx libglib2.0-0
|
9 |
+
|
10 |
+
COPY ./requirements.txt /code/requirements.txt
|
11 |
+
|
12 |
+
RUN python -m venv /code/venv
|
13 |
+
|
14 |
+
RUN /code/venv/bin/pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
15 |
+
|
16 |
+
COPY --chown=user . /code
|
17 |
+
|
18 |
+
# Copy the start script into the container and change permissions before switching to non-root user
|
19 |
+
COPY start.sh /code/start.sh
|
20 |
+
RUN chmod +x /code/start.sh
|
21 |
+
|
22 |
+
# Create necessary directories and set permissions before switching to non-root user
|
23 |
+
RUN mkdir -p /code/uploaded_videos /code/output_frames \
|
24 |
+
&& chown -R user:user /code \
|
25 |
+
&& ls -l /code
|
26 |
+
|
27 |
+
USER user
|
28 |
+
|
29 |
+
RUN ls -l /code
|
30 |
+
RUN ls -l /code/output_frames
|
31 |
+
|
32 |
+
ENV PATH="/code/venv/bin:$PATH"
|
33 |
+
|
34 |
+
# Make port 8000 available to the world outside this container
|
35 |
+
EXPOSE 8000
|
36 |
+
|
37 |
+
# Define environment variable
|
38 |
+
ENV PYTHONUNBUFFERED=1
|
39 |
+
|
40 |
+
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"]
|
41 |
+
# Use the start script as the entry point
|
42 |
+
# CMD ["/code/start.sh"]
|
app/main.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastapi import FastAPI, Request
|
2 |
+
from fastapi.responses import JSONResponse
|
3 |
+
|
4 |
+
app = FastAPI()
|
5 |
+
|
6 |
+
@app.post("/webhook")
|
7 |
+
async def webhook(request: Request):
|
8 |
+
data = await request.json()
|
9 |
+
# Process the incoming data
|
10 |
+
print(f"Received data: {data}")
|
11 |
+
|
12 |
+
# Prepare a response
|
13 |
+
response_data = {
|
14 |
+
"message": "Hello! This is an automatic reply.",
|
15 |
+
"received": data
|
16 |
+
}
|
17 |
+
|
18 |
+
return JSONResponse(content=response_data)
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
fastapi
|
2 |
+
uvicorn
|