Spaces:
Sleeping
Sleeping
Commit
·
691c981
1
Parent(s):
241f993
Update: Finalize Docker configuration and paths
Browse files- Dockerfile +10 -17
- app/__pycache__/main.cpython-310.pyc +0 -0
- app/main.py +20 -8
- app/routers/__pycache__/inference.cpython-310.pyc +0 -0
Dockerfile
CHANGED
@@ -22,13 +22,15 @@ RUN apt-get update && \
|
|
22 |
libglib2.0-0 \
|
23 |
git \
|
24 |
&& apt-get clean && \
|
25 |
-
rm -rf /var/lib/apt/lists/*
|
26 |
-
rm -rf /tmp/* && \
|
27 |
-
mkdir -p /tmp && \
|
28 |
-
chmod 777 /tmp
|
29 |
|
30 |
-
# Create
|
31 |
-
RUN mkdir -p /
|
|
|
|
|
|
|
|
|
|
|
32 |
mkdir -p /home/user/huggingface && \
|
33 |
mkdir -p /home/user/ultralytics && \
|
34 |
chown -R user:user /home/user/.cache && \
|
@@ -38,19 +40,10 @@ RUN mkdir -p /home/user/.cache && \
|
|
38 |
# Copy requirements first
|
39 |
COPY requirements.txt .
|
40 |
|
41 |
-
# Install dependencies
|
42 |
RUN pip install --no-cache-dir --upgrade pip && \
|
43 |
pip install --no-cache-dir setuptools wheel && \
|
44 |
-
pip install --no-cache-dir -r requirements.txt
|
45 |
-
rm -rf ~/.cache/pip && \
|
46 |
-
rm -rf /tmp/* && \
|
47 |
-
mkdir -p /tmp && \
|
48 |
-
chmod 777 /tmp
|
49 |
-
|
50 |
-
# Create necessary directories with proper permissions
|
51 |
-
RUN mkdir -p /tmp/models/parts/weights/weights && \
|
52 |
-
chmod -R 777 /tmp && \
|
53 |
-
chown -R user:user /tmp/models
|
54 |
|
55 |
# Copy application code
|
56 |
COPY --chown=user:user . .
|
|
|
22 |
libglib2.0-0 \
|
23 |
git \
|
24 |
&& apt-get clean && \
|
25 |
+
rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
26 |
|
27 |
+
# Create all necessary directories with proper permissions
|
28 |
+
RUN mkdir -p /tmp/uploads && \
|
29 |
+
mkdir -p /tmp/results && \
|
30 |
+
mkdir -p /tmp/models/parts/weights/weights && \
|
31 |
+
chmod -R 777 /tmp && \
|
32 |
+
chown -R user:user /tmp && \
|
33 |
+
mkdir -p /home/user/.cache && \
|
34 |
mkdir -p /home/user/huggingface && \
|
35 |
mkdir -p /home/user/ultralytics && \
|
36 |
chown -R user:user /home/user/.cache && \
|
|
|
40 |
# Copy requirements first
|
41 |
COPY requirements.txt .
|
42 |
|
43 |
+
# Install dependencies
|
44 |
RUN pip install --no-cache-dir --upgrade pip && \
|
45 |
pip install --no-cache-dir setuptools wheel && \
|
46 |
+
pip install --no-cache-dir -r requirements.txt
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
|
48 |
# Copy application code
|
49 |
COPY --chown=user:user . .
|
app/__pycache__/main.cpython-310.pyc
CHANGED
Binary files a/app/__pycache__/main.cpython-310.pyc and b/app/__pycache__/main.cpython-310.pyc differ
|
|
app/main.py
CHANGED
@@ -47,20 +47,32 @@ app.add_middleware(
|
|
47 |
allow_headers=["*"],
|
48 |
)
|
49 |
|
50 |
-
#
|
51 |
-
|
52 |
-
|
|
|
|
|
|
|
|
|
|
|
53 |
|
54 |
# Include routers
|
55 |
app.include_router(inference.router)
|
56 |
|
57 |
-
# Create required directories
|
58 |
-
UPLOAD_DIR = Path("tmp/uploads")
|
59 |
-
RESULTS_DIR = Path("tmp/results")
|
60 |
|
61 |
def create_dirs():
|
|
|
62 |
for dir_path in [UPLOAD_DIR, RESULTS_DIR]:
|
63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
|
65 |
# Add to startup
|
66 |
@app.on_event("startup")
|
@@ -68,4 +80,4 @@ async def startup_event():
|
|
68 |
create_dirs()
|
69 |
|
70 |
if __name__ == "__main__":
|
71 |
-
uvicorn.run("main:app", host="0.0.0.0", port=
|
|
|
47 |
allow_headers=["*"],
|
48 |
)
|
49 |
|
50 |
+
# Get absolute paths for static and template directories
|
51 |
+
APP_DIR = Path(__file__).resolve().parent
|
52 |
+
STATIC_DIR = APP_DIR / "static"
|
53 |
+
TEMPLATES_DIR = APP_DIR / "templates"
|
54 |
+
|
55 |
+
# Mount static files using absolute path
|
56 |
+
app.mount("/static", StaticFiles(directory=str(STATIC_DIR)), name="static")
|
57 |
+
templates = Jinja2Templates(directory=str(TEMPLATES_DIR))
|
58 |
|
59 |
# Include routers
|
60 |
app.include_router(inference.router)
|
61 |
|
62 |
+
# Create required directories with absolute paths
|
63 |
+
UPLOAD_DIR = Path("/tmp/uploads")
|
64 |
+
RESULTS_DIR = Path("/tmp/results")
|
65 |
|
66 |
def create_dirs():
|
67 |
+
# Ensure directories exist with proper permissions
|
68 |
for dir_path in [UPLOAD_DIR, RESULTS_DIR]:
|
69 |
+
try:
|
70 |
+
dir_path.mkdir(parents=True, exist_ok=True)
|
71 |
+
# Set permissions to 777 to ensure write access
|
72 |
+
os.chmod(str(dir_path), 0o777)
|
73 |
+
except Exception as e:
|
74 |
+
print(f"Error creating directory {dir_path}: {e}")
|
75 |
+
raise
|
76 |
|
77 |
# Add to startup
|
78 |
@app.on_event("startup")
|
|
|
80 |
create_dirs()
|
81 |
|
82 |
if __name__ == "__main__":
|
83 |
+
uvicorn.run("main:app", host="0.0.0.0", port=7860)
|
app/routers/__pycache__/inference.cpython-310.pyc
CHANGED
Binary files a/app/routers/__pycache__/inference.cpython-310.pyc and b/app/routers/__pycache__/inference.cpython-310.pyc differ
|
|