newmsccompiler / Dockerfile
sigyllly's picture
Upload 4 files
1239cb0 verified
raw
history blame
1.69 kB
# Use an official Python slim image for the base
FROM python:3.10-slim
# Set the working directory
WORKDIR /app
# Install dependencies: Mono, wget, and Python pip
RUN apt-get update && apt-get install -y \
wget \
apt-transport-https \
&& apt-get install -y gnupg2 \
&& echo "deb https://download.mono-project.com/repo/debian stable main" >> /etc/apt/sources.list.d/mono-official-stable.list \
&& wget -qO - https://download.mono-project.com/repo/xamarin.gpg | apt-key add - \
&& apt-get update && apt-get install -y mono-complete \
&& apt-get install -y python3-pip \
&& rm -rf /var/lib/apt/lists/*
# 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"
# Ensure mcs is in the PATH
RUN echo $PATH && which mcs
# 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"]