suh4s commited on
Commit
8739839
·
1 Parent(s): 3c2e3e7

Fix Dockerfile uv installation and PATH issues

Browse files
Files changed (1) hide show
  1. Dockerfile +12 -11
Dockerfile CHANGED
@@ -5,9 +5,7 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
5
  PYTHONUNBUFFERED=1 \
6
  PYTHONFAULTHANDLER=1 \
7
  HOME=/home/user \
8
- # PATH will be set by uv if using its venv or if installed to system Python
9
- UV_HOME="$HOME/.uv" \
10
- PATH="$HOME/.uv/bin:$PATH" \
11
  PYTHONPATH="$HOME/app:$PYTHONPATH"
12
 
13
  # Add non-root user
@@ -17,19 +15,23 @@ RUN useradd -m -u 1000 user
17
  RUN apt-get update && apt-get install -y --no-install-recommends \
18
  build-essential \
19
  curl \
20
- && rm -rf /var/lib/apt/lists/* \
21
- && curl -LsSf https://astral.sh/uv/install.sh | sh
22
 
23
  # Set working directory
24
  WORKDIR $HOME/app
25
 
 
 
 
 
 
 
 
26
  # Copy project definition
27
  COPY --chown=user pyproject.toml pyproject.toml
28
 
29
- # Install dependencies using uv (into the system Python for simplicity in Docker)
30
- # Using --system to install into the global site-packages
31
- # Using --no-cache to reduce layer size slightly
32
- RUN uv pip install --system --no-cache .
33
 
34
  # Copy all application files required for runtime
35
  COPY --chown=user app.py app.py
@@ -48,9 +50,8 @@ COPY --chown=user public ./public/
48
  RUN mkdir -p data_sources exports
49
 
50
  # Set permissions for the app directory
 
51
  RUN chown -R user:user $HOME/app
52
-
53
- # Switch to non-root user
54
  USER user
55
 
56
  # Run data download script to initialize data sources
 
5
  PYTHONUNBUFFERED=1 \
6
  PYTHONFAULTHANDLER=1 \
7
  HOME=/home/user \
8
+ PATH="/home/user/.local/bin:$PATH" \
 
 
9
  PYTHONPATH="$HOME/app:$PYTHONPATH"
10
 
11
  # Add non-root user
 
15
  RUN apt-get update && apt-get install -y --no-install-recommends \
16
  build-essential \
17
  curl \
18
+ && rm -rf /var/lib/apt/lists/*
 
19
 
20
  # Set working directory
21
  WORKDIR $HOME/app
22
 
23
+ # Switch to non-root user for uv installation
24
+ USER user
25
+
26
+ # Install uv
27
+ RUN curl -LsSf https://astral.sh/uv/install.sh | sh && \
28
+ echo 'export PATH=$HOME/.local/bin:$PATH' >> $HOME/.bashrc
29
+
30
  # Copy project definition
31
  COPY --chown=user pyproject.toml pyproject.toml
32
 
33
+ # Install dependencies using uv
34
+ RUN ~/.local/bin/uv pip install --system .
 
 
35
 
36
  # Copy all application files required for runtime
37
  COPY --chown=user app.py app.py
 
50
  RUN mkdir -p data_sources exports
51
 
52
  # Set permissions for the app directory
53
+ USER root
54
  RUN chown -R user:user $HOME/app
 
 
55
  USER user
56
 
57
  # Run data download script to initialize data sources