Spaces:
Running
on
L4
Running
on
L4
Update Dockerfile
Browse files- Dockerfile +31 -22
Dockerfile
CHANGED
|
@@ -1,36 +1,45 @@
|
|
| 1 |
-
FROM
|
| 2 |
|
| 3 |
-
# 1. Set up a new user
|
| 4 |
RUN useradd -m -u 1000 user
|
| 5 |
|
| 6 |
-
# 2. Set
|
|
|
|
|
|
|
| 7 |
ENV HOME=/home/user \
|
| 8 |
-
PATH=/
|
| 9 |
|
| 10 |
-
# 3.
|
| 11 |
-
|
| 12 |
-
WORKDIR $HOME/app
|
| 13 |
|
| 14 |
-
# 4.
|
| 15 |
-
|
|
|
|
|
|
|
| 16 |
|
| 17 |
-
#
|
| 18 |
-
|
| 19 |
-
COPY
|
| 20 |
-
RUN pip install --no-cache-dir --upgrade
|
|
|
|
| 21 |
|
| 22 |
-
#
|
| 23 |
-
#
|
| 24 |
-
|
| 25 |
-
ADD https://huggingface.co/datasets/mikonvergence/MajorTOM-SigLIP-Index-Viewer-App/resolve/main/siglip_ivfpq_metadata.parquet ./siglip_ivfpq_metadata.parquet
|
| 26 |
|
| 27 |
-
#
|
| 28 |
-
USER root
|
| 29 |
-
RUN chown user:user ./siglip_ivfpq.index ./siglip_ivfpq_metadata.parquet
|
| 30 |
USER user
|
| 31 |
|
| 32 |
-
#
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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"]
|