Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- Dockerfile +16 -9
Dockerfile
CHANGED
|
@@ -10,24 +10,31 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
| 10 |
curl \
|
| 11 |
&& rm -rf /var/lib/apt/lists/*
|
| 12 |
|
| 13 |
-
# ββ
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
# ββ Install Python dependencies ββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 17 |
-
|
|
|
|
| 18 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 19 |
|
| 20 |
# ββ Copy full application source βββββββββββββββββββββββββββββββββββββββββββββββ
|
| 21 |
-
COPY
|
| 22 |
|
| 23 |
# ββ Create writable directories ββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 24 |
-
RUN mkdir -p outputs storage web_app/__pycache__
|
| 25 |
-
&& chmod -R 777 /app
|
| 26 |
|
| 27 |
# ββ Streamlit config β disable telemetry, set port ββββββββββββββββββββββββββββ
|
| 28 |
-
RUN mkdir -p .streamlit \
|
| 29 |
-
&& cp web_app/streamlit_config.toml .streamlit/config.toml
|
| 30 |
-
&& chmod -R 777 .streamlit
|
| 31 |
|
| 32 |
# ββ HF Spaces: port 7860 ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 33 |
EXPOSE 7860
|
|
|
|
| 10 |
curl \
|
| 11 |
&& rm -rf /var/lib/apt/lists/*
|
| 12 |
|
| 13 |
+
# ββ Create a non-root user (Required for Hugging Face Spaces) ββββββββββββββββββ
|
| 14 |
+
RUN useradd -m -u 1000 user
|
| 15 |
+
USER user
|
| 16 |
+
|
| 17 |
+
# ββ Setup environment ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 18 |
+
ENV HOME=/home/user \
|
| 19 |
+
PATH=/home/user/.local/bin:$PATH
|
| 20 |
+
|
| 21 |
+
# Set the working directory to the user's home directory
|
| 22 |
+
WORKDIR $HOME/app
|
| 23 |
|
| 24 |
# ββ Install Python dependencies ββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 25 |
+
# Copy requirements first to leverage Docker cache
|
| 26 |
+
COPY --chown=user web_app/requirements.txt ./requirements.txt
|
| 27 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 28 |
|
| 29 |
# ββ Copy full application source βββββββββββββββββββββββββββββββββββββββββββββββ
|
| 30 |
+
COPY --chown=user . $HOME/app
|
| 31 |
|
| 32 |
# ββ Create writable directories ββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 33 |
+
RUN mkdir -p outputs storage web_app/__pycache__
|
|
|
|
| 34 |
|
| 35 |
# ββ Streamlit config β disable telemetry, set port ββββββββββββββββββββββββββββ
|
| 36 |
+
RUN mkdir -p $HOME/.streamlit \
|
| 37 |
+
&& cp web_app/streamlit_config.toml $HOME/.streamlit/config.toml
|
|
|
|
| 38 |
|
| 39 |
# ββ HF Spaces: port 7860 ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 40 |
EXPOSE 7860
|