Spaces:
Running
Running
# Step 1: Use Python 3.11.9 as required | |
FROM python:3.11.9 | |
# Step 2: Set up environment variables and timezone configuration | |
ENV TZ=Asia/Colombo | |
RUN apt-get update && apt-get install -y libaio1 wget unzip tzdata \ | |
&& ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone | |
# Step 4: Add a user for running the app (after installations) | |
RUN useradd -m -u 1000 user | |
# Step 5: Create the /app directory and set ownership to the new user | |
RUN mkdir -p /app && chown -R user:user /app | |
# Step 6: Switch to non-root user after the directory has the right permissions | |
USER user | |
ENV PATH="/home/user/.local/bin:$PATH" | |
# Step 7: Set up the working directory for the app | |
WORKDIR /app | |
# Step 8: Copy the requirements file and install dependencies | |
COPY --chown=user ./requirements.txt requirements.txt | |
RUN pip install --no-cache-dir --upgrade -r requirements.txt | |
# Step 9: Install pipenv and handle pipenv environment | |
RUN pip install pipenv | |
COPY --chown=user . /app | |
RUN pipenv install | |
# Step 10: Expose the necessary port (7860 for Hugging Face Spaces) | |
EXPOSE 7860 | |
# Step 11: Set environment variables for the app | |
ENV APP_HOST=0.0.0.0 | |
ENV APP_PORT=7860 | |
# Step 12: Create logs directory (if necessary) | |
RUN mkdir -p /app/logs | |
# Step 13: Run the app using Uvicorn, listening on port 7860 | |
CMD ["cd reggpt"] | |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] |