image-compressor-api / Dockerfile
earncoding's picture
Create Dockerfile
9c99151 verified
Raw
History Blame Contribute Delete
626 Bytes
# Use the official Python image
FROM python:3.9
# Set the working directory
WORKDIR /code
# Copy the requirements file
COPY ./requirements.txt /code/requirements.txt
# Install dependencies
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
# Copy the application code
COPY ./main.py /code/main.py
# Create a non-root user (Security best practice for HF Spaces)
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
# Expose port 7860 (Hugging Face default)
EXPOSE 7860
# Command to run the API
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]