mikonvergence commited on
Commit
ebb7462
·
verified ·
1 Parent(s): 753b698

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +31 -22
Dockerfile CHANGED
@@ -1,36 +1,45 @@
1
- FROM python:3.9
2
 
3
- # 1. Set up a new user named "user" with user ID 1000
4
  RUN useradd -m -u 1000 user
5
 
6
- # 2. Set home and path
 
 
7
  ENV HOME=/home/user \
8
- PATH=/home/user/.local/bin:$PATH
9
 
10
- # 3. Create a working directory (Best Practice)
11
- # This ensures we aren't polluting the root directory
12
- WORKDIR $HOME/app
13
 
14
- # 4. Switch to "user" to install python packages
15
- USER user
 
 
16
 
17
- # Upgrade pip and install requirements
18
- RUN pip install --no-cache-dir --upgrade pip
19
- COPY --chown=user requirements.txt .
20
- RUN pip install --no-cache-dir --upgrade -r requirements.txt
 
21
 
22
- # 5. Download the files
23
- # Note: ADD with URLs always saves as ROOT, regardless of the USER setting.
24
- ADD https://huggingface.co/datasets/mikonvergence/MajorTOM-SigLIP-Index-Viewer-App/resolve/main/siglip_ivfpq.index ./siglip_ivfpq.index
25
- ADD https://huggingface.co/datasets/mikonvergence/MajorTOM-SigLIP-Index-Viewer-App/resolve/main/siglip_ivfpq_metadata.parquet ./siglip_ivfpq_metadata.parquet
26
 
27
- # 6. CRITICAL FIX: Switch to root to fix permissions, then switch back
28
- USER root
29
- RUN chown user:user ./siglip_ivfpq.index ./siglip_ivfpq_metadata.parquet
30
  USER user
31
 
32
- # 7. Copy remaining files
33
- COPY --chown=user *.py *.css siglip* ./
 
 
 
 
 
 
 
 
34
  COPY --chown=user helpers/* ./helpers/
35
 
36
  ENTRYPOINT ["solara", "run", "app.py", "--host=0.0.0.0", "--port", "7860", "--production"]
 
1
+ FROM continuumio/miniconda3
2
 
3
+ # 1. Set up a new user
4
  RUN useradd -m -u 1000 user
5
 
6
+ # 2. Set Environment Variables
7
+ # KEY CONDA TRICK: Add the new environment's bin to PATH immediately.
8
+ # This prevents the need for "conda activate" or "source activate" later.
9
  ENV HOME=/home/user \
10
+ PATH=/opt/conda/envs/app_env/bin:$PATH
11
 
12
+ # 3. Set Working Directory
13
+ WORKDIR /home/user/app
 
14
 
15
+ # 4. Create the Conda Environment
16
+ # We install python 3.9 and wget (to handle downloads cleanly)
17
+ # We do this as root to ensure it installs correctly in /opt/conda
18
+ RUN conda create -n app_env python=3.9 wget -y
19
 
20
+ # 5. Install Requirements
21
+ # Since we updated PATH in step 2, this 'pip' runs inside our conda env.
22
+ COPY requirements.txt .
23
+ RUN pip install --no-cache-dir --upgrade pip && \
24
+ pip install --no-cache-dir -r requirements.txt
25
 
26
+ # 6. Fix Directory Permissions
27
+ # Give the user ownership of the app folder before switching users
28
+ RUN chown -R user:user /home/user/app
 
29
 
30
+ # 7. Switch to "user"
 
 
31
  USER user
32
 
33
+ # 8. Download the files
34
+ # We use wget (installed via conda) instead of ADD.
35
+ # Because we are "USER user", these files are automatically owned by user.
36
+ # This removes the need for the complex "ADD -> Switch to Root -> Chown -> Switch Back" dance.
37
+ RUN wget https://huggingface.co/datasets/mikonvergence/MajorTOM-SigLIP-Index-Viewer-App/resolve/main/siglip_ivfpq.index -O siglip_ivfpq.index && \
38
+ wget https://huggingface.co/datasets/mikonvergence/MajorTOM-SigLIP-Index-Viewer-App/resolve/main/siglip_ivfpq_metadata.parquet -O siglip_ivfpq_metadata.parquet
39
+
40
+ # 9. Copy remaining files
41
+ # We removed 'siglip*' from here so we don't accidentally overwrite the downloaded files with local versions.
42
+ COPY --chown=user *.py *.css ./
43
  COPY --chown=user helpers/* ./helpers/
44
 
45
  ENTRYPOINT ["solara", "run", "app.py", "--host=0.0.0.0", "--port", "7860", "--production"]