egumasa commited on
Commit
6f0680f
·
1 Parent(s): f3e33b1

docker change

Browse files
Files changed (1) hide show
  1. Dockerfile +23 -18
Dockerfile CHANGED
@@ -1,7 +1,5 @@
1
  FROM python:3.12-slim
2
 
3
- WORKDIR /app
4
-
5
  RUN apt-get update && apt-get install -y \
6
  build-essential \
7
  curl \
@@ -9,23 +7,34 @@ RUN apt-get update && apt-get install -y \
9
  git \
10
  && rm -rf /var/lib/apt/lists/*
11
 
 
 
 
12
  # Install uv
13
  COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
14
 
15
- # Set UV cache directory to a writable location
16
- ENV UV_CACHE_DIR=/tmp/uv-cache
 
 
 
 
 
17
 
18
- # Copy project files
19
- COPY pyproject.toml uv.lock ./
20
- COPY requirements.txt ./
21
- COPY web_app/ ./web_app/
22
- COPY text_analyzer/ ./text_analyzer/
23
- COPY config/ ./config/
24
- COPY resources/ ./resources/
25
- COPY .streamlit/ ./.streamlit/
26
 
27
- # Install dependencies with uv (no cache for build)
28
- RUN UV_NO_CACHE=1 uv sync --frozen
 
 
 
 
 
 
 
 
 
29
 
30
  # Download UniDic dictionary data for Japanese text processing
31
  RUN uv run python -m unidic download
@@ -34,8 +43,4 @@ EXPOSE 8501
34
 
35
  HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
36
 
37
- # Set environment for runtime
38
- ENV UV_CACHE_DIR=/tmp/uv-cache
39
- ENV UV_NO_CACHE=1
40
-
41
  ENTRYPOINT ["uv", "run", "streamlit", "run", "web_app/app.py", "--server.port=8501", "--server.address=0.0.0.0", "--server.enableXsrfProtection=false", "--server.enableCORS=false"]
 
1
  FROM python:3.12-slim
2
 
 
 
3
  RUN apt-get update && apt-get install -y \
4
  build-essential \
5
  curl \
 
7
  git \
8
  && rm -rf /var/lib/apt/lists/*
9
 
10
+ # Create user with ID 1000 (required by HF Spaces)
11
+ RUN useradd -m -u 1000 user
12
+
13
  # Install uv
14
  COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
15
 
16
+ # Switch to user
17
+ USER user
18
+
19
+ # Set environment variables
20
+ ENV HOME=/home/user \
21
+ PATH=/home/user/.local/bin:$PATH \
22
+ UV_CACHE_DIR=/home/user/.cache/uv
23
 
24
+ # Set working directory to user's home
25
+ WORKDIR $HOME/app
 
 
 
 
 
 
26
 
27
+ # Copy project files with correct ownership
28
+ COPY --chown=user pyproject.toml uv.lock ./
29
+ COPY --chown=user requirements.txt ./
30
+ COPY --chown=user web_app/ ./web_app/
31
+ COPY --chown=user text_analyzer/ ./text_analyzer/
32
+ COPY --chown=user config/ ./config/
33
+ COPY --chown=user resources/ ./resources/
34
+ COPY --chown=user .streamlit/ ./.streamlit/
35
+
36
+ # Install dependencies with uv
37
+ RUN uv sync --frozen
38
 
39
  # Download UniDic dictionary data for Japanese text processing
40
  RUN uv run python -m unidic download
 
43
 
44
  HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
45
 
 
 
 
 
46
  ENTRYPOINT ["uv", "run", "streamlit", "run", "web_app/app.py", "--server.port=8501", "--server.address=0.0.0.0", "--server.enableXsrfProtection=false", "--server.enableCORS=false"]