omarsol commited on
Commit
a7e3f99
Β·
1 Parent(s): 874cd2c

Refactor Dockerfile and update app launch configuration

Browse files
Files changed (3) hide show
  1. Dockerfile +23 -9
  2. README.md +1 -1
  3. scripts/main.py +5 -13
Dockerfile CHANGED
@@ -1,21 +1,35 @@
1
- FROM python:3.13
 
2
 
 
 
 
 
 
3
  RUN curl -LsSf https://astral.sh/uv/install.sh | sh
4
- # uv was installed to /root/.local/bin – add it to PATH
5
  ENV PATH="/root/.local/bin:${PATH}"
6
 
 
7
  RUN useradd -m -u 1000 user
8
- WORKDIR /app
9
-
10
- COPY pyproject.toml uv.lock ./
11
- RUN uv sync --locked
12
 
13
- COPY . .
 
 
 
14
 
 
 
15
 
16
- ENV HOME=/home/user PATH="/root/.local/bin:/home/user/.local/bin:${PATH}"
17
- RUN chown -R user:user /app
18
  USER user
 
 
 
 
19
 
 
20
  EXPOSE 7860
 
 
21
  CMD ["uv", "run", "scripts/main.py"]
 
1
+ # Dockerfile
2
+ FROM python:3.13-slim
3
 
4
+ # (Recommended) Install curl & certs on -slim base
5
+ RUN apt-get update && apt-get install -y --no-install-recommends curl ca-certificates \
6
+ && rm -rf /var/lib/apt/lists/*
7
+
8
+ # Install uv (installs to /root/.local/bin by default)
9
  RUN curl -LsSf https://astral.sh/uv/install.sh | sh
10
+ # Make sure uv is on PATH for all later steps
11
  ENV PATH="/root/.local/bin:${PATH}"
12
 
13
+ # Create the HF-required user (UID 1000) before copying files
14
  RUN useradd -m -u 1000 user
 
 
 
 
15
 
16
+ # Work in the user's home to avoid permissions issues
17
+ ENV HOME=/home/user \
18
+ PATH="/root/.local/bin:/home/user/.local/bin:${PATH}"
19
+ WORKDIR /home/user/app
20
 
21
+ # Copy only deps first for better caching; make them owned by 'user'
22
+ COPY --chown=user:user pyproject.toml uv.lock ./
23
 
24
+ # Use the non-root user for env creation so .venv belongs to them
 
25
  USER user
26
+ RUN uv sync --locked
27
+
28
+ # Copy the rest of your app
29
+ COPY --chown=user:user . .
30
 
31
+ # Spaces expects your app to listen on this port; keep README app_port in sync
32
  EXPOSE 7860
33
+
34
+ # Start the app via uv
35
  CMD ["uv", "run", "scripts/main.py"]
README.md CHANGED
@@ -28,7 +28,7 @@ The Gradio demo is deployed on Hugging Face Spaces at: [AI Tutor Chatbot on Hugg
28
 
29
  1. **Set environment variables:**
30
 
31
- - copy .env.example to a new .env file and fill in the values
32
 
33
  2. **Run the application:**
34
 
 
28
 
29
  1. **Set environment variables:**
30
 
31
+ - copy .env.example to a new .env file and fill in the values
32
 
33
  2. **Run the application:**
34
 
scripts/main.py CHANGED
@@ -7,20 +7,12 @@ from llama_index.agent.openai import OpenAIAgent
7
  from llama_index.core.llms import MessageRole
8
  from llama_index.core.memory import ChatSummaryMemoryBuffer
9
  from llama_index.core.tools import RetrieverTool, ToolMetadata
10
- from llama_index.core.vector_stores import (
11
- FilterCondition,
12
- FilterOperator,
13
- MetadataFilter,
14
- MetadataFilters,
15
- )
16
  from llama_index.llms.openai import OpenAI
17
  from prompts import system_message_openai_agent
18
- from setup import (
19
- AVAILABLE_SOURCES,
20
- AVAILABLE_SOURCES_UI,
21
- CONCURRENCY_COUNT,
22
- custom_retriever_all_sources,
23
- )
24
 
25
 
26
  def update_query_engine_tools(selected_sources) -> list[RetrieverTool]:
@@ -263,4 +255,4 @@ with gr.Blocks(
263
 
264
  if __name__ == "__main__":
265
  demo.queue(default_concurrency_limit=CONCURRENCY_COUNT)
266
- demo.launch(debug=False, share=False)
 
7
  from llama_index.core.llms import MessageRole
8
  from llama_index.core.memory import ChatSummaryMemoryBuffer
9
  from llama_index.core.tools import RetrieverTool, ToolMetadata
10
+ from llama_index.core.vector_stores import (FilterCondition, FilterOperator,
11
+ MetadataFilter, MetadataFilters)
 
 
 
 
12
  from llama_index.llms.openai import OpenAI
13
  from prompts import system_message_openai_agent
14
+ from setup import (AVAILABLE_SOURCES, AVAILABLE_SOURCES_UI, CONCURRENCY_COUNT,
15
+ custom_retriever_all_sources)
 
 
 
 
16
 
17
 
18
  def update_query_engine_tools(selected_sources) -> list[RetrieverTool]:
 
255
 
256
  if __name__ == "__main__":
257
  demo.queue(default_concurrency_limit=CONCURRENCY_COUNT)
258
+ demo.launch(server_name="0.0.0.0", server_port=7860, debug=False, share=False)