kadarakos commited on
Commit
7b442b3
·
1 Parent(s): 3994148

build fix

Browse files
Files changed (2) hide show
  1. Dockerfile +11 -13
  2. pyproject.toml +3 -0
Dockerfile CHANGED
@@ -1,26 +1,24 @@
1
  FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim
2
 
3
- # Stay in root to keep paths simple
4
- WORKDIR /
5
 
6
- # 1. Install dependencies (Cached layer)
7
- # We need --extra train because we need Torch for the initial compilation
8
  COPY pyproject.toml uv.lock ./
9
- RUN uv sync --frozen --no-install-project --extra train
10
 
11
- # 2. Pre-bake NLTK data so it doesn't download on every request
12
- RUN uv run python -m nltk.downloader punkt punkt_tab
13
-
14
- # 3. Copy only the source code (Excludes ONNX via .dockerignore)
15
  COPY src ./src
16
  COPY README.md ./
17
 
18
- # 4. Final project install
19
- RUN uv sync --frozen --extra train
 
 
 
 
20
 
21
  # 5. HF Space defaults
22
  ENV PORT=7860
23
  EXPOSE 7860
24
 
25
- # Run the app. The 'lifespan' in mentioned.app will handle the download/ONNX export.
26
- CMD ["uv", "run", "python", "-m", "uvicorn", "mentioned.app:app", "--host", "0.0.0.0", "--port", "7860"]
 
1
  FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim
2
 
3
+ WORKDIR /app
 
4
 
5
+ # 1. Copy config files
 
6
  COPY pyproject.toml uv.lock ./
 
7
 
8
+ # 2. Copy the source code EARLY
9
+ # (This fixes the "Expected a Python module" error)
 
 
10
  COPY src ./src
11
  COPY README.md ./
12
 
13
+ # 3. Now run the sync
14
+ # (uv will now find src/mentioned/__init__.py and be happy)
15
+ RUN uv sync --frozen
16
+
17
+ # 4. Pre-bake NLTK data
18
+ RUN uv run python -m nltk.downloader punkt punkt_tab
19
 
20
  # 5. HF Space defaults
21
  ENV PORT=7860
22
  EXPOSE 7860
23
 
24
+ CMD ["uv", "run", "python", "-m", "uvicorn mentioned.app:app", "--host", "0.0.0.0", "--port", "7860"]
 
pyproject.toml CHANGED
@@ -35,3 +35,6 @@ dev = [
35
 
36
  [tool.setuptools.packages.find]
37
  where = ["src"]
 
 
 
 
35
 
36
  [tool.setuptools.packages.find]
37
  where = ["src"]
38
+
39
+ [tool.uv]
40
+ package = true