logan-codes commited on
Commit
d80b103
·
1 Parent(s): de5dca2

patch: docker fix

Browse files
Files changed (4) hide show
  1. app/Dockerfile → Dockerfile +37 -25
  2. compose.yaml +0 -29
  3. start.sh +9 -0
  4. ui/Dockerfile +0 -25
app/Dockerfile → Dockerfile RENAMED
@@ -1,25 +1,37 @@
1
- FROM python:3.13-slim
2
-
3
- # Environment settings
4
- ENV PYTHONDONTWRITEBYTECODE=1
5
- ENV PYTHONUNBUFFERED=1
6
-
7
- WORKDIR /app
8
-
9
- # System dependencies (safe default)
10
- RUN apt-get update && apt-get install -y \
11
- build-essential \
12
- && rm -rf /var/lib/apt/lists/*
13
-
14
- # Install Python dependencies
15
- COPY ../requirements.txt .
16
- RUN pip install --no-cache-dir -r requirements.txt
17
-
18
- # Copy application code
19
- COPY . .
20
-
21
- # Expose FastAPI port
22
- EXPOSE 8000
23
-
24
- # Run FastAPI with Uvicorn
25
- CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.13-slim
2
+
3
+ # Environment settings
4
+ ENV PYTHONDONTWRITEBYTECODE=1
5
+ ENV PYTHONUNBUFFERED=1
6
+ ENV HOME=/home/user
7
+ ENV PATH=/home/user/.local/bin:$PATH
8
+
9
+ WORKDIR /app
10
+
11
+ # System dependencies
12
+ RUN apt-get update && apt-get install -y \
13
+ build-essential \
14
+ curl \
15
+ && rm -rf /var/lib/apt/lists/*
16
+
17
+ # Create a non-privileged user for HF Spaces
18
+ RUN useradd -m -u 1000 user
19
+ USER user
20
+
21
+ # Install Python dependencies
22
+ # Copy root requirements (assuming it contains both app and ui deps)
23
+ COPY --chown=user requirements.txt .
24
+ RUN pip install --no-cache-dir --user -r requirements.txt
25
+
26
+ # Copy application code
27
+ COPY --chown=user . .
28
+
29
+ # Ensure start script is executable
30
+ RUN chmod +x start.sh
31
+
32
+ # HF Spaces default port is 7860 (will be used by Streamlit)
33
+ # FastAPI will run on 8000 internally
34
+ EXPOSE 7860
35
+
36
+ # Run the startup script
37
+ CMD ["./start.sh"]
compose.yaml DELETED
@@ -1,29 +0,0 @@
1
- # Comments are provided throughout this file to help you get started.
2
- # If you need more help, visit the Docker Compose reference guide at
3
- # https://docs.docker.com/go/compose-spec-reference/
4
-
5
- # Here the instructions define your application as a service called "server".
6
- # This service is built from the Dockerfile in the current directory.
7
- # You can add other services your application may depend on here, such as a
8
- # database or a cache. For examples, see the Awesome Compose repository:
9
- # https://github.com/docker/awesome-compose
10
- services:
11
- server:
12
- build:
13
- context: ./app
14
- ports:
15
- - 8000:8000
16
- env_file:
17
- - .env
18
-
19
- frontend:
20
- build:
21
- context: ./ui
22
- ports:
23
- - 3000:3000
24
- depends_on:
25
- - server
26
- env_file:
27
- - .env
28
- environment:
29
- - API_URL=http://server:8000/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
start.sh ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Start FastAPI server in the background
4
+ echo "Starting FastAPI server..."
5
+ python -m uvicorn app.main:app --host 0.0.0.0 --port 8000 &
6
+
7
+ # Start Streamlit UI
8
+ echo "Starting Streamlit UI..."
9
+ streamlit run ui/Home.py --server.port 7860 --server.address 0.0.0.0
ui/Dockerfile DELETED
@@ -1,25 +0,0 @@
1
- FROM python:3.13-slim
2
-
3
- # Prevent Python from writing pyc files & buffering stdout
4
- ENV PYTHONDONTWRITEBYTECODE=1
5
- ENV PYTHONUNBUFFERED=1
6
-
7
- WORKDIR /app
8
-
9
- # Install system dependencies (optional but safe)
10
- RUN apt-get update && apt-get install -y \
11
- build-essential \
12
- && rm -rf /var/lib/apt/lists/*
13
-
14
- # Install Python dependencies
15
- COPY requirements.txt .
16
- RUN pip install --no-cache-dir -r requirements.txt
17
-
18
- # Copy application code
19
- COPY . .
20
-
21
- # Expose Streamlit port
22
- EXPOSE 8501
23
-
24
- # Run Streamlit
25
- CMD ["streamlit", "run", "Home.py", "--server.port=3000", "--server.address=0.0.0.0"]