Create Dockerfile
Browse files- Dockerfile +55 -0
Dockerfile
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use a full Python image
|
| 2 |
+
FROM python:3.12
|
| 3 |
+
|
| 4 |
+
# Install system dependencies as root
|
| 5 |
+
RUN apt-get update \
|
| 6 |
+
&& apt-get install -qq -y build-essential xvfb xdg-utils wget ffmpeg libpq-dev vim libmagick++-dev fonts-liberation sox bc --no-install-recommends \
|
| 7 |
+
&& apt-get clean
|
| 8 |
+
|
| 9 |
+
## ImageMagicK Installation ##
|
| 10 |
+
RUN mkdir -p /tmp/distr && \
|
| 11 |
+
cd /tmp/distr && \
|
| 12 |
+
wget https://download.imagemagick.org/ImageMagick/download/releases/ImageMagick-7.0.11-2.tar.xz && \
|
| 13 |
+
tar xvf ImageMagick-7.0.11-2.tar.xz && \
|
| 14 |
+
cd ImageMagick-7.0.11-2 && \
|
| 15 |
+
./configure --enable-shared=yes --disable-static --without-perl && \
|
| 16 |
+
make && \
|
| 17 |
+
make install && \
|
| 18 |
+
ldconfig /usr/local/lib && \
|
| 19 |
+
cd /tmp && \
|
| 20 |
+
rm -rf distr
|
| 21 |
+
|
| 22 |
+
# Create a new user named "user" with user ID 1000
|
| 23 |
+
RUN useradd -m -u 1000 user
|
| 24 |
+
|
| 25 |
+
# Switch to the "user" user for the remainder of the build
|
| 26 |
+
USER user
|
| 27 |
+
|
| 28 |
+
# Set home to the user's home directory and update PATH accordingly
|
| 29 |
+
ENV HOME=/home/user \
|
| 30 |
+
PATH=/home/user/.local/bin:$PATH
|
| 31 |
+
|
| 32 |
+
# Set the working directory to the user's home directory
|
| 33 |
+
WORKDIR $HOME/app
|
| 34 |
+
|
| 35 |
+
# Upgrade pip (as non-root) to avoid permission issues
|
| 36 |
+
RUN pip install --no-cache-dir --upgrade pip
|
| 37 |
+
|
| 38 |
+
# Copy the requirements file (with the correct ownership) to leverage Docker cache
|
| 39 |
+
COPY --chown=user requirements.txt $HOME/app/requirements.txt
|
| 40 |
+
|
| 41 |
+
# Install Python dependencies
|
| 42 |
+
RUN pip install -r requirements.txt
|
| 43 |
+
|
| 44 |
+
# Copy the rest of the application code into the container (with proper ownership)
|
| 45 |
+
COPY --chown=user . $HOME/app
|
| 46 |
+
|
| 47 |
+
# (Optional) If you need to download a checkpoint or other assets:
|
| 48 |
+
# RUN mkdir -p content
|
| 49 |
+
# ADD --chown=user https://<SOME_ASSET_URL> content/<SOME_ASSET_NAME>
|
| 50 |
+
|
| 51 |
+
# Expose port 7860 (Hugging Face Spaces expects your app to listen on this port)
|
| 52 |
+
EXPOSE 7860
|
| 53 |
+
|
| 54 |
+
# Command to run the FastAPI app using uvicorn.
|
| 55 |
+
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
|