grimbano commited on
Commit
d03083f
·
1 Parent(s): df72e07

docs: :memo: Update docker requirements and other doc files

Browse files
Files changed (6) hide show
  1. .gitignore +5 -3
  2. Dockerfile +19 -3
  3. MakeFile +43 -0
  4. pyproject.toml +0 -13
  5. requirements.txt +11 -4
  6. src/streamlit_app.py +0 -8
.gitignore CHANGED
@@ -1,4 +1,6 @@
 
1
  .venv/
2
- uv.lock
3
-
4
- **__pycache__/
 
 
1
+ .env
2
  .venv/
3
+ .vscode/
4
+ .cache/
5
+ resources/
6
+ **/__pycache__/
Dockerfile CHANGED
@@ -9,13 +9,29 @@ RUN apt-get update && apt-get install -y \
9
  git \
10
  && rm -rf /var/lib/apt/lists/*
11
 
12
- # Set cache in /tmp (recommended in Spaces)
13
- ENV HF_HOME=/tmp/huggingface
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
  COPY requirements.txt ./
16
  COPY src/ ./src/
 
17
 
18
- RUN pip3 install -r requirements.txt
 
19
 
20
  EXPOSE 8501
21
 
 
9
  git \
10
  && rm -rf /var/lib/apt/lists/*
11
 
12
+ # Create cache directory and set permissions
13
+ RUN mkdir -p /app/.cache/torch && \
14
+ chmod -R 777 /app/.cache
15
+
16
+ # Set environment variables
17
+ ENV TORCH_HOME=/app/.cache/torch \
18
+ ENABLE_XSRF_PROTECTION=false
19
+
20
+ # Add a non-root user and switch to it
21
+ RUN useradd -m -u 1000 appuser
22
+ USER appuser
23
+ ENV HOME="/home/appuser"
24
+ WORKDIR $HOME
25
+
26
+ RUN mkdir -p $HOME/.cache/torch && chmod -R 777 $HOME/.cache
27
+ ENV TORCH_HOME=$HOME/.cache/torch
28
 
29
  COPY requirements.txt ./
30
  COPY src/ ./src/
31
+ COPY embeddings/ ./embeddings/
32
 
33
+ RUN pip3 install --user -r requirements.txt
34
+ ENV PATH=$HOME/.local/bin:$PATH
35
 
36
  EXPOSE 8501
37
 
MakeFile ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Python environment
2
+ PROJECT_ROOT = $(shell pwd)
3
+ VENV = $(PROJECT_ROOT)/.venv
4
+ PYTHON_ENV = $(VENV)/bin/python
5
+
6
+ # Docker image and container names for the student demo
7
+ IMAGE_NAME = streamlit-student-demo
8
+ CONTAINER_NAME = streamlit-student-demo-container
9
+ PORT = 8501
10
+
11
+ .PHONY: build run run-detached stop clean up restart
12
+
13
+ # Build the Docker image using Dockerfile.simple
14
+ build:
15
+ docker build -f Dockerfile.simple -t $(IMAGE_NAME) .
16
+
17
+ # Run the Docker container interactively (foreground)
18
+ run:
19
+ docker run --rm -it \
20
+ --name $(CONTAINER_NAME) \
21
+ -p $(PORT):8501 \
22
+ $(IMAGE_NAME)
23
+
24
+ # Run the Docker container in detached mode (background)
25
+ run-detached:
26
+ docker run -d \
27
+ --name $(CONTAINER_NAME) \
28
+ -p $(PORT):8501 \
29
+ $(IMAGE_NAME)
30
+
31
+ # Stop the running container
32
+ stop:
33
+ docker stop $(CONTAINER_NAME) || true
34
+
35
+ # Remove the container (if stopped)
36
+ clean:
37
+ docker rm $(CONTAINER_NAME) || true
38
+
39
+ # Build and run in one command (detached)
40
+ up: build run-detached
41
+
42
+ # Stop, remove, rebuild, and run
43
+ restart: stop clean up
pyproject.toml DELETED
@@ -1,13 +0,0 @@
1
- [project]
2
- name = "pokedex"
3
- version = "0.1.0"
4
- description = "Add your description here"
5
- readme = "README.md"
6
- requires-python = "==3.11.*"
7
- dependencies = [
8
- "pillow",
9
- "requests",
10
- "streamlit",
11
- "torch",
12
- "transformers",
13
- ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
requirements.txt CHANGED
@@ -1,5 +1,12 @@
1
- pillow
2
- requests
3
- streamlit
4
- torch
 
 
 
 
 
 
 
5
  transformers
 
1
+ numpy==1.26.4
2
+ packaging==23.2
3
+ setuptools==69.2.0
4
+ fastapi==0.109.2
5
+ uvicorn==0.27.1
6
+ python-multipart==0.0.9
7
+ requests==2.31.0
8
+ torch==2.2.1
9
+ torchvision==0.17.1
10
+ Pillow==10.2.0
11
+ streamlit==1.32.0
12
  transformers
src/streamlit_app.py CHANGED
@@ -1,11 +1,3 @@
1
- import os
2
- # Define temporal path for fixing issues
3
- os.environ['HF_HOME'] = '/tmp/huggingface'
4
-
5
- # Create the path if it doesn't exists
6
- os.makedirs('/tmp/huggingface', exist_ok=True)
7
-
8
-
9
  import streamlit as st
10
  from PIL import Image
11
  from similarity import PokemonSimilarity
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
  from PIL import Image
3
  from similarity import PokemonSimilarity