Spaces:
Runtime error
Runtime error
File size: 1,012 Bytes
2b58075 312e599 fd71755 7d95607 0b18a30 312e599 2b58075 371be76 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# Step 1: Choose a base image
FROM python:3.9
# Step 2: Set the working directory inside the container
WORKDIR /app
# Step 3: Copy the application files to the container
COPY . /app
# Step 4: Install the required dependencies
RUN pip install -r requirements.txt
# Step 5: Expose the necessary port
EXPOSE 7860
# Install huggingface-cli
RUN pip install huggingface_hub
# Login to Hugging Face using the token from the environment variable
# Create a non-root user and grant read-write permissions
RUN useradd -ms /bin/bash myuser
RUN chown -R myuser:myuser /app
# Change permissions of /app directory
RUN chmod -R 777 /app
# Switch to the non-root user
USER myuser
# Expose the secret HUGGINGFACE_TOKEN at buildtime and use its value as the Hugging Face token
RUN --mount=type=secret,id=HUGGINGFACE_TOKEN,mode=0444,required=true \
echo "HUGGINGFACE_TOKEN=$(cat /run/secrets/HUGGINGFACE_TOKEN)" > .env
# Step 6: Define the entry point command
CMD ["flask", "run", "--host=0.0.0.0", "--port=7860"]
|