Spaces:
Sleeping
Sleeping
Download Dockerfile from AnthonyTruchetPoC/persistent-docker: direct link, hf CLI and curl.
- Browser
- Download file 2.72 kB
-
https://huggingface.co/spaces/AnthonyTruchetPoC/persistent-docker/resolve/main/Dockerfile
- Command line
-
hf download hf://spaces/AnthonyTruchetPoC/persistent-docker/Dockerfile
-
curl -L -o Dockerfile https://huggingface.co/spaces/AnthonyTruchetPoC/persistent-docker/resolve/main/Dockerfile
2.72 kB
| # syntax=docker/dockerfile:1 | |
| FROM python:3.10.12 | |
| ARG APP_HOME=/home/user | |
| ARG APP_CODE=/opt/code | |
| ARG APP_DATA=/data/app | |
| ARG HF_HOME=/data/huggingface | |
| ENV APP_CODE=$APP_CODE \ | |
| APP_DATA=$APP_DATA \ | |
| HF_HOME=$HF_HOME | |
| ENV PYTHONUNBUFFERED=1 \ | |
| SYSTEM=spaces \ | |
| SHELL=/bin/bash | |
| # Remove any third-party apt sources to avoid issues with expiring keys. | |
| # Install some basic utilities | |
| RUN rm -f /etc/apt/sources.list.d/*.list && \ | |
| apt-get update && apt-get install -y --no-install-recommends \ | |
| curl \ | |
| ca-certificates \ | |
| sudo \ | |
| git \ | |
| git-lfs \ | |
| zip \ | |
| unzip \ | |
| htop \ | |
| bzip2 \ | |
| libx11-6 \ | |
| build-essential \ | |
| libsndfile-dev \ | |
| software-properties-common \ | |
| nodejs \ | |
| && rm -rf /var/lib/apt/lists/* | |
| WORKDIR /opt | |
| # Create a non-root user and switch to it | |
| RUN adduser --disabled-password --gecos '' --shell /bin/bash -u 1000 user \ | |
| && chown -R user:user /opt | |
| RUN echo "user ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers | |
| USER user | |
| # All users can use /home/user as their home directory | |
| ENV HOME=$APP_HOME | |
| ENV PATH=$HOME/.local/bin:$PATH | |
| RUN mkdir -p $HOME/.cache $HOME/.config \ | |
| && chmod -R 777 $HOME | |
| ####################################### | |
| # Start root user section | |
| ####################################### | |
| USER root | |
| # User Debian packages | |
| ## Security warning : Potential user code executed as root (build time) | |
| RUN --mount=target=/root/packages.txt,source=packages.txt \ | |
| apt-get update \ | |
| && xargs -r -a /root/packages.txt apt-get install -y --no-install-recommends \ | |
| && rm -rf /var/lib/apt/lists/* | |
| RUN --mount=target=/root/on_startup.sh,source=on_startup.sh,readwrite \ | |
| bash /root/on_startup.sh | |
| ####################################### | |
| # End root user section | |
| ####################################### | |
| USER user | |
| WORKDIR $APP_HOME | |
| RUN --mount=target=$APP_CODE/requirements.txt,source=requirements.txt \ | |
| pip3 install --no-cache-dir --upgrade pip \ | |
| && pip install --no-cache-dir --upgrade -r $APP_CODE/requirements.txt | |
| # Copy our code to $APP_CODE and config | |
| COPY --chown=user:user --chmod=u=rX src/ $APP_CODE/ | |
| COPY --chown=user ./start_*.sh $APP_HOME | |
| RUN chmod +x $APP_HOME/start_*.sh | |
| COPY --chown=user:user --chmod=u=rX .streamlit/ $APP_HOME/.streamlit/ | |
| # Persistent disk space | |
| # Assumes a mount is passed to the docker command, like: | |
| # $ docker ... --mount type=volume,src=ai-playground-vol,dst=/data ... | |
| # see https://huggingface.co/docs/hub/spaces-storage | |
| VOLUME /data | |
| ENV PYTHONPATH=$APP_CODE:$PYTHONPATH | |
| RUN ln -s $APP_DATA/ data | |
| RUN ln -s $APP_CODE/ code | |
| ADD jupyter/notebooks notebooks | |
| # Expose streamlit application | |
| EXPOSE 8501 | |
| EXPOSE 7860 | |
| ENTRYPOINT [ "bash", "-o", "allexport" ] | |
| CMD [ "-f", "./start_server.sh" ] | |