my-second-project / Dockerfile
Atomik31's picture
Initial commit
d338053
# Start with a lightweight Linux Anaconda image
FROM continuumio/miniconda3:25.3.1-1
# Update all packages and install nano unzip and curl
RUN apt-get update
RUN apt-get install nano unzip curl -y
# THIS IS SPECIFIC TO HUGGINFACE
# We create a new user named "user" with ID of 1000
RUN useradd -m -u 1000 user
# We switch from "root" (default user when creating an image) to "user"
USER user
# We set two environmnet variables
# so that we can give ownership to all files in there afterwards
# we also add /home/user/.local/bin in the $PATH environment variable
# PATH environment variable sets paths to look for installed binaries
# We update it so that Linux knows where to look for binaries if we were to install them with "user".
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
# We set working directory to $HOME/app (<=> /home/user/app)
WORKDIR $HOME/app
# Leverage layer caching: copy only reqs first
COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt
# Copy all local files to /home/user/app with "user" as owner of these files
# Always use --chown=user when using HUGGINGFACE to avoid permission errors
COPY --chown=user . $HOME/app
# THIS IS SPECIFIC TO HUGGINGFACE AS WELL
# expose port 7860 which is the port used by HuggingFace for Web Application
EXPOSE 7860
# Run streamlit server
CMD ["streamlit", "run", "app.py", "--server.port=7860"]