demo-docker-gradio / Dockerfile
sigyllly's picture
Update Dockerfile
a380f43 verified
raw
history blame
1.36 kB
# Use an official Python slim image for the base
FROM python:3.10-slim
# Set the working directory
WORKDIR /app
# Install dependencies: .NET SDK, wget, and Python pip
RUN apt-get update && apt-get install -y \
wget \
apt-transport-https \
&& wget https://packages.microsoft.com/config/debian/11/packages-microsoft-prod.deb -O packages-microsoft-prod.deb \
&& dpkg -i packages-microsoft-prod.deb \
&& apt-get update && apt-get install -y dotnet-sdk-7.0 \
&& apt-get install -y python3-pip \
&& rm -rf /var/lib/apt/lists/*
# Create a writable directory for .NET
RUN mkdir -p /home/appuser/.dotnet && chmod -R 777 /home/appuser/.dotnet
# Create uploads directory
RUN mkdir -p /app/uploads
# Create a non-root user and switch to it
RUN useradd -ms /bin/bash appuser
USER appuser
# Set permissions for the working directory
RUN chmod -R 777 /app
# Set the DOTNET_HOME environment variable
ENV DOTNET_HOME="/home/appuser/.dotnet"
ENV PATH="${PATH}:${DOTNET_HOME}"
# Copy the requirements file
COPY --chown=appuser:appuser ./requirements.txt /app/requirements.txt
# Install Python dependencies
RUN pip3 install --no-cache-dir --upgrade -r /app/requirements.txt
# Copy the Flask app files
COPY --chown=appuser:appuser . .
# Expose the port the app runs on
EXPOSE 7860
# Command to run the Flask app
CMD ["python3", "main.py"]