Spaces:
Sleeping
Sleeping
File size: 1,611 Bytes
700c673 14cd36c 7dfb4c7 c0bbedf c25609b 54215af 801b804 1d13f37 c25609b 0dd98dd c25609b 1d13f37 c25609b 0dd98dd d3a4ebc 4e7102d a380f43 f0c849a a380f43 c25609b f0c849a a380f43 c0bbedf 54215af a07f417 54215af a380f43 14cd36c 54215af 66f8fc1 54215af |
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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# Use an official Python slim image for the base
FROM python:3.10-slim
# Set the working directory
WORKDIR /app
# Install dependencies: wget, unzip, and Python pip
RUN apt-get update && apt-get install -y \
wget \
apt-transport-https \
gnupg2 \
unzip \
python3-pip \
&& rm -rf /var/lib/apt/lists/*
# Download and install Roslyn
RUN wget https://github.com/dotnet/roslyn/releases/download/v4.0.1/roslyn.zip \
&& unzip roslyn.zip -d /usr/local/roslyn \
&& rm roslyn.zip
# Set the PATH for the Roslyn compiler
ENV PATH="/usr/local/roslyn/Microsoft.Net.Compilers.4.0.1/tools:${PATH}"
# Create a non-root user and set it as the user for the rest of the image
RUN useradd -ms /bin/bash appuser
# Ensure the /app directory is owned by the non-root user
RUN chown -R appuser:appuser /app
# Switch to the non-root user
USER appuser
# Create necessary directories and set permissions
RUN mkdir -p /app/uploads /home/appuser/.mono && \
chmod -R 777 /app/uploads /home/appuser/.mono
# Set the MONO_HOME environment variable
ENV MONO_HOME="/home/appuser/.mono"
# Add the Mono tools directory to PATH
ENV PATH="${PATH}:${MONO_HOME}/bin:/usr/bin"
# Verify that csc is installed
RUN which csc
# Copy the requirements file with the correct owner
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"]
|