Spaces:
Running
Running
FROM python:3.9 | |
# Create a user with UID 1000 | |
RUN useradd -m -u 1000 user | |
# Set the working directory and user environment variables | |
ENV HOME=/ \ | |
PATH=/bin:$PATH | |
# Copy the requirements file to the /code directory | |
COPY ./requirements.txt /code/requirements.txt | |
# Install the Python dependencies | |
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt | |
# Create a directory for cache and set permissions | |
RUN mkdir -p /.cache && chmod 777 /.cache && chown user:user /.cache | |
RUN pwd && ls -l | |
# Create the database file and set permissions | |
RUN touch /app/users.db && chmod 777 /app/users.db && chown user:user /app/users.db | |
# Change ownership of mentor.txt and temp_mentor.txt | |
RUN chown user:user /app/mentor.txt /app/temp_mentor.txt | |
# Change ownership of the 'app' directory | |
RUN chown user:user /app | |
# Switch back to the user | |
USER user | |
# Set the working directory for the application | |
WORKDIR /app | |
# Start the application using gunicorn | |
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:7860", "--timeout", "300", "main:app"] | |