Spaces:
Running
on
L4
Running
on
L4
Update Dockerfile
Browse files- Dockerfile +18 -21
Dockerfile
CHANGED
|
@@ -1,48 +1,45 @@
|
|
| 1 |
FROM continuumio/miniconda3
|
| 2 |
|
| 3 |
-
# 1. Set up
|
| 4 |
RUN useradd -m -u 1000 user
|
| 5 |
|
| 6 |
# 2. Set Environment Variables
|
| 7 |
-
#
|
| 8 |
-
#
|
| 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
|
| 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
|
| 21 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
COPY requirements.txt .
|
| 23 |
RUN pip install --no-cache-dir --upgrade pip && \
|
| 24 |
pip install --no-cache-dir -r requirements.txt
|
| 25 |
|
| 26 |
-
|
| 27 |
-
conda clean -ya
|
| 28 |
-
|
| 29 |
-
# 6. Fix Directory Permissions
|
| 30 |
-
# Give the user ownership of the app folder before switching users
|
| 31 |
RUN chown -R user:user /home/user/app
|
| 32 |
|
| 33 |
-
#
|
| 34 |
USER user
|
| 35 |
|
| 36 |
-
#
|
| 37 |
-
# We use wget (installed via conda) instead of ADD.
|
| 38 |
-
# Because we are "USER user", these files are automatically owned by user.
|
| 39 |
-
# This removes the need for the complex "ADD -> Switch to Root -> Chown -> Switch Back" dance.
|
| 40 |
RUN wget https://huggingface.co/datasets/mikonvergence/MajorTOM-SigLIP-Index-Viewer-App/resolve/main/siglip_ivfpq.index -O siglip_ivfpq.index && \
|
| 41 |
wget https://huggingface.co/datasets/mikonvergence/MajorTOM-SigLIP-Index-Viewer-App/resolve/main/siglip_ivfpq_metadata.parquet -O siglip_ivfpq_metadata.parquet
|
| 42 |
|
| 43 |
-
#
|
| 44 |
-
# We removed 'siglip*' from here so we don't accidentally overwrite the downloaded files with local versions.
|
| 45 |
COPY --chown=user *.py *.css ./
|
| 46 |
COPY --chown=user helpers/* ./helpers/
|
| 47 |
|
|
|
|
|
|
|
| 48 |
ENTRYPOINT ["solara", "run", "app.py", "--host=0.0.0.0", "--port", "7860", "--production"]
|
|
|
|
| 1 |
FROM continuumio/miniconda3
|
| 2 |
|
| 3 |
+
# 1. Set up user (Hugging Face Spaces recommends UID 1000)
|
| 4 |
RUN useradd -m -u 1000 user
|
| 5 |
|
| 6 |
# 2. Set Environment Variables
|
| 7 |
+
# PATH: Ensures we use the conda python/pip/solara
|
| 8 |
+
# LD_LIBRARY_PATH (NEW): Helps faiss-gpu find CUDA libraries without "conda activate"
|
| 9 |
ENV HOME=/home/user \
|
| 10 |
+
PATH=/opt/conda/envs/app_env/bin:$PATH \
|
| 11 |
+
LD_LIBRARY_PATH=/opt/conda/envs/app_env/lib:$LD_LIBRARY_PATH
|
| 12 |
|
| 13 |
# 3. Set Working Directory
|
| 14 |
WORKDIR /home/user/app
|
| 15 |
|
| 16 |
+
# 4. Create Conda Environment
|
|
|
|
|
|
|
| 17 |
RUN conda create -n app_env python=3.9 wget -y
|
| 18 |
|
| 19 |
+
# 5. Install Conda Packages
|
| 20 |
+
# Note: We use '-n app_env' to target the specific environment
|
| 21 |
+
RUN conda install -n app_env -c pytorch -c nvidia -c conda-forge faiss-gpu=1.7.4 -y && \
|
| 22 |
+
conda clean -ya
|
| 23 |
+
|
| 24 |
+
# 6. Install Pip Requirements
|
| 25 |
COPY requirements.txt .
|
| 26 |
RUN pip install --no-cache-dir --upgrade pip && \
|
| 27 |
pip install --no-cache-dir -r requirements.txt
|
| 28 |
|
| 29 |
+
# 7. Fix Permissions
|
|
|
|
|
|
|
|
|
|
|
|
|
| 30 |
RUN chown -R user:user /home/user/app
|
| 31 |
|
| 32 |
+
# 8. Switch to User
|
| 33 |
USER user
|
| 34 |
|
| 35 |
+
# 9. Download Files (Using wget inside the user context)
|
|
|
|
|
|
|
|
|
|
| 36 |
RUN wget https://huggingface.co/datasets/mikonvergence/MajorTOM-SigLIP-Index-Viewer-App/resolve/main/siglip_ivfpq.index -O siglip_ivfpq.index && \
|
| 37 |
wget https://huggingface.co/datasets/mikonvergence/MajorTOM-SigLIP-Index-Viewer-App/resolve/main/siglip_ivfpq_metadata.parquet -O siglip_ivfpq_metadata.parquet
|
| 38 |
|
| 39 |
+
# 10. Copy Application Code
|
|
|
|
| 40 |
COPY --chown=user *.py *.css ./
|
| 41 |
COPY --chown=user helpers/* ./helpers/
|
| 42 |
|
| 43 |
+
# 11. Entrypoint
|
| 44 |
+
# This will execute /opt/conda/envs/app_env/bin/solara
|
| 45 |
ENTRYPOINT ["solara", "run", "app.py", "--host=0.0.0.0", "--port", "7860", "--production"]
|